def doRESOLVEURL(self, headers, body): spacewalk_auth_headers = ['X-RHN-Server-Id', 'X-RHN-Auth-User-Id', 'X-RHN-Auth', 'X-RHN-Auth-Server-Time', 'X-RHN-Auth-Expire-Offset'] if not os.geteuid() == 0: # you can't access auth data if you are not root self.answer("ERROR", {}, "Can't access managed repositores without root access") return if not headers.has_key('channel'): self.answer("ERROR", {}, "Missing argument channel") return if headers.has_key('server'): server = int(headers['server']) else: server = 0 # do we have spacewalk-client-tools with timeout option? args = getargspec(rhnChannel.getChannelDetails)[0] timeout = self._getTimeout() if 'timeout' in args: details = rhnChannel.getChannelDetails(timeout=timeout) else: details = rhnChannel.getChannelDetails(); self.channel = None for channel in details: if channel['label'] == headers['channel']: self.channel = channel if not self.channel: self.answer("ERROR", {}, "Can't retrieve information for channel %s" % headers['channel']) return self.auth_headers = {} if 'timeout' in args: login_info = up2dateAuth.getLoginInfo(timeout=timeout) else: login_info = up2dateAuth.getLoginInfo() for k,v in login_info.items(): if k in spacewalk_auth_headers: self.auth_headers[k] = v #self.answer("META", li) # url is a list, use the one provided by the given server if type(self.channel['url']) == type([]): self.channel['url'] = self.channel['url'][server] timeoutstr = "" if timeout: timeoutstr = "&timeout=%d" % timeout url = "%s/GET-REQ/%s?head_requests=no%s" % (self.channel['url'], self.channel['label'], timeoutstr) self.answer("RESOLVEDURL", self.auth_headers, url)
def doRESOLVEURL(self, headers, body): spacewalk_auth_headers = ['X-RHN-Server-Id', 'X-RHN-Auth-User-Id', 'X-RHN-Auth', 'X-RHN-Auth-Server-Time', 'X-RHN-Auth-Expire-Offset'] if not os.geteuid() == 0: # you can't access auth data if you are not root self.answer("ERROR", {}, "Can't access managed repositores without root access") return if not headers.has_key('channel'): self.answer("ERROR", {}, "Missing argument channel") return # do we have spacewalk-client-tools with timeout option? args = getargspec(rhnChannel.getChannelDetails)[0] timeout = self._getTimeout() if 'timeout' in args: details = rhnChannel.getChannelDetails(timeout=timeout) else: details = rhnChannel.getChannelDetails(); self.channel = None for channel in details: if channel['label'] == headers['channel']: self.channel = channel if not self.channel: self.answer("ERROR", {}, "Can't retrieve information for channel %s" % headers['channel']) return self.auth_headers = {} if 'timeout' in args: login_info = up2dateAuth.getLoginInfo(timeout=timeout) else: login_info = up2dateAuth.getLoginInfo() for k,v in login_info.items(): if k in spacewalk_auth_headers: self.auth_headers[k] = v #self.answer("META", li) # url might be a list type, we use the 1st one if type(self.channel['url']) == type([]): self.channel['url'] = self.channel['url'][0] timeoutstr = "" if timeout: timeoutstr = "&timeout=%d" % timeout url = "%s/GET-REQ/%s?head_requests=no%s" % (self.channel['url'], self.channel['label'], timeoutstr) self.answer("RESOLVEDURL", self.auth_headers, url)
def __setupRhnHttpHeaders(self): """ Set up self.http_headers with needed RHN X-RHN-blah headers """ try: li = up2dateAuth.getLoginInfo() except up2dateErrors.RhnServerException, e: raise yum.Errors.RepoError(str(e))
def __init__(self, config, source, buildroot='', nc=None): JointDB.__init__(self, config, source, buildroot) self.comps = None self.reponame = "rhnrepo" if not use_rhn: return up2date_cfg = rhnconfig.initUp2dateConfig() try: login_info = up2dateAuth.getLoginInfo() except up2dateErrors.RhnServerException, e: raise IOError, "Failed to get login info from RHN Server."
def subscribedChannels(): ret = [] debugprint(ret) li = up2dateAuth.getLoginInfo() if not li: return [] channels = li.get('X-RHN-Auth-Channels') if not channels: return [] for label, version, t, t in channels: ret.append(rhnChannel.rhnChannel(label = label, version = version, type = 'up2date', url = cfg['serverURL'])) return ret
def subscribedChannels(): ret = [] debugprint(ret) li = up2dateAuth.getLoginInfo() if not li: return [] channels = li.get('X-RHN-Auth-Channels') if not channels: return [] for label, version, t, t in channels: ret.append( rhnChannel.rhnChannel(label=label, version=version, type='up2date', url=cfg['serverURL'])) return ret
def __init__(self): self.login = None genericRepo.GenericRepo.__init__(self) self.cfg = config.initUp2dateConfig() li = up2dateAuth.getLoginInfo() serverSettings = ServerSettings() self.httpServer = getGETServer(li, serverSettings) localHeaderCache = rpmSource.HeaderCache() self.gds = HttpGetSource(self.httpServer, None) self.hds = rpmSource.DiskCache() self.lds = rpmSource.LocalDisk() self.hcs = rpmSource.HeaderMemoryCache(cacheObject = localHeaderCache) # localHeaderCache = rpmSource.HeaderCache() self.psc.headerCache = localHeaderCache # header needs to be a shared object between several # different classes and isntances, so it's a bit weird. # should maybe reimplement it as class level storage # bits and shared onjects... self.sources = {'listPackages':[{'name':'diskcache', 'object':self.hds}, {'name':'get', 'object':self.gds}], 'listAllPackages':[{'name':'diskcache', 'object':self.hds}, {'name':'get', 'object':self.gds}], 'getObsoletes':[{'name':'diskcache', 'object':self.hds}, {'name':'get', 'object':self.gds}], 'getPackage':[{'name':'localdisk','object':self.lds}, {'name':'diskcache', 'object':self.hds}, {'name':'get', 'object': self.gds}, ], 'getHeader':[{'name':'memcache', 'object': self.hcs}, {'name':'diskcache', 'object':self.hds}, {'name':'localdisk', 'object':self.hds}, {'name':'get', 'object': self.gds} ], 'getPackageSource':[{'name':'localdisk','object':self.lds}, {'name':'diskcache', 'object':self.hds}, {'name':'get', 'object': self.gds}, ], }
def main(self): """RhnCli (the base class) just sets stuff up and then calls this to run the rest of the program. """ ui = self._get_ui() ui.main() # Check to see if the registration worked. try: if not up2dateAuth.getLoginInfo(): if not self._testRhnLogin(): sys.exit(1) except up2dateErrors.RhnServerException: sys.exit(1) # Assuming registration worked, remember to save info (proxy setup,etc) # from rhncli self.saveConfig() sys.exit(0)
def doRESOLVEURL(self, headers, body): spacewalk_auth_headers = ['X-RHN-Server-Id', 'X-RHN-Auth-User-Id', 'X-RHN-Auth', 'X-RHN-Auth-Server-Time', 'X-RHN-Auth-Expire-Offset'] if not os.geteuid() == 0: # you can't access auth data if you are not root self.answer("ERROR", {}, "Can't access managed repositores without root access") return if not headers.has_key('channel'): self.answer("ERROR", {}, "Missing argument channel") return details = rhnChannel.getChannelDetails(); self.channel = None for channel in details: if channel['label'] == headers['channel']: self.channel = channel if not self.channel: self.answer("ERROR", {}, "Can't retrieve information for channel %s" % headers['channel']) return self.auth_headers = {} login_info = up2dateAuth.getLoginInfo() for k,v in login_info.items(): if k in spacewalk_auth_headers: self.auth_headers[k] = v #self.answer("META", li) # url might be a list type, we use the 1st one if type(self.channel['url']) == type([]): self.channel['url'] = self.channel['url'][0] url = "%s/GET-REQ/%s?head_requests=no" % (self.channel['url'], self.channel['label']) self.answer("RESOLVEDURL", self.auth_headers, url)
def __init__(self): self.login = None genericRepo.GenericRepo.__init__(self) self.cfg = config.initUp2dateConfig() li = up2dateAuth.getLoginInfo() serverSettings = ServerSettings() self.httpServer = getGETServer(li, serverSettings) localHeaderCache = rpmSource.HeaderCache() self.gds = HttpGetSource(self.httpServer, None) self.hds = rpmSource.DiskCache() self.lds = rpmSource.LocalDisk() self.hcs = rpmSource.HeaderMemoryCache(cacheObject=localHeaderCache) # localHeaderCache = rpmSource.HeaderCache() self.psc.headerCache = localHeaderCache # header needs to be a shared object between several # different classes and isntances, so it's a bit weird. # should maybe reimplement it as class level storage # bits and shared onjects... self.sources = { 'listPackages': [{ 'name': 'diskcache', 'object': self.hds }, { 'name': 'get', 'object': self.gds }], 'listAllPackages': [{ 'name': 'diskcache', 'object': self.hds }, { 'name': 'get', 'object': self.gds }], 'getObsoletes': [{ 'name': 'diskcache', 'object': self.hds }, { 'name': 'get', 'object': self.gds }], 'getPackage': [ { 'name': 'localdisk', 'object': self.lds }, { 'name': 'diskcache', 'object': self.hds }, { 'name': 'get', 'object': self.gds }, ], 'getHeader': [{ 'name': 'memcache', 'object': self.hcs }, { 'name': 'diskcache', 'object': self.hds }, { 'name': 'localdisk', 'object': self.hds }, { 'name': 'get', 'object': self.gds }], 'getPackageSource': [ { 'name': 'localdisk', 'object': self.lds }, { 'name': 'diskcache', 'object': self.hds }, { 'name': 'get', 'object': self.gds }, ], }
debugprint(rhnChannel.getChannels(force=1)) debugprint(rhnChannel.getChannels(force=1).list) for channel in rhnChannel.rhnChannelList().list: print channel['label'], print for channel in rhnChannel.getChannels(force=1).list: print channel['label'], print for channel in repos.channels.list: print channel['label'], print for channel in subscribedChannels(): print channel['label'], print #sys.exit(0) debugprint(up2dateAuth.getLoginInfo()) for channel in subscribedChannels(): cfg['storageDir'] = '/var/yam/rhel4as-i386/'+channel['label'] try: os.makedirs(cfg['storageDir'], 0755) except: pass print channel['label'], channel['type'], channel['url'], channel['version'] package_list, type = rpcServer.doCall(repos.listPackages, channel, None, None) print channel['label'], 'has', len(package_list), 'packages' # for name, version, release, test, arch, test, label in package_list: # print name, # for pkg in package_list: # name, version, release, test, arch, test, label = pkg # rpcServer.doCall(repos.getPackage, pkg) # rpcServer.doCall(repos.getPackage, pkg, wrapperUtils.printPkg, wrapperUtils.printRetrieveHash)
print for channel in rhnChannel.getChannels(force=1).list: print channel['label'], print for channel in repos.channels.list: print channel['label'], print for channel in subscribedChannels(): print channel['label'], print #sys.exit(0) debugprint(up2dateAuth.getLoginInfo()) for channel in subscribedChannels(): cfg['storageDir'] = '/var/yam/rhel4as-i386/' + channel['label'] try: os.makedirs(cfg['storageDir'], 0755) except: pass print channel['label'], channel['type'], channel['url'], channel['version'] package_list, type = rpcServer.doCall(repos.listPackages, channel, None, None) print channel['label'], 'has', len(package_list), 'packages' # for name, version, release, test, arch, test, label in package_list: # print name, # for pkg in package_list: # name, version, release, test, arch, test, label = pkg