From ac9597ddcbfed317b9622e4d2e7145555e4e9873 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Tue, 7 Oct 2008 23:01:11 -0600 Subject: Renamed webui-cherry.py, simple-server.py to lite-webui.py, lite-xmlrpc.py respectively --- lite-xmlrpc.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 lite-xmlrpc.py (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py new file mode 100755 index 00000000..6d29d74a --- /dev/null +++ b/lite-xmlrpc.py @@ -0,0 +1,51 @@ +#!/usr/bin/python + +# Authors: +# Jason Gerard DeRose +# +# Copyright (C) 2008 Red Hat +# see file 'COPYING' for use and warranty information +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2 only +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +""" +A simple XML-RPC test server using SimpleXMLRPCServer. + +The server will run at http://localhost:8080 +""" + +from SimpleXMLRPCServer import SimpleXMLRPCServer +from ipalib.util import xmlrpc_unmarshal +from ipalib import api +from ipalib import load_plugins + +api.env.server_context = True +api.finalize() + +class Dispatch(object): + def __init__(self, cmd): + self.__cmd = cmd + + def __call__(self, *params): + print 'dispatch: %s%r' % (self.__cmd.name, params) + (args, kw) = xmlrpc_unmarshal(*params) + return self.__cmd(*args, **kw) + + +server = SimpleXMLRPCServer(('localhost', 8880), allow_none=True) +server.register_introspection_functions() +for cmd in api.Command(): + server.register_function(Dispatch(cmd), cmd.name) + +server.serve_forever() -- cgit From 0cdc1e015a7da724ce8347c4a3f5bb1e95b539e5 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 22 Oct 2008 19:49:39 -0600 Subject: Removed my lite-xmlrpc.py script --- lite-xmlrpc.py | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100755 lite-xmlrpc.py (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py deleted file mode 100755 index 6d29d74a..00000000 --- a/lite-xmlrpc.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/python - -# Authors: -# Jason Gerard DeRose -# -# Copyright (C) 2008 Red Hat -# see file 'COPYING' for use and warranty information -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; version 2 only -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -""" -A simple XML-RPC test server using SimpleXMLRPCServer. - -The server will run at http://localhost:8080 -""" - -from SimpleXMLRPCServer import SimpleXMLRPCServer -from ipalib.util import xmlrpc_unmarshal -from ipalib import api -from ipalib import load_plugins - -api.env.server_context = True -api.finalize() - -class Dispatch(object): - def __init__(self, cmd): - self.__cmd = cmd - - def __call__(self, *params): - print 'dispatch: %s%r' % (self.__cmd.name, params) - (args, kw) = xmlrpc_unmarshal(*params) - return self.__cmd(*args, **kw) - - -server = SimpleXMLRPCServer(('localhost', 8880), allow_none=True) -server.register_introspection_functions() -for cmd in api.Command(): - server.register_function(Dispatch(cmd), cmd.name) - -server.serve_forever() -- cgit From a204a0426d2cada051e416ccc67d1eeafa86abcd Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 22 Oct 2008 19:54:39 -0600 Subject: Renamed Rob's test_server script to lite-xmlrpc.py --- lite-xmlrpc.py | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100755 lite-xmlrpc.py (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py new file mode 100755 index 00000000..86df6815 --- /dev/null +++ b/lite-xmlrpc.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python + +import sys +import SimpleXMLRPCServer +import logging +import xmlrpclib +import re +import threading +import commands +from ipalib import api +from ipalib import config +from ipa_server import conn +from ipa_server.servercore import context +import ipalib.load_plugins +from ipalib.util import xmlrpc_unmarshal +import traceback + +PORT=8888 + +class StoppableXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer): + """Override of TIME_WAIT""" + allow_reuse_address = True + + def serve_forever(self): + self.stop = False + while not self.stop: + self.handle_request() + +class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHandler): + """Overides the default SimpleXMLRPCRequestHander to support logging. + Logs client IP and the XML request and response. + """ + + def parse(self, given): + """Convert the incoming arguments into the format IPA expects""" + args = [] + kw = {} + for g in given: + kw[g] = unicode(given[g]) + return (args, kw) + + def _dispatch(self, method, params): + """Dispatches the XML-RPC method. + + Methods beginning with an '_' are considered private and will + not be called. + """ + + # this is fine for our test server + # uid = commands.getoutput('/usr/bin/id -u') + uid = "500" + krbccache = "FILE:/tmp/krb5cc_" + uid + + func = None + try: + try: + # check to see if a matching function has been registered + func = funcs[method] + except KeyError: + raise Exception('method "%s" is not supported' % method) + (args, kw) = xmlrpc_unmarshal(*params) + # FIXME: don't hardcode host and port + context.conn = conn.IPAConn("localhost", 389, krbccache) + logger.info("calling %s" % method) + return func(*args, **kw) + finally: + # Clean up any per-request data and connections +# for k in context.__dict__.keys(): +# del context.__dict__[k] + pass + + def _marshaled_dispatch(self, data, dispatch_method = None): + try: + params, method = xmlrpclib.loads(data) + + # generate response + if dispatch_method is not None: + response = dispatch_method(method, params) + else: + response = self._dispatch(method, params) + # wrap response in a singleton tuple + response = (response,) + response = xmlrpclib.dumps(response, methodresponse=1) + except: + # report exception back to client. This is needed to report + # tracebacks found in server code. + e_class, e = sys.exc_info()[:2] + # FIXME, need to get this number from somewhere... + faultCode = getattr(e_class,'faultCode',1) + tb_str = ''.join(traceback.format_exception(*sys.exc_info())) + faultString = tb_str + response = xmlrpclib.dumps(xmlrpclib.Fault(faultCode, faultString)) + + return response + + def do_POST(self): + clientIP, port = self.client_address + # Log client IP and Port + logger.info('Client IP: %s - Port: %s' % (clientIP, port)) + try: + # get arguments + data = self.rfile.read(int(self.headers["content-length"])) + + # unmarshal the XML data + params, method = xmlrpclib.loads(data) + + # Log client request + logger.info('Client request: \n%s\n' % data) + + response = self._marshaled_dispatch( + data, getattr(self, '_dispatch', None)) + + # Log server response + logger.info('Server response: \n%s\n' % response) + except Exception, e: + # This should only happen if the module is buggy + # internal error, report as HTTP server error + print e + self.send_response(500) + self.end_headers() + else: + # got a valid XML-RPC response + self.send_response(200) + self.send_header("Content-type", "text/xml") + self.send_header("Content-length", str(len(response))) + self.end_headers() + self.wfile.write(response) + + # shut down the connection + self.wfile.flush() + self.connection.shutdown(1) + +# Set up our logger +logger = logging.getLogger('xmlrpcserver') +hdlr = logging.FileHandler('xmlrpcserver.log') +formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s") +hdlr.setFormatter(formatter) +logger.addHandler(hdlr) +logger.setLevel(logging.INFO) + +# Set up the server +XMLRPCServer = StoppableXMLRPCServer(("",PORT), LoggingSimpleXMLRPCRequestHandler) + +XMLRPCServer.register_introspection_functions() + +api.finalize() + +# Initialize our environment +config.set_default_env(api.env) +env_dict = config.read_config() +env_dict['server_context'] = True +api.env.update(env_dict) + +# Get and register all the methods +for cmd in api.Command: + logger.info("registering %s" % cmd) + XMLRPCServer.register_function(api.Command[cmd], cmd) + +funcs = XMLRPCServer.funcs + +print "Listening on port %d" % PORT +try: + XMLRPCServer.serve_forever() +except KeyboardInterrupt: + XMLRPCServer.server_close() + print "Server shutdown." -- cgit From e93c0455d48534afae347b40f0f5d10a7fab4e06 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 22 Oct 2008 22:14:58 -0600 Subject: Added place-holder mod_python_webui.py module; cleaned up lite-* and mod_python_* docstrings --- lite-xmlrpc.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 86df6815..49f3a2ae 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -15,6 +15,10 @@ import ipalib.load_plugins from ipalib.util import xmlrpc_unmarshal import traceback +""" +In-tree XML-RPC server using SimpleXMLRPCServer. +""" + PORT=8888 class StoppableXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer): -- cgit From fb441b2b1054de1ba0a99d01b9e1ea9700024aeb Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Wed, 22 Oct 2008 23:00:45 -0600 Subject: make-doc now includes the lite-* scripts, both with now check in __name__ == '__main__' before starting --- lite-xmlrpc.py | 82 +++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 30 deletions(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 49f3a2ae..88ef1512 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -1,5 +1,28 @@ #!/usr/bin/env python +# Authors: +# Rob Crittenden +# +# Copyright (C) 2008 Red Hat +# see file 'COPYING' for use and warranty information +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; version 2 only +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +""" +In-tree XML-RPC server using SimpleXMLRPCServer. +""" + import sys import SimpleXMLRPCServer import logging @@ -15,9 +38,6 @@ import ipalib.load_plugins from ipalib.util import xmlrpc_unmarshal import traceback -""" -In-tree XML-RPC server using SimpleXMLRPCServer. -""" PORT=8888 @@ -134,37 +154,39 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa self.wfile.flush() self.connection.shutdown(1) -# Set up our logger -logger = logging.getLogger('xmlrpcserver') -hdlr = logging.FileHandler('xmlrpcserver.log') -formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s") -hdlr.setFormatter(formatter) -logger.addHandler(hdlr) -logger.setLevel(logging.INFO) -# Set up the server -XMLRPCServer = StoppableXMLRPCServer(("",PORT), LoggingSimpleXMLRPCRequestHandler) +if __name__ == '__main__': + # Set up our logger + logger = logging.getLogger('xmlrpcserver') + hdlr = logging.FileHandler('xmlrpcserver.log') + formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s") + hdlr.setFormatter(formatter) + logger.addHandler(hdlr) + logger.setLevel(logging.INFO) + + # Set up the server + XMLRPCServer = StoppableXMLRPCServer(("",PORT), LoggingSimpleXMLRPCRequestHandler) -XMLRPCServer.register_introspection_functions() + XMLRPCServer.register_introspection_functions() -api.finalize() + api.finalize() -# Initialize our environment -config.set_default_env(api.env) -env_dict = config.read_config() -env_dict['server_context'] = True -api.env.update(env_dict) + # Initialize our environment + config.set_default_env(api.env) + env_dict = config.read_config() + env_dict['server_context'] = True + api.env.update(env_dict) -# Get and register all the methods -for cmd in api.Command: - logger.info("registering %s" % cmd) - XMLRPCServer.register_function(api.Command[cmd], cmd) + # Get and register all the methods + for cmd in api.Command: + logger.info("registering %s" % cmd) + XMLRPCServer.register_function(api.Command[cmd], cmd) -funcs = XMLRPCServer.funcs + funcs = XMLRPCServer.funcs -print "Listening on port %d" % PORT -try: - XMLRPCServer.serve_forever() -except KeyboardInterrupt: - XMLRPCServer.server_close() - print "Server shutdown." + print "Listening on port %d" % PORT + try: + XMLRPCServer.serve_forever() + except KeyboardInterrupt: + XMLRPCServer.server_close() + print "Server shutdown." -- cgit From 06a82bf4b646cd077a43841abb5670d9a495b24c Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Thu, 23 Oct 2008 11:00:50 -0400 Subject: Fix ipa command running in server_context=True Make the LDAP host and port environment variables More changes so that commands have a shell return value lite-xmlrpc no longer hardcodes the kerberos credentials cache location --- lite-xmlrpc.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 88ef1512..7e9c69a8 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -37,6 +37,7 @@ from ipa_server.servercore import context import ipalib.load_plugins from ipalib.util import xmlrpc_unmarshal import traceback +import krbV PORT=8888 @@ -70,10 +71,7 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa not be called. """ - # this is fine for our test server - # uid = commands.getoutput('/usr/bin/id -u') - uid = "500" - krbccache = "FILE:/tmp/krb5cc_" + uid + krbccache = krbV.default_context().default_ccache().name func = None try: @@ -84,7 +82,7 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa raise Exception('method "%s" is not supported' % method) (args, kw) = xmlrpc_unmarshal(*params) # FIXME: don't hardcode host and port - context.conn = conn.IPAConn("localhost", 389, krbccache) + context.conn = conn.IPAConn(api.env.ldaphost, api.env.ldapport, krbccache) logger.info("calling %s" % method) return func(*args, **kw) finally: -- cgit From c8b3f6516513dc3e5948fe8280c3f159ad122684 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Mon, 27 Oct 2008 00:41:37 -0600 Subject: Removed depreciated load_plugins.py module; changed all places where load_plugins was imported to now call api.load_plugins() --- lite-xmlrpc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 7e9c69a8..b057138c 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -34,11 +34,12 @@ from ipalib import api from ipalib import config from ipa_server import conn from ipa_server.servercore import context -import ipalib.load_plugins from ipalib.util import xmlrpc_unmarshal import traceback import krbV +api.load_plugins() + PORT=8888 -- cgit From fbcb55bd11d17dbff8ec3c7c99cf7b3bb91d3752 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Tue, 28 Oct 2008 02:10:56 -0600 Subject: lite-xmlrpc.py now uses api.bootstrap() property, logs to api.logger --- lite-xmlrpc.py | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index b057138c..5e2112d7 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -38,11 +38,6 @@ from ipalib.util import xmlrpc_unmarshal import traceback import krbV -api.load_plugins() - - -PORT=8888 - class StoppableXMLRPCServer(SimpleXMLRPCServer.SimpleXMLRPCServer): """Override of TIME_WAIT""" allow_reuse_address = True @@ -155,37 +150,26 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa if __name__ == '__main__': - # Set up our logger - logger = logging.getLogger('xmlrpcserver') - hdlr = logging.FileHandler('xmlrpcserver.log') - formatter = logging.Formatter("%(asctime)s %(levelname)s %(message)s") - hdlr.setFormatter(formatter) - logger.addHandler(hdlr) - logger.setLevel(logging.INFO) + api.bootstrap(context='server', verbose=True) + logger = api.logger # Set up the server - XMLRPCServer = StoppableXMLRPCServer(("",PORT), LoggingSimpleXMLRPCRequestHandler) - + XMLRPCServer = StoppableXMLRPCServer( + ('', api.env.lite_xmlrpc_port), + LoggingSimpleXMLRPCRequestHandler + ) XMLRPCServer.register_introspection_functions() - api.finalize() - - # Initialize our environment - config.set_default_env(api.env) - env_dict = config.read_config() - env_dict['server_context'] = True - api.env.update(env_dict) - # Get and register all the methods + api.finalize() for cmd in api.Command: - logger.info("registering %s" % cmd) + logger.debug('registering %s', cmd) XMLRPCServer.register_function(api.Command[cmd], cmd) - funcs = XMLRPCServer.funcs - print "Listening on port %d" % PORT + logger.info('Listening on port %d', api.env.lite_xmlrpc_port) try: XMLRPCServer.serve_forever() except KeyboardInterrupt: XMLRPCServer.server_close() - print "Server shutdown." + logger.info('Server shutdown.') -- cgit From 47c736a90b845e3e96d99b06fac19e410d64e76b Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Tue, 28 Oct 2008 02:33:35 -0600 Subject: Cleaned up some funky indentation inconsistencies in lite-xmlrpc.py --- lite-xmlrpc.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 5e2112d7..73c7e028 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -113,7 +113,7 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa def do_POST(self): clientIP, port = self.client_address - # Log client IP and Port + # Log client IP and Port logger.info('Client IP: %s - Port: %s' % (clientIP, port)) try: # get arguments @@ -123,14 +123,14 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa params, method = xmlrpclib.loads(data) # Log client request - logger.info('Client request: \n%s\n' % data) + logger.info('Client request: \n%s\n' % data) response = self._marshaled_dispatch( data, getattr(self, '_dispatch', None)) - # Log server response + # Log server response logger.info('Server response: \n%s\n' % response) - except Exception, e: + except Exception, e: # This should only happen if the module is buggy # internal error, report as HTTP server error print e -- cgit From ad60c94b5eadc797eb65de9059d557dbadc8ef71 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Tue, 28 Oct 2008 02:45:38 -0600 Subject: Cleaned up LoggingSimpleXMLRPCRequestHandler._dispatch() method --- lite-xmlrpc.py | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 73c7e028..6fbd76d8 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -61,31 +61,24 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa return (args, kw) def _dispatch(self, method, params): - """Dispatches the XML-RPC method. + """ + Dispatches the XML-RPC method. Methods beginning with an '_' are considered private and will not be called. """ - + if method not in funcs: + logger.error('no such method %r', method) + raise Exception('method "%s" is not supported' % method) + func = funcs[method] krbccache = krbV.default_context().default_ccache().name - - func = None - try: - try: - # check to see if a matching function has been registered - func = funcs[method] - except KeyError: - raise Exception('method "%s" is not supported' % method) - (args, kw) = xmlrpc_unmarshal(*params) - # FIXME: don't hardcode host and port - context.conn = conn.IPAConn(api.env.ldaphost, api.env.ldapport, krbccache) - logger.info("calling %s" % method) - return func(*args, **kw) - finally: - # Clean up any per-request data and connections -# for k in context.__dict__.keys(): -# del context.__dict__[k] - pass + context.conn = conn.IPAConn( + api.env.ldap_host, + api.env.ldap_port, + krbccache, + ) + logger.info('calling %s', method) + return func(*args, **kw) def _marshaled_dispatch(self, data, dispatch_method = None): try: -- cgit From dfc690696a448ee973ea48ed5ddf736e0b4377e4 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Tue, 28 Oct 2008 03:08:32 -0600 Subject: Fixed some things I broke in lite-xmlrpc.py --- lite-xmlrpc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 6fbd76d8..3483ceb5 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -78,6 +78,7 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa krbccache, ) logger.info('calling %s', method) + (args, kw) = xmlrpc_unmarshal(*params) return func(*args, **kw) def _marshaled_dispatch(self, data, dispatch_method = None): @@ -143,7 +144,9 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa if __name__ == '__main__': - api.bootstrap(context='server', verbose=True) + api.bootstrap(context='server') + api.load_plugins() + api.finalize() logger = api.logger # Set up the server @@ -154,12 +157,13 @@ if __name__ == '__main__': XMLRPCServer.register_introspection_functions() # Get and register all the methods - api.finalize() + for cmd in api.Command: logger.debug('registering %s', cmd) XMLRPCServer.register_function(api.Command[cmd], cmd) funcs = XMLRPCServer.funcs + logger.info('Logging to file %r', api.env.log) logger.info('Listening on port %d', api.env.lite_xmlrpc_port) try: XMLRPCServer.serve_forever() -- cgit From 3076cb4d2fa1be023a1c72d70cbdf5024047ff2a Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 30 Oct 2008 14:11:24 -0600 Subject: Plugin.set_api() now sets convience instance attributes from api for env, context, log, and all NameSpace --- lite-xmlrpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 3483ceb5..988cc2ba 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -147,7 +147,7 @@ if __name__ == '__main__': api.bootstrap(context='server') api.load_plugins() api.finalize() - logger = api.logger + logger = api.log # Set up the server XMLRPCServer = StoppableXMLRPCServer( -- cgit From 140458cfc694a1b77100c81a58600365627e7758 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 31 Oct 2008 12:29:59 -0600 Subject: API.finalize() now cascades call to API.load_plugins() --- lite-xmlrpc.py | 1 - 1 file changed, 1 deletion(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 988cc2ba..131ef8b3 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -145,7 +145,6 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa if __name__ == '__main__': api.bootstrap(context='server') - api.load_plugins() api.finalize() logger = api.log -- cgit From a23d41a57f43c3a0f298d3918ae1712181fa544e Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 31 Oct 2008 18:17:08 -0600 Subject: Reoganized global option functionality to it is easy for any script to use the environment-related global options; lite-xmlrpc.py now uses same global options --- lite-xmlrpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 131ef8b3..26204d92 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -144,7 +144,7 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa if __name__ == '__main__': - api.bootstrap(context='server') + api.bootstrap_from_options(context='server') api.finalize() logger = api.log -- cgit From 5e5a83e4e84d2e9a5d6d987056199a8ed83978b8 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 31 Oct 2008 19:03:07 -0600 Subject: Renamed API.bootstrap_from_options() to bootstrap_with_global_options() --- lite-xmlrpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 26204d92..702d469d 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -144,7 +144,7 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa if __name__ == '__main__': - api.bootstrap_from_options(context='server') + api.bootstrap_with_global_options(context='server') api.finalize() logger = api.log -- cgit From a9e8bda0cf2cc76593d7eb89138607aa2cc5bb61 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Fri, 31 Oct 2008 20:59:44 -0600 Subject: Dropped some of the more verbose logging in lite-xmlrpc.py to logger.debug() --- lite-xmlrpc.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 702d469d..3b04bc3f 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -115,15 +115,19 @@ class LoggingSimpleXMLRPCRequestHandler(SimpleXMLRPCServer.SimpleXMLRPCRequestHa # unmarshal the XML data params, method = xmlrpclib.loads(data) + logger.info('Call to %s(%s) from %s:%s', method, + ', '.join(repr(p) for p in params), + clientIP, port + ) # Log client request - logger.info('Client request: \n%s\n' % data) + logger.debug('Client request: \n%s\n' % data) response = self._marshaled_dispatch( data, getattr(self, '_dispatch', None)) # Log server response - logger.info('Server response: \n%s\n' % response) + logger.debug('Server response: \n%s\n' % response) except Exception, e: # This should only happen if the module is buggy # internal error, report as HTTP server error -- cgit From 6fe78a4944f11d430b724103f7d8d49c92af9b63 Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Sun, 4 Jan 2009 18:39:39 -0700 Subject: Renamed all references to 'ipa_server' to 'ipaserver' --- lite-xmlrpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lite-xmlrpc.py') diff --git a/lite-xmlrpc.py b/lite-xmlrpc.py index 3b04bc3f..ee03adae 100755 --- a/lite-xmlrpc.py +++ b/lite-xmlrpc.py @@ -32,8 +32,8 @@ import threading import commands from ipalib import api from ipalib import config -from ipa_server import conn -from ipa_server.servercore import context +from ipaserver import conn +from ipaserver.servercore import context from ipalib.util import xmlrpc_unmarshal import traceback import krbV -- cgit