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')
def __init__(self): usage = "usage: %prog yum [OPTIONS]" shortdesc = "Fetches content from a yum repo." desc = "yum" CliDriver.__init__(self, "yum", usage, shortdesc, desc) GrinderLog.setup(self.debug) self.parser.add_option("--label", dest="label", help="Repo label") self.parser.add_option("--url", dest="url", help="Repo URL to fetch the content bits.") self.parser.add_option("--cacert", dest="cacert", help="Path location to CA Certificate.") self.parser.add_option("--clicert", dest="clicert", help="Path location to Client SSl Certificate.") self.parser.add_option("--clikey", dest="clikey", help="Path location to Client Certificate Key.") self.parser.add_option("--parallel", dest="parallel", help="Thread count to fetch the bits in parallel. Defaults to 5") self.parser.add_option("--dir", dest="dir", help="Directory path to store the fetched content. Defaults to Current working Directory")
fileName = itemInfo['filename'] fetchName = itemInfo['fetch_name'] itemSize = itemInfo['package_size'] md5sum = itemInfo['md5sum'] hashType = itemInfo['hashtype'] fetchURL = self.getFetchURL(self.channelLabel, fetchName) status = self.fetch(fileName, fetchURL, itemSize, hashType, md5sum, self.savePath, headers=authMap) if status == BaseFetch.STATUS_UNAUTHORIZED: LOG.warn("Unauthorized request from fetch(). Will attempt to update authentication credentials and retry") authMap = self.login(refresh=True) return self.fetch(fileName, fetchURL, itemSize, md5sum, self.savePath, headers=authMap) return status if __name__ == "__main__": import GrinderLog GrinderLog.setup(True) systemId = open("/etc/sysconfig/rhn/systemid").read() baseURL = "http://satellite.rhn.redhat.com" channelLabel = "rhel-i386-server-vt-5" savePath = "./test123" pf = PackageFetch(systemId, baseURL, channelLabel, savePath) pkg = {} pkg['nevra'] = "Virtualization-es-ES-5.2-9.noarch.rpm" pkg['fetch_name'] = "Virtualization-es-ES-5.2-9:.noarch.rpm" pkg['package_size'] = "1731195" pkg['md5sum'] = "91b0f20aeeda88ddae4959797003a173" pkg['hashtype'] = 'md5' pkg['filename'] = "Virtualization-es-ES-5.2-9.noarch.rpm" status = pf.fetchItem(pkg) print "Package fetch status is %s" % (status)