當前位置: 首頁>>代碼示例>>Python>>正文


Python ServiceController.getServices方法代碼示例

本文整理匯總了Python中agent.controllers.service.ServiceController.getServices方法的典型用法代碼示例。如果您正苦於以下問題:Python ServiceController.getServices方法的具體用法?Python ServiceController.getServices怎麽用?Python ServiceController.getServices使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在agent.controllers.service.ServiceController的用法示例。


在下文中一共展示了ServiceController.getServices方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: cleanupOrphanedPackages

# 需要導入模塊: from agent.controllers.service import ServiceController [as 別名]
# 或者: from agent.controllers.service.ServiceController import getServices [as 別名]
    def cleanupOrphanedPackages(checkAge = False):
        '''  API to cleanup Orphaned Packages For All Services '''
        from agent.controllers.service import ServiceController
        #services = os.listdir(service_nodes)
        from agent.controllers.manifest import ManifestController
        #import pdb;pdb.set_trace()
        services = ServiceController.getServices()
        service_nodes = ServiceController.serviceRootPath()

        linkedPaths = []
        sysServices = ['agent']
        LOG.info('Garbage collecting orphaned installed packages')
        for service in services:
            try:
                if service in sysServices:
                    LOG.debug('system services cannot be garbage collected')
                else:
                    servicePath = os.path.join(service_nodes, service)
                    installedPkgPath = os.path.join(servicePath, 'installed-packages')
                    linkedPaths.extend(ManifestController.getAllSymLinks(service))
                    linkedPaths.extend(manifestutil.getModuleSymLinks(service))
                    LOG.debug('symLinks returned %s' % linkedPaths)
                    installedPkgPaths = PackageUtil.getAllInstalledPackages(installedPkgPath)
                    LOG.debug('installedPkgPaths returned for the service %s' % installedPkgPaths)
                    if len(installedPkgPaths) > 0:
                        orphanPkgs = set(installedPkgPaths) - set(linkedPaths)
                        LOG.debug('orphanPkgs returned %s' % orphanPkgs)
                        PackageUtil.cleanupInstalledPkgs(installedPkgPath, orphanPkgs)
            except BaseException as excep:
                LOG.error('Failed to proceed with garbage collection %s' % str(excep))
                # agent-804, manifests only contains folders, need to delete if file is in manifests
                servicePath = os.path.join(service_nodes, service)
                if not os.path.isdir(servicePath):
                    utils.runsyscmd('rm -f %s' % servicePath)
        LOG.info('Garbage collecting orphaned installed packages completed')
開發者ID:anzarafaq,項目名稱:cronusagent,代碼行數:37,代碼來源:package.py

示例2: __deleteServices

# 需要導入模塊: from agent.controllers.service import ServiceController [as 別名]
# 或者: from agent.controllers.service.ServiceController import getServices [as 別名]
    def __deleteServices(self):
        """ delete all services except agent itself; clear all manifests in 'agent' itself except current active"""
        self._updateStatus(progress = 60)
        services = ServiceController.getServices()

        #kill all service threads
        self._threadMgr.stopServiceThread()

        #remove folder
        for service in services:
            if 'agent' == service:
                self.__delAllExceptActiveManifests(service)
                continue

            path = ServiceController.servicePath(service)
            # retry service cleanup
            for _ in range(3):
                if not os.path.exists(path):
                    break
                ServiceDelete.deleteFolderContents(path)
                # sleep here a bit to ensure delete is complete
                time.sleep(1)

            if os.path.exists(path):
                msg = 'Could not delete service %s completely even after 3 retries.' % service
                LOG.error(msg)
                raise Exception(msg)

        self._updateStatus(progress = 90)
開發者ID:cronuspaas,項目名稱:cronusagent,代碼行數:31,代碼來源:services_cleanup.py

示例3: stopServiceThread

# 需要導入模塊: from agent.controllers.service import ServiceController [as 別名]
# 或者: from agent.controllers.service.ServiceController import getServices [as 別名]
    def stopServiceThread(self):
        """ stop all service threads """
        from agent.controllers.service import ServiceController

        LOG.info("Stopping service thread")
        with self.__lock:
            services = ServiceController.getServices()
            for service in services:
                threads = self.getThreadByCat(ServiceController.serviceCat(service), fastbreak=False)
                for thread in threads:
                    thread.stop()
開發者ID:arunkumar-m,項目名稱:cronus-agent,代碼行數:13,代碼來源:threadmgr.py


注:本文中的agent.controllers.service.ServiceController.getServices方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。