Пример #1
0
 def test_cleanupOrphanedPackages2(self):
     from agent.lib.utils import rchown
     from agent.tests.unit.test_util import createManifest
     serviceName = 'service2'
     manifestName = 'manifestA'
     serviceName1 = 'service3'
     try:
         createManifest(self, packages = ["http://github.com/yubin154/cronusagent/blob/master/agent/agent/tests/unit/packages/perlserver-1.0.0.unix.cronus"],
                                   service = serviceName, manifest = manifestName)
         createManifest(self, packages = ["http://github.com/yubin154/cronusagent/blob/master/agent/agent/tests/unit/packages/perlserver-1.0.0.unix.cronus"],
                                   service = serviceName1, manifest = manifestName)
     except Exception as ex:
         print 'exception thrown during mf %s' % str(ex)
     installedPkgPath = os.path.realpath(os.path.join(manifestutil.serviceRootPath() , serviceName, 'installed-packages'))
     installedPkgPath1 = os.path.realpath(os.path.join(manifestutil.serviceRootPath() , serviceName1, 'installed-packages'))
     uname = configutil.getAgentUser()
     uid, gid = utils.getUidGid(uname)
     rchown(installedPkgPath, uid, gid)
     rchown(installedPkgPath1, uid, gid)
     self.assertEquals(len(os.listdir(installedPkgPath)) , 1)
     self.assertEquals(len(os.listdir(installedPkgPath1)) , 1)
     self.app.delete(url(controller = 'manifest', action = 'delete', service = serviceName, manifest = manifestName), expect_errors = True)
     self.app.delete(url(controller = 'manifest', action = 'delete', service = serviceName1, manifest = manifestName), expect_errors = True)
     pylons.config['packageMgr_install_package_age'] = 0
     pylons.config['packageMgr_install_package_min_age'] = 0.0
     PackageMgr.cleanupOrphanedPackages()
     self.assertEquals(len(os.listdir(installedPkgPath)) , 0)
     self.assertEquals(len(os.listdir(installedPkgPath1)) , 0)
Пример #2
0
 def listServices(self):
     """ list services """
     packageList = getServices()
     return ApplogController.prepareOutput(
                     packageList, 
                     "/applog/packages?service=", 
                     serviceRootPath(), 
                     "List Of Services")
Пример #3
0
    def test_cleanUpAllInstalledPackages(self):
        from agent.lib.utils import rchown
        from agent.tests.unit.test_util import createManifest
        #import pdb;pdb.set_trace();
        serviceName = 'service3'
        manifestName = 'manifestB'
        try:
            createManifest(self, packages = ["http://github.com/yubin154/cronusagent/blob/master/agent/agent/tests/unit/packages/perlserver-1.0.0.unix.cronus"],
                                  service = serviceName, manifest = manifestName)
        except Exception as ex:
            print 'exception thrown during mf %s' % str(ex)

        installedPkgPath = os.path.realpath(os.path.join(manifestutil.serviceRootPath() , serviceName, 'installed-packages'))

        uname = configutil.getAgentUser()
        uid, gid = utils.getUidGid(uname)
        rchown(installedPkgPath, uid, gid)


        pkgs = []
        for pkg in os.listdir(installedPkgPath):
            pkgs.append(os.path.join(installedPkgPath, pkg))

        pkgVers = []
        for pkg in pkgs:
            for pkgVer in os.listdir(pkg):
                pkgVers.append(os.path.join(pkg, pkgVer))

        self.assertEquals(len(os.listdir(installedPkgPath)) , 1)

        self.app.delete(url(controller = 'manifest', action = 'delete', service = serviceName, manifest = manifestName), expect_errors = True)
        #import pdb; pdb.set_trace();
        symLinks = [] #ManifestController.getAllSymLinks(serviceName)
        orphans = set(pkgVers) - set(symLinks)
        age = pylons.config['packageMgr_install_package_age']
        minage = pylons.config['packageMgr_install_package_min_age']
        pylons.config['packageMgr_install_package_age'] = 0
        pylons.config['packageMgr_install_package_min_age'] = 0.0
        self.assertEquals(len(os.listdir(installedPkgPath)) , 1)
        PackageUtil.cleanupInstalledPkgs(installedPkgPath, orphans)
        #PackageUtil.cleanUpInstalledPkgs(installedPkgPath, orphans)
        self.assertEquals(len(os.listdir(installedPkgPath)) , 0)
        pylons.config['packageMgr_install_package_age'] = age
        pylons.config['packageMgr_install_package_min_age'] = minage
Пример #4
0
 def listServices(self):
     """ listServices """
     packageList = getServices()
     return ModulelogController.prepareOutput(
         packageList, "/log/list/packages?service=", serviceRootPath(),
         "List Of Services")
Пример #5
0
 def downloadAgentLog(self):
     """ show log file """
     print serviceRootPath()
     return downloadFile('logs/agent.log')
Пример #6
0
 def testServiceRootPath(self):
     print manifestutil.serviceRootPath()
     assert manifestutil.serviceRootPath() is not None
Пример #7
0
 def testServiceRootPath(self):
     print manifestutil.serviceRootPath()
     assert manifestutil.serviceRootPath() is not None
Пример #8
0
 def downloadAgentLog(self):
     """ show log file """
     print serviceRootPath()
     return downloadFile('logs/agent.log')