コード例 #1
0
ファイル: test_RHNSync.py プロジェクト: mccun934/grinder
 def test_loadConfig(self):
     """
     Test loading a config file supplies correct values
     """
     configFile = "./tests/config/testConfigA.yml"
     rhnSync = RHNSync()
     self.assertTrue(rhnSync.loadConfig(configFile))
     self.assertTrue(self.validateOptions(rhnSync))
コード例 #2
0
 def testSync(self):
     channel_label = "rhel-i386-server-vt-5"
     rhnSync = RHNSync()
     report = rhnSync.syncPackages(channel_label,
                                   "./%s" % (channel_label),
                                   callback=sampleCallBack)
     print "report = %s" % (report)
     self.assertTrue(G_STATUS == "FINISHED")
     self.assertTrue(G_SIZE_LEFT == 0)
     self.assertTrue(G_ITEMS_LEFT == 0)
コード例 #3
0
ファイル: test_RHNSync.py プロジェクト: Katello/grinder
 def testSync(self):
     channel_label = "rhel-i386-server-vt-5"
     rhnSync = RHNSync()
     report = rhnSync.syncPackages(channel_label, 
             "./%s" % (channel_label), 
             callback=sampleCallBack)
     print "report = %s" % (report)
     self.assertTrue(G_STATUS == "FINISHED")
     self.assertTrue(G_SIZE_LEFT == 0)
     self.assertTrue(G_ITEMS_LEFT == 0)
コード例 #4
0
ファイル: GrinderCLI.py プロジェクト: dhajoshi/grinder
    def __init__(self):
        usage = "usage: %prog rhn [OPTIONS]"
        shortdesc = "Fetches content from a rhn source."
        desc = "rhn"
        CliDriver.__init__(self, "rhn", usage, shortdesc, desc)
        #GrinderLog.setup(self.debug)
        self.rhnSync = RHNSync()

        self.parser.add_option('-a', '--all', action='store_true', 
                help='Fetch ALL packages from a channel, not just latest')
        self.parser.add_option('-b', '--basepath', action='store', 
                help='Path RPMs are stored')
        self.parser.add_option('-c', '--certfile', action='store', 
                help='Entitlement Certificate')
        self.parser.add_option('-C', '--config', action='store', 
                help='Configuration file')
        self.parser.add_option('-k', '--kickstarts', action='store_true', 
                help='Sync all kickstart trees for channels specified')
        self.parser.add_option('-K', '--skippackages', action='store_true', 
                help='Skip sync of packages', default=False)
        self.parser.add_option('-L', '--listchannels', action='store_true', 
                help='List all channels we have access to synchronize')
        self.parser.add_option('-p', '--password', action='store',
                help='RHN Password')
        self.parser.add_option('-P', '--parallel', action='store',
                help='Number of threads to fetch in parallel.')
        self.parser.add_option('-r', '--removeold', action='store_true', 
                help='Remove older rpms')
        self.parser.add_option('-s', '--systemid', action='store', help='System ID')
        self.parser.add_option('-u', '--username', action='store', help='RHN User Account')
        self.parser.add_option('-U', '--url', action='store', help='Red Hat Server URL')
        self.parser.add_option("--limit", dest="limit",
                          help="Limit bandwidth in KB/sec", default=None)
コード例 #5
0
ファイル: GrinderCLI.py プロジェクト: dhajoshi/grinder
class RHNDriver(CliDriver):
    def __init__(self):
        usage = "usage: %prog rhn [OPTIONS]"
        shortdesc = "Fetches content from a rhn source."
        desc = "rhn"
        CliDriver.__init__(self, "rhn", usage, shortdesc, desc)
        #GrinderLog.setup(self.debug)
        self.rhnSync = RHNSync()

        self.parser.add_option('-a', '--all', action='store_true', 
                help='Fetch ALL packages from a channel, not just latest')
        self.parser.add_option('-b', '--basepath', action='store', 
                help='Path RPMs are stored')
        self.parser.add_option('-c', '--certfile', action='store', 
                help='Entitlement Certificate')
        self.parser.add_option('-C', '--config', action='store', 
                help='Configuration file')
        self.parser.add_option('-k', '--kickstarts', action='store_true', 
                help='Sync all kickstart trees for channels specified')
        self.parser.add_option('-K', '--skippackages', action='store_true', 
                help='Skip sync of packages', default=False)
        self.parser.add_option('-L', '--listchannels', action='store_true', 
                help='List all channels we have access to synchronize')
        self.parser.add_option('-p', '--password', action='store',
                help='RHN Password')
        self.parser.add_option('-P', '--parallel', action='store',
                help='Number of threads to fetch in parallel.')
        self.parser.add_option('-r', '--removeold', action='store_true', 
                help='Remove older rpms')
        self.parser.add_option('-s', '--systemid', action='store', help='System ID')
        self.parser.add_option('-u', '--username', action='store', help='RHN User Account')
        self.parser.add_option('-U', '--url', action='store', help='Red Hat Server URL')
        self.parser.add_option("--limit", dest="limit",
                          help="Limit bandwidth in KB/sec", default=None)

    def _validate_options(self):
        if self.options.all and self.options.removeold:
            systemExit(1, "Conflicting options specified 'all' and 'removeold'.")
        if self.options.config:
            if not self.rhnSync.loadConfig(self.options.config):
                systemExit(1, "Unable to parse config file: %s" % (self.options.config))
        if self.options.all:
            self.rhnSync.setFetchAllPackages(self.options.all)
            self.rhnSync.setRemoveOldPackages(False)
        if self.options.basepath:
            self.rhnSync.setBasePath(self.options.basepath)
        if self.options.url:
            self.rhnSync.setURL(self.options.url)
        if self.options.username:
            self.rhnSync.setUsername(self.options.username)
        if self.options.password:
            self.rhnSync.setPassword(self.options.password)
        if self.options.certfile:
            cert = open(self.options.certfile, 'r').read()
            self.rhnSync.setCert(cert)
        if self.options.systemid:
            sysid = open(self.options.systemid, 'r').read()
            self.rhnSync.setSystemId(sysid)
        if self.options.parallel:
            self.rhnSync.setParallel(self.options.parallel)
        if self.options.debug:
            self.rhnSync.setVerbose(self.options.debug)
        if self.options.removeold:
            self.rhnSync.setRemoveOldPackages(self.options.removeold)
            self.rhnSync.setFetchAllPackages(False)

    def _do_command(self):
        """
        Executes the command.
        """
        self._validate_options()
        try:
            self.rhnSync.activate()
        except SystemNotActivatedException, e:
            LOG.debug("%s" % (traceback.format_exc()))
            systemExit(1, "System is not activated. Please pass in a valid username/password")
        except CantActivateException, e:
            LOG.debug("%s" % (traceback.format_exc()))
            systemExit(1, "Unable to activate system.")
コード例 #6
0
ファイル: GrinderCLI.py プロジェクト: pombredanne/grinder-1
    def __init__(self):
        usage = "usage: %prog rhn [OPTIONS]"
        shortdesc = "Fetches content from a rhn source."
        desc = "rhn"
        CliDriver.__init__(self, "rhn", usage, shortdesc, desc)
        #GrinderLog.setup(self.debug)
        self.rhnSync = RHNSync()

        self.parser.add_option(
            '-a',
            '--all',
            action='store_true',
            help='Fetch ALL packages from a channel, not just latest')
        self.parser.add_option('-b',
                               '--basepath',
                               action='store',
                               help='Path RPMs are stored')
        self.parser.add_option('-c',
                               '--certfile',
                               action='store',
                               help='Entitlement Certificate')
        self.parser.add_option('-C',
                               '--config',
                               action='store',
                               help='Configuration file')
        self.parser.add_option(
            '-k',
            '--kickstarts',
            action='store_true',
            help='Sync all kickstart trees for channels specified')
        self.parser.add_option('-K',
                               '--skippackages',
                               action='store_true',
                               help='Skip sync of packages',
                               default=False)
        self.parser.add_option(
            '-L',
            '--listchannels',
            action='store_true',
            help='List all channels we have access to synchronize')
        self.parser.add_option('-p',
                               '--password',
                               action='store',
                               help='RHN Password')
        self.parser.add_option('-P',
                               '--parallel',
                               action='store',
                               help='Number of threads to fetch in parallel.')
        self.parser.add_option('-r',
                               '--removeold',
                               action='store_true',
                               help='Remove older rpms')
        self.parser.add_option('-s',
                               '--systemid',
                               action='store',
                               help='System ID')
        self.parser.add_option('-u',
                               '--username',
                               action='store',
                               help='RHN User Account')
        self.parser.add_option('-U',
                               '--url',
                               action='store',
                               help='Red Hat Server URL')
        self.parser.add_option("--limit",
                               dest="limit",
                               help="Limit bandwidth in KB/sec",
                               default=None)
コード例 #7
0
ファイル: GrinderCLI.py プロジェクト: pombredanne/grinder-1
class RHNDriver(CliDriver):
    def __init__(self):
        usage = "usage: %prog rhn [OPTIONS]"
        shortdesc = "Fetches content from a rhn source."
        desc = "rhn"
        CliDriver.__init__(self, "rhn", usage, shortdesc, desc)
        #GrinderLog.setup(self.debug)
        self.rhnSync = RHNSync()

        self.parser.add_option(
            '-a',
            '--all',
            action='store_true',
            help='Fetch ALL packages from a channel, not just latest')
        self.parser.add_option('-b',
                               '--basepath',
                               action='store',
                               help='Path RPMs are stored')
        self.parser.add_option('-c',
                               '--certfile',
                               action='store',
                               help='Entitlement Certificate')
        self.parser.add_option('-C',
                               '--config',
                               action='store',
                               help='Configuration file')
        self.parser.add_option(
            '-k',
            '--kickstarts',
            action='store_true',
            help='Sync all kickstart trees for channels specified')
        self.parser.add_option('-K',
                               '--skippackages',
                               action='store_true',
                               help='Skip sync of packages',
                               default=False)
        self.parser.add_option(
            '-L',
            '--listchannels',
            action='store_true',
            help='List all channels we have access to synchronize')
        self.parser.add_option('-p',
                               '--password',
                               action='store',
                               help='RHN Password')
        self.parser.add_option('-P',
                               '--parallel',
                               action='store',
                               help='Number of threads to fetch in parallel.')
        self.parser.add_option('-r',
                               '--removeold',
                               action='store_true',
                               help='Remove older rpms')
        self.parser.add_option('-s',
                               '--systemid',
                               action='store',
                               help='System ID')
        self.parser.add_option('-u',
                               '--username',
                               action='store',
                               help='RHN User Account')
        self.parser.add_option('-U',
                               '--url',
                               action='store',
                               help='Red Hat Server URL')
        self.parser.add_option("--limit",
                               dest="limit",
                               help="Limit bandwidth in KB/sec",
                               default=None)

    def _validate_options(self):
        if self.options.all and self.options.removeold:
            systemExit(1,
                       "Conflicting options specified 'all' and 'removeold'.")
        if self.options.config:
            if not self.rhnSync.loadConfig(self.options.config):
                systemExit(
                    1,
                    "Unable to parse config file: %s" % (self.options.config))
        if self.options.all:
            self.rhnSync.setFetchAllPackages(self.options.all)
            self.rhnSync.setRemoveOldPackages(False)
        if self.options.basepath:
            self.rhnSync.setBasePath(self.options.basepath)
        if self.options.url:
            self.rhnSync.setURL(self.options.url)
        if self.options.username:
            self.rhnSync.setUsername(self.options.username)
        if self.options.password:
            self.rhnSync.setPassword(self.options.password)
        if self.options.certfile:
            cert = open(self.options.certfile, 'r').read()
            self.rhnSync.setCert(cert)
        if self.options.systemid:
            sysid = open(self.options.systemid, 'r').read()
            self.rhnSync.setSystemId(sysid)
        if self.options.parallel:
            self.rhnSync.setParallel(self.options.parallel)
        if self.options.debug:
            self.rhnSync.setVerbose(self.options.debug)
        if self.options.removeold:
            self.rhnSync.setRemoveOldPackages(self.options.removeold)
            self.rhnSync.setFetchAllPackages(False)

    def _do_command(self):
        """
        Executes the command.
        """
        self._validate_options()
        try:
            self.rhnSync.activate()
        except SystemNotActivatedException, e:
            LOG.debug("%s" % (traceback.format_exc()))
            systemExit(
                1,
                "System is not activated. Please pass in a valid username/password"
            )
        except CantActivateException, e:
            LOG.debug("%s" % (traceback.format_exc()))
            systemExit(1, "Unable to activate system.")