diff options
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/frontend.py | 9 | ||||
-rw-r--r-- | ipalib/plugins/b_xmlrpc.py | 4 | ||||
-rw-r--r-- | ipalib/plugins/f_misc.py | 27 | ||||
-rw-r--r-- | ipalib/util.py | 6 |
4 files changed, 35 insertions, 11 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py index 62a503cc5..ce4168bc9 100644 --- a/ipalib/frontend.py +++ b/ipalib/frontend.py @@ -639,8 +639,11 @@ class Command(plugable.Plugin): Generator method used by `Command.get_default`. """ for param in self.params(): - if param.required and kw.get(param.name, None) is None: - yield (param.name, param.get_default(**kw)) + if kw.get(param.name, None) is None: + if param.required: + yield (param.name, param.get_default(**kw)) + else: + yield (param.name, None) def validate(self, **kw): """ @@ -694,7 +697,7 @@ class Command(plugable.Plugin): """ Forward call over XML-RPC to this same command on server. """ - return self.api.Backend.xmlrpc.forward_call(self.name, *args, **kw) + return self.Backend.xmlrpc.forward_call(self.name, *args, **kw) def finalize(self): """ diff --git a/ipalib/plugins/b_xmlrpc.py b/ipalib/plugins/b_xmlrpc.py index 87dc95050..22361b1bb 100644 --- a/ipalib/plugins/b_xmlrpc.py +++ b/ipalib/plugins/b_xmlrpc.py @@ -43,6 +43,10 @@ class xmlrpc(Backend): """ Return an xmlrpclib.ServerProxy instance (the client). """ + # FIXME: Rob, is there any reason we can't use allow_none=True here? + # Are there any reasonably common XML-RPC client implementations + # that don't support the <nil/> extension? + # See: http://docs.python.org/library/xmlrpclib.html uri = self.api.env.xmlrpc_uri if uri.startswith('https://'): return xmlrpclib.ServerProxy(uri, diff --git a/ipalib/plugins/f_misc.py b/ipalib/plugins/f_misc.py index 055e54d75..1acf1c999 100644 --- a/ipalib/plugins/f_misc.py +++ b/ipalib/plugins/f_misc.py @@ -31,23 +31,34 @@ from ipalib import api, Command, Param, Bool class env(Command): """Show environment variables""" + takes_args = ('variables*',) + takes_options = ( Param('server?', type=Bool(), default=False, doc='Show environment variables of server', ), ) - def run(self, **kw): - if kw.get('server', False) and not self.api.env.in_server: - return self.forward() - return self.execute() + def run(self, variables, **kw): + if kw['server'] and not self.env.in_server: + return self.forward(variables) + return self.execute(variables) + + def find_keys(self, variables): + for key in variables: + if key in self.env: + yield (key, self.env[key]) - def execute(self): - return tuple( - (key, self.api.env[key]) for key in self.api.env - ) + def execute(self, variables): + if variables is None: + return tuple( + (key, self.env[key]) for key in self.env + ) + return tuple(self.find_keys(variables)) def output_for_cli(self, textui, result, **kw): + if len(result) == 0: + return textui.print_name(self.name) textui.print_keyval(result) textui.print_count(result, '%d variable', '%d variables') diff --git a/ipalib/util.py b/ipalib/util.py index 12f9c7814..9bc432545 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -34,6 +34,12 @@ def xmlrpc_marshal(*args, **kw): """ Marshal (args, kw) into ((kw,) + args). """ + kw = dict( + filter(lambda item: item[1] is not None, kw.iteritems()) + ) + args = tuple( + filter(lambda value: value is not None, args) + ) return ((kw,) + args) |