コード例 #1
0
ファイル: misc.py プロジェクト: zeroluck/simian
 def get(self, report=None, uuid=None):
     """Misc get handler."""
     auth.DoUserAuth()
     if report == 'hostmanifest':
         self._DisplayHostManifest(uuid=uuid)
     elif report == 'installs':
         pending = self.request.get('pending') == '1'
         pkg = urllib.unquote(self.request.get('pkg', 'all'))
         if pending:
             self._DisplayHostsPendingPkg(pkg)
         else:
             self._DisplayInstallsForPackage(pkg)
     elif report == 'installproblems':
         self._DisplayInstallProblems()
     elif report == 'preflightexits':
         self._DisplayPreflightExits()
     elif report == 'diskfree':
         self._DisplayLowDiskFree()
     elif report == 'uptime':
         self._DisplayLongestUptime()
     elif report == 'offcorp':
         self._DisplayLongestOffCorp()
     elif report == 'manifest':
         track = uuid
         self._DisplayManifest(track)
     elif report == 'msulogsummary':
         self._DisplayMsuLogSummary()
     elif report == 'msulogevent':
         self._DisplayMsuLogEvent()
     elif report == 'user_settings':
         self._DisplayUserSettings()
     elif report == 'clientlog':
         log_key_name = uuid
         l = models.ClientLogFile.get_by_key_name(log_key_name)
         if l:
             self.response.headers[
                 'Content-Type'] = 'text/plain; charset=utf-8'
             self.response.out.write(l.log_file)
         else:
             self.response.out.write('Log not found')
             self.response.set_status(404)
     elif report == 'maintenance':
         if not self.IsAdminUser():
             self.response.set_status(403)
             return
         from simian.mac.admin import maintenance
         action = uuid
         if action == 'update_installs_schema':
             maintenance.UpdateInstallLogSchema()
         elif action == 'update_legacy_apple_updates':
             maintenance.ConvertLegacyAppleUpdateInstallLogEntities()
         elif action == 'rebuild_install_counts':
             maintenance.RebuildInstallCounts()
         else:
             self.response.set_status(404)
     else:
         self.response.set_status(404)
コード例 #2
0
 def get(self, report=None, uuid=None):
     """Stats get handler."""
     auth.DoUserAuth()
     if not report:
         report_type = self.request.get('type')
         report_filter = self.request.get('filter')
         if report_type and report_filter:
             report_filter = urllib.unquote(report_filter)
             report_filter = report_filter.strip()
             self._DisplaySummary(report_type, report_filter)
         else:
             self._DisplayCachedSummary()
     elif report == 'host':
         self._DisplayHost(uuid=uuid)
     elif report == 'hostmanifest':
         self._DisplayHostManifest(uuid=uuid)
     elif report == 'installs':
         pkg = self.request.get('pkg')
         historical = self.request.get('historical') == '1'
         applesus = self.request.get('applesus') == '1'
         pending = self.request.get('pending') == '1'
         if pkg:
             if pending:
                 self._DisplayHostsPendingPkg(pkg)
             else:
                 self._DisplayInstallsForPackage(pkg)
         else:
             if historical or applesus:
                 self._DisplayPackagesListFromCache(applesus=applesus)
             else:
                 self._DisplayPackagesList()
     elif report == 'installproblems':
         self._DisplayInstallProblems()
     elif report == 'preflightexits':
         self._DisplayPreflightExits()
     elif report == 'diskfree':
         self._DisplayLowDiskFree()
     elif report == 'uptime':
         self._DisplayLongestUptime()
     elif report == 'offcorp':
         self._DisplayLongestOffCorp()
     elif report == 'brokenclients':
         self._DisplayBrokenClients()
     elif report == 'msulogsummary':
         self._DisplayMsuLogSummary(since_days=uuid)
     elif report == 'msulogevent':
         self._DisplayMsuLogEvent()
     elif report == 'user_settings':
         self._DisplayUserSettings()
     elif report == 'adminlogs':
         self._DisplayAdminLogs()
     elif report == 'loststolen':
         self._DisplayLostStolen()
     elif report == 'packagealias':
         self._DisplayPackageAlias()
     elif report == 'clientlog':
         log_key_name = uuid
         l = models.ClientLogFile.get_by_key_name(log_key_name)
         if l:
             self.response.headers[
                 'Content-Type'] = 'text/plain; charset=utf-8'
             self.response.out.write(l.log_file)
         else:
             self.response.out.write('Log not found')
             self.response.set_status(404)
     elif report == 'maintenance':
         if not auth.IsAdminUser():
             self.response.set_status(403)
             return
         from simian.mac.admin import maintenance
         action = uuid
         if action == 'update_installs_schema':
             maintenance.UpdateInstallLogSchema()
         elif action == 'update_legacy_apple_updates':
             maintenance.ConvertLegacyAppleUpdateInstallLogEntities()
         elif action == 'rebuild_install_counts':
             maintenance.RebuildInstallCounts()
         else:
             self.response.set_status(404)
     else:
         self.response.set_status(404)