示例#1
0
文件: rhnreg.py 项目: ncounter/uyuni
def getAvailableChannels(username, password):
    s = rhnserver.RhnServer()
    server_arch = up2dateUtils.getArch()
    server_version = up2dateUtils.getVersion()
    server_release = up2dateUtils.getRelease()

    availableChannels = None

    try:
        availableChannels = s.registration.available_eus_channels(
            username, password, server_arch, server_version, server_release)
    except xmlrpclib.Fault, f:
        if f.faultCode == 99:
            raise up2dateErrors.DelayError(
                f.faultString), None, sys.exc_info()[2]
        else:
            raise
示例#2
0
    def __exception_from_fault(self, fault):
        if fault.faultCode == -3:
            # This username is already taken, or the password is incorrect.
            exception = up2dateErrors.AuthenticationOrAccountCreationError(
                fault.faultString)
        elif fault.faultCode == -2:
            # Invalid username and password combination.
            exception = up2dateErrors.AuthenticationOrAccountCreationError(
                fault.faultString)
        elif fault.faultCode == -1:
            exception = up2dateErrors.UnknownMethodException(fault.faultString)
        elif fault.faultCode == -13:
            # Username is too short.
            exception = up2dateErrors.LoginMinLengthError(fault.faultString)
        elif fault.faultCode == -14:
            # too short password
            exception = up2dateErrors.PasswordMinLengthError(fault.faultString)
        elif fault.faultCode == -15:
            # bad chars in username
            exception = up2dateErrors.ValidationError(fault.faultString)
        elif fault.faultCode == -16:
            # Invalid product registration code.
            # TODO Should this really be a validation error?
            exception = up2dateErrors.ValidationError(fault.faultString)
        elif fault.faultCode == -19:
            # invalid
            exception = up2dateErrors.NoBaseChannelError(fault.faultString)
        elif fault.faultCode == -31:
            # No entitlement
            exception = up2dateErrors.InsuffMgmntEntsError(fault.faultString)
        elif fault.faultCode == -36:
            # rhnException.py says this means "Invalid action."
            # TODO find out which is right
            exception = up2dateErrors.PasswordError(fault.faultString)
        elif abs(fault.faultCode) == 49:
            exception = up2dateErrors.AbuseError(fault.faultString)
        elif abs(fault.faultCode) == 60:
            exception = up2dateErrors.AuthenticationTicketError(
                fault.faultString)
        elif abs(fault.faultCode) == 105:
            exception = up2dateErrors.RhnUuidUniquenessError(fault.faultString)
        elif fault.faultCode == 99:
            exception = up2dateErrors.DelayError(fault.faultString)
        elif abs(fault.faultCode) == 91:
            exception = up2dateErrors.InsuffMgmntEntsError(fault.faultString)
        elif fault.faultCode == -106:
            # Invalid username.
            exception = up2dateErrors.ValidationError(fault.faultString)
        elif fault.faultCode == -600:
            # Invalid username.
            exception = up2dateErrors.InvalidRegistrationNumberError(
                fault.faultString)
        elif fault.faultCode == -601:
            # No entitlements associated with given hardware info
            exception = up2dateErrors.NotEntitlingError(fault.faultString)
        elif fault.faultCode == -602:
            # No entitlements associated with reg num
            exception = up2dateErrors.NotEntitlingError(fault.faultString)
        elif fault.faultCode == -2001 or fault.faultCode == -700:
            exception = up2dateErrors.AuthenticationOrAccountCreationError(
                fault.faultString)
        elif fault.faultCode == -701:
            exception = up2dateErrors.PasswordMaxLengthError(fault.faultString)
        elif fault.faultCode == -61:
            exception = up2dateErrors.ActivationKeyUsageLimitError(
                fault.faultString)
        elif fault.faultCode == -5:
            exception = up2dateErrors.UnableToCreateUser(fault.faultString)
        else:
            exception = up2dateErrors.CommunicationError(fault.faultString)

        return exception