def updateHardware(): s = rpcServer.getServer() hardwareList = hardware.Hardware() s.registration.refresh_hw_profile(up2dateAuth.getSystemId(), hardwareList)
def login(systemId=None): server = rpcServer.getServer() log = up2dateLog.initLog() # send up the capabality info headerlist = clientCaps.caps.headerFormat() for (headerName, value) in headerlist: server.add_header(headerName, value) if systemId == None: systemId = getSystemId() if not systemId: return None maybeUpdateVersion() log.log_me("logging into up2date server") # the list of caps the client needs caps = capabilities.Capabilities() global loginInfo try: li = rpcServer.doCall(server.up2date.login, systemId) except rpclib.Fault, f: if abs(f.faultCode) == 49: # print f.faultString raise up2dateErrors.AbuseError(f.faultString) else: raise f
def login(systemId=None): server = rpcServer.getServer() log = rhnLog.initLog() # send up the capabality info headerlist = clientCaps.caps.headerFormat() for (headerName, value) in headerlist: server.add_header(headerName, value) if systemId == None: systemId = getSystemId() if not systemId: return None maybeUpdateVersion() log.log_me("logging into up2date server") # the list of caps the client needs caps = capabilities.Capabilities() global loginInfo, loginTime, loginOffset try: loginInfo = rpcServer.doCall(server.up2date.login, systemId) loginTime = time.time() loginOffset = float(loginInfo['X-RHN-Auth-Expire-Offset']) - 60.0 except xmlrpclib.Fault, f: if abs(f.faultCode) == 49: # print f.faultString raise rhnErrors.AbuseError(f.faultString) else: raise f
def getChannelDetails(): channels = [] sourceChannels = getChannels() useRhn = None for sourceChannel in sourceChannels.channels(): if sourceChannel["type"] == "up2date": useRhn = 1 if useRhn: s = rpcServer.getServer() up2dateChannels = rpcServer.doCall(s.up2date.listChannels, up2dateAuth.getSystemId()) for sourceChannel in sourceChannels.channels(): if sourceChannel["type"] != "up2date": # FIMXE: kluge since we dont have a good name, maybe be able to fix sourceChannel["name"] = sourceChannel["label"] sourceChannel["description"] = "%s channel %s from %s" % ( sourceChannel["type"], sourceChannel["label"], sourceChannel["url"], ) channels.append(sourceChannel) continue if useRhn: for up2dateChannel in up2dateChannels: if up2dateChannel["label"] != sourceChannel["label"]: continue for key in up2dateChannel.keys(): sourceChannel[key] = up2dateChannel[key] channels.append(sourceChannel) return channels
def getChannelDetails(): channels = [] sourceChannels = getChannels() useRhn = None for sourceChannel in sourceChannels.channels(): if sourceChannel['type'] == "up2date": useRhn = 1 if useRhn: s = rpcServer.getServer() up2dateChannels = rpcServer.doCall(s.up2date.listChannels, up2dateAuth.getSystemId()) for sourceChannel in sourceChannels.channels(): if sourceChannel['type'] != 'up2date': # FIMXE: kluge since we dont have a good name, maybe be able to fix sourceChannel['name'] = sourceChannel['label'] sourceChannel['description'] = "%s channel %s from %s" % ( sourceChannel['type'], sourceChannel['label'], sourceChannel['url']) channels.append(sourceChannel) continue if useRhn: for up2dateChannel in up2dateChannels: if up2dateChannel['label'] != sourceChannel['label']: continue for key in up2dateChannel.keys(): sourceChannel[key] = up2dateChannel[key] channels.append(sourceChannel) return channels
def getAdvisoryInfo(pkg, warningCallback=None): log = up2dateLog.initLog() cfg = config.initUp2dateConfig() # no errata for non rhn use if not cfg['useRhn']: return None s = rpcServer.getServer() ts = transaction.initReadOnlyTransaction() mi = ts.dbMatch('Providename', pkg[0]) if not mi: return None # odd,set h to last value in mi. mi has to be iterated # to get values from it... h = None for h in mi: break info = None # in case of package less errata that somehow apply if h: try: pkgName = "%s-%s-%s" % (h['name'], h['version'], h['release']) log.log_me("getAdvisoryInfo for %s" % pkgName) info = rpcServer.doCall(s.errata.getPackageErratum, up2dateAuth.getSystemId(), pkg) except rpclib.Fault, f: if warningCallback: warningCallback(f.faultString) return None
def subscribeChannels(channels, username, passwd): s = rpcServer.getServer() try: channels = rpcServer.doCall(s.up2date.subscribeChannels, up2dateAuth.getSystemId(), channels, username, passwd) except rpclib.Fault, f: if f.faultCode == -36: raise up2dateErrors.PasswordError(f.faultString) else: raise up2dateErrors.CommunicationError(f.faultString)
def termsAndConditions(): s = rpcServer.getServer() try: return rpcServer.doCall(s.registration.terms_and_conditions) except rpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def privacyText(): s = rpcServer.getServer() try: return rpcServer.doCall(s.registration.privacy_statement) except rpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def welcomeText(): s = rpcServer.getServer() try: return rpcServer.doCall(s.registration.welcome_message) except rpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def updatePackages(systemId, packageList): s = rpcServer.getServer() try: rpcServer.doCall(s.registration.update_packages, systemId, packageList) except xmlrpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def privacyText(): s = rpcServer.getServer() try: return rpcServer.doCall(s.registration.privacy_statement) except xmlrpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def termsAndConditions(): s = rpcServer.getServer() try: return rpcServer.doCall(s.registration.terms_and_conditions) except xmlrpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def welcomeText(): s = rpcServer.getServer() try: return rpcServer.doCall(s.registration.welcome_message) except xmlrpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def getCaps(): s = rpcServer.getServer() try: rpcServer.doCall(s.registration.welcome_message) except xmlrpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise f
def sendHardware(systemId, hardwareList): s = rpcServer.getServer() try: rpcServer.doCall(s.registration.add_hw_profile, systemId, hardwareList) except xmlrpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def listPackages(systemId): s = rpcServer.getServer() try: rpcServer.doCall(s.registration.list_packages,systemId) except rpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def listPackages(systemId): s = rpcServer.getServer() try: rpcServer.doCall(s.registration.list_packages, systemId) except xmlrpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def sendHardware(systemId, hardwareList): s = rpcServer.getServer() try: rpcServer.doCall(s.registration.add_hw_profile, systemId, hardwareList) except rpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def registerProduct(systemId, productInfo): s = rpcServer.getServer() try: rpcServer.doCall(s.registration.register_product, systemId, productInfo) except xmlrpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def getCaps(): s = rpcServer.getServer() try: rpcServer.doCall(s.registration.welcome_message) except rpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise f
def unsubscribeChannels(channels, username, passwd): s = rpcServer.getServer() try: channels = rpcServer.doCall(s.up2date.unsubscribeChannels, up2dateAuth.getSystemId(), channels, username, passwd) except rpclib.Fault, f: if f.faultCode == -36: raise up2dateErrors.PasswordError(f.faultString) else: raise up2dateErrors.CommunicationError(f.faultString)
def registerProduct(systemId, productInfo, oemInfo={}): s = rpcServer.getServer() try: rpcServer.doCall(s.registration.register_product, systemId, productInfo) except rpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def validateRegNum(regNum): s = rpcServer.getServer() try: rpcServer.doCall(s.registration.validate_reg_num,regNum) except rpclib.Fault, f: if f.faultCode == -16: # invalid raise rhnErrors.ValidationError(f.faultString) elif f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def validateRegNum(regNum): s = rpcServer.getServer() try: rpcServer.doCall(s.registration.validate_reg_num, regNum) except xmlrpclib.Fault, f: if f.faultCode == -16: # invalid raise rhnErrors.ValidationError(f.faultString) elif f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def sendSerialNumber(systemId, num): s = rpcServer.getServer() try: if cfg["oemId"] != None: rpcServer.doCall(s.registration.send_serial, systemId, num, cfg["oemId"]) else: rpcServer.doCall(s.registration.send_serial, systemId, num) except rpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def finishMessage(systemId): # ret = (-1, "blippyFoobar", "this is some text\n\n\nmore\n\ntext\\n\nfoo") # return ret s = rpcServer.getServer() try: ret = rpcServer.doCall(s.registration.finish_message, systemId) return ret except rpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def finishMessage(systemId): # ret = (-1, "blippyFoobar", "this is some text\n\n\nmore\n\ntext\\n\nfoo") # return ret s = rpcServer.getServer() try: ret = rpcServer.doCall(s.registration.finish_message, systemId) return ret except xmlrpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def sendSerialNumber(systemId, num): s = rpcServer.getServer() try: if cfg["oemId"] != None: rpcServer.doCall(s.registration.send_serial, systemId, num, cfg["oemId"]) else: rpcServer.doCall(s.registration.send_serial, systemId, num) except xmlrpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def registerUser(username, password, email=None, orgid=None, orgpassword=None): s = rpcServer.getServer() try: if not email == None: if orgid and orgpassword: rpcServer.doCall(s.registration.new_user, username, password, email, orgid, orgpassword) else: rpcServer.doCall(s.registration.new_user, username, password, email) else: rpcServer.doCall(s.registration.new_user, username, password) except xmlrpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def maybeUpdateVersion(): cfg = config.initUp2dateConfig() try: idVer = rpclib.xmlrpclib.loads(getSystemId())[0][0]['os_release'] except: # they may not even have a system id yet. return 0 systemVer = up2dateUtils.getVersion() if idVer != systemVer: s = rpcServer.getServer() try: newSystemId = rpcServer.doCall(s.registration.upgrade_version, getSystemId(), systemVer) except rpclib.Fault, f: raise up2dateErrors.CommunicationError(f.faultString) path = cfg["systemIdPath"] dir = path[:string.rfind(path, "/")] if not os.access(dir, os.W_OK): try: os.mkdir(dir) except: return 0 if not os.access(dir, os.W_OK): return 0 if os.access(path, os.F_OK): # already have systemid file there; let's back it up savePath = path + ".save" try: os.rename(path, savePath) except: return 0 f = open(path, "w") f.write(newSystemId) f.close() try: os.chmod(path, 0600) except: pass
def registerSystem(username=None, password=None, profileName=None, packages=None, token=None, other=None): s = rpcServer.getServer() auth_dict = { "profile_name": profileName, "os_release": rhnUtils.getVersion(), "release_name": rhnUtils.getOSRelease(), "architecture": rhnUtils.getArch() } # dict of other bits to send up if other: for (key, item) in other.items(): auth_dict[key] = item if token: auth_dict["token"] = token else: auth_dict["username"] = username auth_dict["password"] = password auth_dict["uuid"] = cfg["uuid"] or "" auth_dict["rhnuuid"] = cfg["rhnuuid"] or "" try: if packages == None: ret = rpcServer.doCall(s.registration.new_system, auth_dict) else: ret = rpcServer.doCall(s.registration.new_system, auth_dict, packages) except xmlrpclib.Fault, f: if abs(f.faultCode) == 99: raise rhnErrors.DelayError(f.faultString) elif abs(f.faultCode) == 60: raise rhnErrors.AuthenticationTicketError(f.faultString) elif abs(f.faultCode) == 105: raise rhnErrors.RhnUuidUniquenessError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def reserveUser(username, password): s = rpcServer.getServer() try: ret = rpcServer.doCall(s.registration.reserve_user, username, password) except rpclib.Fault, f: if f.faultCode == -3: # account already in use raise rhnErrors.ValidationError(f.faultString) elif f.faultCode == -14: # too short password raise rhnErrors.ValidationError(f.faultString) elif f.faultCode == -15: # bad chars in username raise rhnErrors.ValidationError(f.faultString) elif f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def registerSystem(username = None, password = None, profileName = None, packages = None, token = None, other = None): s = rpcServer.getServer() auth_dict = { "profile_name" : profileName, "os_release" : rhnUtils.getVersion(), "release_name" : rhnUtils.getOSRelease(), "architecture" : rhnUtils.getArch() }; # dict of other bits to send up if other: for (key, item) in other.items(): auth_dict[key] = item if token: auth_dict["token"] = token else: auth_dict["username"] = username auth_dict["password"] = password auth_dict["uuid"] = cfg["uuid"] or "" auth_dict["rhnuuid"] = cfg["rhnuuid"] or "" try: if packages == None: ret = rpcServer.doCall(s.registration.new_system, auth_dict) else: ret = rpcServer.doCall(s.registration.new_system, auth_dict, packages) except rpclib.Fault, f: if abs(f.faultCode) == 99: raise rhnErrors.DelayError(f.faultString) elif abs(f.faultCode) == 60: raise rhnErrors.AuthenticationTicketError(f.faultString) elif abs(f.faultCode) == 105: raise rhnErrors.RhnUuidUniquenessError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def reserveUser(username, password): s = rpcServer.getServer() try: ret = rpcServer.doCall(s.registration.reserve_user, username, password) except xmlrpclib.Fault, f: if f.faultCode == -3: # account already in use raise rhnErrors.ValidationError(f.faultString) elif f.faultCode == -14: # too short password raise rhnErrors.ValidationError(f.faultString) elif f.faultCode == -15: # bad chars in username raise rhnErrors.ValidationError(f.faultString) elif f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
def registerUser(username, password, email = None, orgid = None, orgpassword = None): s = rpcServer.getServer() try: if not email == None: if orgid and orgpassword: rpcServer.doCall(s.registration.new_user, username, password, email, orgid, orgpassword) else: rpcServer.doCall(s.registration.new_user, username, password, email) else: rpcServer.doCall(s.registration.new_user, username, password) except rpclib.Fault, f: if f.faultCode == 99: raise rhnErrors.DelayError(f.faultString) else: raise rhnErrors.CommunicationError(f.faultString)
import xmlrpclib import rpcServer import hardware def updateHardware(): registered = rhnAuth.getSystemId() if not registered: print "system not registered" sys.exit(1) try: rhnAuth.updateLoginInfo() except xmlrpclib.Fault, f: faultError(f.faultString) sys.exit(1) except rhnErrors.ServerCapabilityError, e: print e sys.exit(1) except rhnErrors.CommunicationError, e: print e sys.exit(1) #print _("Updating package profile...") s = rpcServer.getServer() hardwareList = hardware.Hardware() s.registration.refresh_hw_profile(registered, hardwareList)
def __init__(self, serverOverride=None, timeout=None): self._server = rpcServer.getServer(serverOverride=serverOverride, timeout=timeout) self._capabilities = None
from rhn import rpclib except ImportError: rpclib = __import__("xmlrpclib") def updateHardware(): registered = rhnAuth.getSystemId() if not registered: print "system not registered" sys.exit(1) try: rhnAuth.updateLoginInfo() except rpclib.Fault, f: faultError(f.faultString) sys.exit(1) except rhnErrors.ServerCapabilityError, e: print e sys.exit(1) except rhnErrors.CommunicationError, e: print e sys.exit(1) #print _("Updating package profile...") s = rpcServer.getServer() hardwareList = hardware.Hardware() s.registration.refresh_hw_profile(registered, hardwareList)
def __init__(self): self._server = rpcServer.getServer() self._capabilities = None