def getGETServer(logininfo, serverSettings): server = rpclib.GETServer(serverSettings.httpServerUrl, proxy=serverSettings.proxyUrl, username=serverSettings.proxyUser, password=serverSettings.proxyPassword, headers=logininfo) server.add_header("X-Up2date-Version", rhnUtils.version()) return server
def _listPackages(self): """ Generates a list of objects by calling the function """ server = rpclib.GETServer(self.rhnParentXMLRPC, proxy=self.httpProxy, username=self.httpProxyUsername, password=self.httpProxyPassword, headers=self.clientInfo) if self.caChain: server.add_trusted_cert(self.caChain) return server.listAllPackagesChecksum(self.channelName, self.channelVersion)
def __channelPackageMapping(self): """ fetch package list on behalf of the client """ log_debug(6, self.rhnParentXMLRPC, self.httpProxy, self.httpProxyUsername, self.httpProxyPassword) log_debug(6, self.clientInfo) server = rpclib.GETServer(self.rhnParentXMLRPC, proxy=self.httpProxy, username=self.httpProxyUsername, password=self.httpProxyPassword, headers=self.clientInfo) if self.caChain: server.add_trusted_cert(self.caChain) packageList = listPackages(server, self.channelName, self.channelVersion) # Hash the list _hash = {} for package in packageList: arch = package[4] extension = "rpm" if isSolarisArch(arch): extension = "pkg" filename = "%s-%s-%s.%s.%s" % (package[0], package[1], package[2], package[4], extension) # if the package contains checksum info if len(package) > 6: filePaths = computePackagePaths(package, source=0, prepend=PREFIX, checksum=package[7]) else: filePaths = computePackagePaths(package, source=0, prepend=PREFIX) _hash[filename] = filePaths if CFG.DEBUG > 4: log_debug( 5, "Mapping: %s[...snip snip...]%s" % (str(_hash)[:40], str(_hash)[-40:])) return cPickle.dumps(_hash, 1)
#!/usr/bin/python # # Tests the encodings in Input and Output objects # import sys sys.path.append('..') from rhn import rpclib gs = rpclib.GETServer("http://coyote.devel.redhat.com/DOWNLOAD") gs.set_transport_flags(allow_partial_content=1) fd = gs.a.b('a', 'b', 'c', offset=9, amount=1) #fd = gs.a.b('a', 'b', 'c') print fd.read() print gs.get_response_headers() print "Status", gs.get_response_status() print "Reason", gs.get_response_reason() print gs.get_content_range()
sys.path.append('..') from rhn import rpclib if len(sys.argv) > 1: system_id_file = sys.argv[1] else: system_id_file = '/etc/sysconfig/rhn/systemid' systemid = open(system_id_file).read() #server_url = "http://coyote.devel.redhat.com/XMLRPC" server_url = "http://xmlrpc.rhn.webdev.redhat.com/XMLRPC" s = rpclib.Server(server_url) cookie = s.up2date.login(systemid) gs = rpclib.GETServer(server_url, headers=cookie) gs.set_transport_flags(allow_partial_content=1) channel_name, channel_version = cookie['X-RHN-Auth-Channels'][0][:2] package_list = gs.listPackages(channel_name, channel_version) for p in package_list: if p[0] == 'python': break pn, pv, pr, pe, pa = p[:5] package_name = "%s-%s-%s.%s.rpm" % (pn, pv, pr, pa) fd = gs.getPackage(channel_name, package_name, offset=1023) #, amount=10)