예제 #1
0
 def __query_future_actions(self, time_window):
     try:
         actions = self.server.queue.get_future_actions(
             up2dateAuth.getSystemId(), time_window)
         return actions
     except xmlrpclib.Fault:
         f = sys.exc_info()[1]
         if f.faultCode == -31:
             raise_with_tb(up2dateErrors.InsuffMgmntEntsError(
                 f.faultString))
         else:
             print("Could not retrieve action item from server %s" %
                   self.server)
             print("Error code: %d%s" % (f.faultCode, f.faultString))
         sys.exit(-1)
     # XXX: what if no SSL in socket?
     except SSL.socket_error:
         print("ERROR: SSL handshake to %s failed" % self.server)
         print("""
         This could signal that you are *NOT* talking to a server
         whose certificate was signed by a Certificate Authority
         listed in the %s file or that the
         RHNS-CA-CERT file is invalid.""" % self.rhns_ca_cert)
         sys.exit(-1)
     except socket.error:
         print("Could not retrieve action from %s.\n"\
               "Possible networking problem?" % str(self.server))
         sys.exit(-1)
     except up2dateErrors.ServerCapabilityError:
         print(sys.exc_info()[1])
         sys.exit(1)
     except SSL.Error:
         print("ERROR: SSL errors detected")
         print("%s" % sys.exc_info()[1])
         sys.exit(-1)
예제 #2
0
    def __get_action(self, status_report):
        try:
            action = self.server.queue.get(up2dateAuth.getSystemId(),
                                           ACTION_VERSION, status_report)

            return action
        except xmlrpclib.Fault:
            f = sys.exc_info()[1]
            if f.faultCode == -31:
                raise up2dateErrors.InsuffMgmntEntsError(
                    f.faultString), None, sys.exc_info()[2]
            else:
                print "Could not retrieve action item from server %s" % self.server
                print "Error code: %d%s" % (f.faultCode, f.faultString)
            sys.exit(-1)
        # XXX: what if no SSL in socket?
        except socket.sslerror:
            print "ERROR: SSL handshake to %s failed" % self.server
            print """
            This could signal that you are *NOT* talking to a server
            whose certificate was signed by a Certificate Authority
            listed in the %s file or that the
            RHNS-CA-CERT file is invalid.""" % self.rhns_ca_cert
            sys.exit(-1)
        except socket.error:
            print "Could not retrieve action from %s.\n"\
                  "Possible networking problem?" % str(self.server)
            sys.exit(-1)
        except up2dateErrors.ServerCapabilityError:
            print sys.exc_info()[1]
            sys.exit(1)
        except SSL.Error:
            print "ERROR: SSL errors detected"
            print "%s" % sys.exc_info()[1]
            sys.exit(-1)
예제 #3
0
 def __query_future_actions(self, time_window):
     try:
         actions = self.server.queue.get_future_actions(up2dateAuth.getSystemId(),
             time_window)
         return actions
     except xmlrpclib.Fault, f:
         if f.faultCode == -31:
             raise up2dateErrors.InsuffMgmntEntsError(f.faultString), None, sys.exc_info()[2]
         else:
             print "Could not retrieve action item from server %s" % self.server
             print "Error code: %d%s" % (f.faultCode, f.faultString)
         sys.exit(-1)
예제 #4
0
    def __get_action(self, status_report):
        try:
            action = self.server.queue.get(up2dateAuth.getSystemId(),
                ACTION_VERSION, status_report)

            return action
        except xmlrpclib.Fault, f:
            if f.faultCode == -31:
                raise up2dateErrors.InsuffMgmntEntsError(f.faultString), None, sys.exc_info()[2]
            else:
                print "Could not retrieve action item from server %s" % self.server
                print "Error code: %d%s" % (f.faultCode, f.faultString)
            sys.exit(-1)
예제 #5
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 == -110:
                # Account is disabled
                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) == 74:
                exception = up2dateErrors.RegistrationDeniedError()
            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