Пример #1
0
    def __call__(self, *args):

        self.logger.debug("(X) -------------------------------------------")

        try:
            rc = self.__method(*args)
        except codes.FuncException, e:
            self.__log_exc()
            (t, v, tb) = sys.exc_info()
            rc = futils.nice_exception(t, v, tb)
Пример #2
0
    def __call__(self, *args):

        self.logger.debug("(X) -------------------------------------------")

        try:
            rc = self.__method(*args)
        except codes.FuncException, e:
            self.__log_exc()
            (t, v, tb) = sys.exc_info()
            rc = futils.nice_exception(t,v,tb)
Пример #3
0
    def _dispatch(self, method, params):

        """
        the SimpleXMLRPCServer class will call _dispatch if it doesn't
        find a handler method
        """
        # take _this_request and hand it off to check out the acls of the method
        # being called vs the requesting host
        
        if not hasattr(self, '_this_request'):
            raise codes.InvalidMethodException
            
        r,a = self._this_request
        peer_cert = r.get_peer_certificate()
        ip = a[0]
        

        # generally calling conventions are:  hardware.info
        # async convention is async.hardware.info
        # here we parse out the async to decide how to invoke it.
        # see the async docs on the Wiki for further info.
        async_dispatch = False
        if method.startswith("async."):
            async_dispatch = True
            method = method.replace("async.","",1)

        if not self.acls.check(self._our_ca, peer_cert, ip, method, params):
            raise codes.AccessToMethodDenied
            
        # Recognize ipython's tab completion calls
        if method == 'trait_names' or method == '_getAttributeNames':
            return self.handlers.keys()

        cn = peer_cert.get_subject().CN
        sub_hash = peer_cert.subject_name_hash()
        self.audit_logger.log_call(ip, cn, sub_hash, method, params)

        try:
            if not async_dispatch:
                return self.get_dispatch_method(method)(*params)
            else:
                return jobthing.minion_async_run(self.get_dispatch_method, method, params)
        except:
            (t, v, tb) = sys.exc_info()
            rc = futils.nice_exception(t, v, tb)
            return rc
Пример #4
0
    def _dispatch(self, method, params):
        """
        the SimpleXMLRPCServer class will call _dispatch if it doesn't
        find a handler method
        """
        # take _this_request and hand it off to check out the acls of the method
        # being called vs the requesting host

        if not hasattr(self, '_this_request'):
            raise codes.InvalidMethodException

        r, a = self._this_request
        peer_cert = r.get_peer_certificate()
        ip = a[0]

        # generally calling conventions are:  hardware.info
        # async convention is async.hardware.info
        # here we parse out the async to decide how to invoke it.
        # see the async docs on the Wiki for further info.
        async_dispatch = False
        if method.startswith("async."):
            async_dispatch = True
            method = method.replace("async.", "", 1)

        if not self.acls.check(self._our_ca, peer_cert, ip, method, params):
            raise codes.AccessToMethodDenied

        # Recognize ipython's tab completion calls
        if method == 'trait_names' or method == '_getAttributeNames':
            return self.handlers.keys()

        cn = peer_cert.get_subject().CN
        sub_hash = peer_cert.subject_name_hash()
        self.audit_logger.log_call(ip, cn, sub_hash, method, params)

        try:
            if not async_dispatch:
                return self.get_dispatch_method(method)(*params)
            else:
                return jobthing.minion_async_run(self.get_dispatch_method,
                                                 method, params)
        except:
            (t, v, tb) = sys.exc_info()
            rc = futils.nice_exception(t, v, tb)
            return rc
Пример #5
0
            string.join(traceback.format_list(traceback.extract_tb(tb))))

    def __call__(self, *args):

        self.logger.debug("(X) -------------------------------------------")

        try:
            rc = self.__method(*args)
        except codes.FuncException, e:
            self.__log_exc()
            (t, v, tb) = sys.exc_info()
            rc = futils.nice_exception(t, v, tb)
        except:
            self.__log_exc()
            (t, v, tb) = sys.exc_info()
            rc = futils.nice_exception(t, v, tb)
        self.logger.debug("Return code for %s: %s" % (self.__name, rc))

        return rc


def serve():
    """
    Code for starting the XMLRPC service.
    """
    server = FuncSSLXMLRPCServer(('', 51234))
    server.logRequests = 0  # don't print stuff to console
    server.serve_forever()


class FuncXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer, XmlRpcInterface):
Пример #6
0
        self.logger.info("Exception Info:\n%s" % string.join(traceback.format_list(traceback.extract_tb(tb))))

    def __call__(self, *args):

        self.logger.debug("(X) -------------------------------------------")

        try:
            rc = self.__method(*args)
        except codes.FuncException, e:
            self.__log_exc()
            (t, v, tb) = sys.exc_info()
            rc = futils.nice_exception(t,v,tb)
        except:
            self.__log_exc()
            (t, v, tb) = sys.exc_info()
            rc = futils.nice_exception(t,v,tb)
        self.logger.debug("Return code for %s: %s" % (self.__name, rc))

        return rc


def serve():

    """
    Code for starting the XMLRPC service.
    """
    server =FuncSSLXMLRPCServer(('', 51234))
    server.logRequests = 0 # don't print stuff to console
    server.serve_forever()