Exemplo n.º 1
0
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
Exemplo n.º 2
0
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)
Exemplo n.º 3
0
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)
Exemplo n.º 4
0
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)
Exemplo n.º 5
0
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)
Exemplo n.º 6
0
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)
Exemplo n.º 7
0
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
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
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)
Exemplo n.º 10
0
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)
Exemplo n.º 11
0
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)
Exemplo n.º 12
0
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)
Exemplo n.º 13
0
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)
Exemplo n.º 14
0
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
Exemplo n.º 15
0
    def __call__(self, *args, **kwargs):
        """ Call the method. Catch faults and translate them. """
        method = getattr(self._server, self._method_name)

        try:
            return rpcServer.doCall(method, *args, **kwargs)
        except xmlrpclib.Fault:
            raise (self.__exception_from_fault(sys.exc_info()[1]), None,
                   sys.exc_info()[2])
        except OpenSSL.SSL.Error:
            # TODO This should probably be moved to rhnlib and raise an
            # exception that subclasses OpenSSL.SSL.Error
            # TODO Is there a better way to detect cert failures?
            error = str(sys.exc_info()[1])
            error = error.strip("[()]")
            pieces = error.split(',')
            message = ""
            if len(pieces) > 2:
                message = pieces[2]
            elif len(pieces) == 2:
                message = pieces[1]
            message = message.strip(" '")
            if message == 'certificate verify failed':
                raise (up2dateErrors.SSLCertificateVerifyFailedError(), None,
                       sys.exc_info()[2])
            else:
                raise (up2dateErrors.NetworkError(message), None,
                       sys.exc_info()[2])
Exemplo n.º 16
0
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
Exemplo n.º 17
0
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
Exemplo n.º 18
0
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
Exemplo n.º 19
0
    def __call__(self, *args, **kwargs):
        """ Call the method. Catch faults and translate them. """
        method = getattr(self._server, self._method_name)

        try:
            return rpcServer.doCall(method, *args, **kwargs)
        except xmlrpclib.Fault:
            raise (self.__exception_from_fault(sys.exc_info()[1]), None, sys.exc_info()[2])
        except OpenSSL.SSL.Error:
            # TODO This should probably be moved to rhnlib and raise an
            # exception that subclasses OpenSSL.SSL.Error
            # TODO Is there a better way to detect cert failures?
            error = str(sys.exc_info()[1])
            error = error.strip("[()]")
            pieces = error.split(',')
            message = ""
            if len(pieces) > 2:
                message = pieces[2]
            elif len(pieces) == 2:
                message = pieces[1]
            message = message.strip(" '")
            if message == 'certificate verify failed':
                raise (up2dateErrors.SSLCertificateVerifyFailedError(), None, sys.exc_info()[2])
            else:
                raise (up2dateErrors.NetworkError(message), None, sys.exc_info()[2])
Exemplo n.º 20
0
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
Exemplo n.º 21
0
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
Exemplo n.º 22
0
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
Exemplo n.º 23
0
    def __call__(self, *args, **kwargs):
        """ Call the method. Catch faults and translate them. """
        method = getattr(self._server, self._method_name)

        try:
            return rpcServer.doCall(method, *args, **kwargs)
        except xmlrpclib.Fault, f:
            raise self.__exception_from_fault(f), None, sys.exc_info()[2]
Exemplo n.º 24
0
 def __verifyTokens(self, rd):
     import rhnChannel
     import rpcServer
     channels = rhnChannel.getChannels()
     channel = channels.channels()[0]
     # if this doesn't throw an auth traceback, the auth doesnt work
     p, t = rpcServer.doCall(rd.listPackages, channel,
                             msgCallback=None, progressCallback=None)
Exemplo n.º 25
0
    def __call__(self, *args, **kwargs):
        """ Call the method. Catch faults and translate them. """
        method = getattr(self._server, self._method_name)

        try:
            return rpcServer.doCall(method, *args, **kwargs)
        except xmlrpclib.Fault, f:
            raise self.__exception_from_fault(f), None, sys.exc_info()[2]
Exemplo n.º 26
0
 def __verifyTokens(self, rd):
     import rhnChannel
     import rpcServer
     channels = rhnChannel.getChannels()
     channel = channels.channels()[0]
     # if this doesn't throw an auth traceback, the auth doesnt work
     p, t = rpcServer.doCall(rd.listPackages, channel,
                             msgCallback=None, progressCallback=None)
Exemplo n.º 27
0
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)
Exemplo n.º 28
0
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)
Exemplo n.º 29
0
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)
Exemplo n.º 30
0
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)
Exemplo n.º 31
0
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)
Exemplo n.º 32
0
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)
Exemplo n.º 33
0
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)
Exemplo n.º 34
0
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)
Exemplo n.º 35
0
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)
Exemplo n.º 36
0
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)
Exemplo n.º 37
0
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)
Exemplo n.º 38
0
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)
Exemplo n.º 39
0
def downloadPackage(channel, pkghash, localfile, serverUrl=None):
    cfg = config.initUp2dateConfig()

    serverSettings = ServerSettings()
    if serverUrl is not None:
        serverSettings.httpServerUrl = serverUrl
    li = rhnAuth.getLoginInfo()
    s = getGETServer(li, serverSettings)

    fd = rpcServer.doCall(s.getPackage, channel, pkghash)
    status = s.get_response_status()

    f2 = _readFD(fd, localfile)
    f2.close()
    fd.close()
Exemplo n.º 40
0
def downloadPackage(channel, pkghash, localfile, serverUrl=None):
    cfg = config.initUp2dateConfig()

    serverSettings = ServerSettings()
    if serverUrl is not None:
        serverSettings.httpServerUrl = serverUrl
    li = rhnAuth.getLoginInfo()
    s = getGETServer(li, serverSettings)

    fd = rpcServer.doCall(s.getPackage, channel, pkghash)
    status = s.get_response_status()

    f2 = _readFD(fd, localfile)
    f2.close()
    fd.close()
Exemplo n.º 41
0
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
Exemplo n.º 42
0
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
Exemplo n.º 43
0
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)
Exemplo n.º 44
0
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)
Exemplo n.º 45
0
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)
Exemplo n.º 46
0
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
Exemplo n.º 47
0
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)
Exemplo n.º 48
0
    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

    if info:
        return info

    try:
        log.log_me("getAdvisoryInfo for %s-0-0" % pkg[0])
        info = rpcServer.doCall(s.errata.GetByPackage, "%s-0-0" % pkg[0],
                                up2dateUtils.getVersion())
    except rpclib.Fault, f:
        if warningCallback:
            warningCallback(f.faultString)
        return None

    return info
Exemplo n.º 49
0
    # 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
    
    if info:
        return info
    
    try:
        log.log_me("getAdvisoryInfo for %s-0-0" % pkg[0])
        info = rpcServer.doCall(s.errata.GetByPackage,
                      "%s-0-0" % pkg[0],
                      up2dateUtils.getVersion())
    except rpclib.Fault, f:
        if warningCallback:
            warningCallback(f.faultString)
        return None
    
    return info