Example #1
0
    def login(self, username=None, password=None):

        self._get_session()

        if not self.session and not (username and password):
            raise cfg_exceptions.InvalidSession()

        if self.session and not username:
            test = self.rpc_call('config.test_session',
                                 {'session': self.session})
            if not test:
                raise cfg_exceptions.InvalidSession(
                    'Session is either expired or invalid')

        else:
            self.username = username
            self.password = password

            try:
                self.session = self.rpc_call('config.rhn_login', {
                    'username': self.username,
                    'password': self.password,
                })
            except xmlrpclib.Fault, e:
                fault_code, fault_string = e.faultCode, e.faultString
                if fault_code == -2:
                    raise cfg_exceptions.AuthenticationError(
                        "Invalid username or incorrect password"
                    ), None, sys.exc_info()[2]
                raise cfg_exceptions.InvalidSession(
                    fault_code, fault_string), None, sys.exc_info()[2]

            self._save_session()
Example #2
0
 def rpc_call(self, method_name, *params):
     try:
         result = apply(repository.RPC_Repository.rpc_call,
             (self, method_name) + params)
     except xmlrpclib.Fault, e:
         if e.faultCode == -9:
             # System not subscribed
             raise cfg_exceptions.AuthenticationError(
                 "Invalid digital server certificate%s" % e.faultString), None, sys.exc_info()[2]
         raise
Example #3
0
 def rpc_call(self, method_name, *params):
     try:
         result = repository.RPC_Repository.rpc_call(self, method_name, *params)
     except xmlrpclib.Fault:
         e = sys.exc_info()[1]
         if e.faultCode == -9:
             # System not subscribed
             raise_with_tb(cfg_exceptions.AuthenticationError(
                 "Invalid digital server certificate%s" % e.faultString), sys.exc_info()[2])
         raise
     return result