Exemplo n.º 1
0
 def testLoglevel(self):
     # test default value
     self.assertEqual("normal", msger.get_loglevel())
     # test no effect value
     msger.set_loglevel("zzzzzz")
     self.assertEqual("normal", msger.get_loglevel())
     # test effect value
     msger.set_loglevel("verbose")
     self.assertEqual("verbose", msger.get_loglevel())
     msger.set_loglevel("debug")
     self.assertEqual("debug", msger.get_loglevel())
     msger.set_loglevel("quiet")
     self.assertEqual("quiet", msger.get_loglevel())
Exemplo n.º 2
0
 def testLoglevel(self):
     # test default value
     self.assertEqual("normal", msger.get_loglevel())
     # test no effect value
     msger.set_loglevel("zzzzzz")
     self.assertEqual("normal", msger.get_loglevel())
     # test effect value
     msger.set_loglevel("verbose")
     self.assertEqual("verbose", msger.get_loglevel())
     msger.set_loglevel("debug")
     self.assertEqual("debug", msger.get_loglevel())
     msger.set_loglevel("quiet")
     self.assertEqual("quiet", msger.get_loglevel())
Exemplo n.º 3
0
def select_bootstrap(repomd, cachedir, bootstrapdir):
    cfgmgr = configmgr
    lvl = msger.get_loglevel()
    msger.set_loglevel('quiet')
    repo_rpmver = misc.get_rpmver_in_repo(repomd)
    if not repo_rpmver:
        msger.set_loglevel(lvl)
        return (None, None)

    # Check avaliable bootstrap
    bootstrap_env = bootstrap.Bootstrap(homedir=bootstrapdir)
    for bs in bootstrap_env.list():
        if compare_rpmversion(repo_rpmver, bs['rpm']):
            return (bs['name'], {})

    for bsname, bsrepo in list(cfgmgr.bootstraps.items()):
        repolist = []
        for repo in list(bsrepo.keys()):
            repolist.append(bsrepo[repo])

        rpmver = None
        try:
            repomd = misc.get_metadata_from_repos(repolist, cachedir)
            rpmver = misc.get_rpmver_in_repo(repomd)
        except errors.CreatorError as e:
            msger.set_loglevel(lvl)
            raise

        if not rpmver:
            continue
        if compare_rpmversion(repo_rpmver, rpmver):
            msger.set_loglevel(lvl)
            return (bsname, bsrepo)
    msger.set_loglevel(lvl)
    return (None, None)
Exemplo n.º 4
0
def select_bootstrap(repomd, cachedir, bootstrapdir):
    cfgmgr = configmgr
    lvl = msger.get_loglevel()
    msger.set_loglevel('quiet')
    repo_rpmver = misc.get_rpmver_in_repo(repomd)
    if not repo_rpmver:
        msger.set_loglevel(lvl)
        return (None, None)

    # Check avaliable bootstrap
    bootstrap_env = bootstrap.Bootstrap(homedir = bootstrapdir)
    for bs in bootstrap_env.list():
        if compare_rpmversion(repo_rpmver, bs['rpm']):
            return (bs['name'], {})

    for bsname, bsrepo in cfgmgr.bootstraps.items():
        repolist = []
        for repo in bsrepo.keys():
            repolist.append(bsrepo[repo])

        rpmver = None
        try:
            repomd = misc.get_metadata_from_repos(repolist, cachedir)
            rpmver = misc.get_rpmver_in_repo(repomd)
        except errors.CreatorError, e:
            msger.set_loglevel(lvl)
            raise

        if not rpmver:
            continue
        if compare_rpmversion(repo_rpmver, rpmver):
            msger.set_loglevel(lvl)
            return (bsname, bsrepo)
Exemplo n.º 5
0
class BackendPlugin(_Plugin):
    mic_plugin_type = "backend"

    # suppress the verbose rpm warnings
    if msger.get_loglevel() != 'debug':
        import rpm
        rpm.setVerbosity(rpm.RPMLOG_ERR)

    def addRepository(self):
        pass
Exemplo n.º 6
0
 def setUp(self):
     self.configmgr = conf.ConfigMgr(siteconf=SITECONF)
     shutil.copy2(KSCONF, KSBAK)
     with open(KSCONF, 'r') as f:
         content = f.read()
     content = content.replace('$$$$$$', "file://" + REPOURI)
     with open(KSCONF, 'w') as f:
         f.write(content)
     if not os.path.exists(CACHEDIR):
         os.makedirs(CACHEDIR)
     self.configmgr.create['cachedir'] = CACHEDIR
     self.level = msger.get_loglevel()
     msger.set_loglevel('RAWTEXT')
Exemplo n.º 7
0
    def run(self, name, cmd, chdir='/', bindmounts=None):
        self.rootdir = name
        def mychroot():
            os.chroot(self.rootdir)
            os.chdir(chdir)

        if isinstance(cmd, list):
            cmd = ' '.join(cmd)

        lvl = msger.get_loglevel()
        msger.set_loglevel('quiet')
        globalmounts = chroot.setup_chrootenv(self.rootdir, bindmounts)
        try:
            proxy.set_proxy_environ()
            subprocess.call(cmd, preexec_fn=mychroot, shell=True)
            proxy.unset_proxy_environ()
        except:
            raise errors.BootstrapError("Run in bootstrap fail")
        finally:
            chroot.cleanup_chrootenv(self.rootdir, bindmounts, globalmounts)

        msger.set_loglevel(lvl)