diff options
author | Petr Viktorin <pviktori@redhat.com> | 2012-06-21 08:20:26 -0400 |
---|---|---|
committer | Martin Kosek <mkosek@redhat.com> | 2013-02-21 16:26:09 +0100 |
commit | 7336a176b43989b9d459a2536af88f89e849213f (patch) | |
tree | 46c2ab141dc545e8f0c148871508fe7c952d22e5 /ipalib/frontend.py | |
parent | 246bc3f3eaccf2a84310df84dc85fe455c24ac65 (diff) | |
download | freeipa-7336a176b43989b9d459a2536af88f89e849213f.tar.gz freeipa-7336a176b43989b9d459a2536af88f89e849213f.tar.xz freeipa-7336a176b43989b9d459a2536af88f89e849213f.zip |
Add the version option to all Commands
Several Commands were missing the 'version' option. Add it to those
that were missing it.
Do not remove the version option before calling commands. This means
methods such as execute(), forward(), run() receive it.
Several of these needed `**options` added to their signatures.
Commands in the Cert plugin passed any unknown options to the underlying
functions, these are changed to pass what's needed explicitly.
Some commands in DNS and Batch plugins now pass version to commands
they call.
When the option is not given, fill it in automatically. (In a subsequent
commit, a warning will be added in this case).
Note that the public API did not change: all RPC calls already accepted
a version option. There's no need for an API version bump (even though
API.txt changes substantially).
Design page: http://freeipa.org/page/V3/Messages
Tickets:
https://fedorahosted.org/freeipa/ticket/2732
https://fedorahosted.org/freeipa/ticket/3294
Diffstat (limited to 'ipalib/frontend.py')
-rw-r--r-- | ipalib/frontend.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py index 52ddf28c7..c27ff1389 100644 --- a/ipalib/frontend.py +++ b/ipalib/frontend.py @@ -526,7 +526,6 @@ class Command(HasParam): yield (name, options.pop(name)) # If any options remain, they are either internal or unknown unused_keys = set(options).difference(self.internal_options) - unused_keys.discard('version') if unused_keys: raise OptionError(_('Unknown option: %(option)s'), option=unused_keys.pop()) @@ -743,7 +742,8 @@ class Command(HasParam): if self.api.env.in_server: if 'version' in options: self.verify_client_version(options['version']) - del options['version'] + else: + options['version'] = API_VERSION return self.execute(*args, **options) return self.forward(*args, **options) @@ -897,12 +897,12 @@ class Command(HasParam): exclude='webui', flags=['no_output'], ) - yield Str('version?', - doc=_('Client version. Used to determine if server will accept request.'), - exclude='webui', - flags=['no_option', 'no_output'], - ) - return + break + yield Str('version?', + doc=_('Client version. Used to determine if server will accept request.'), + exclude='webui', + flags=['no_option', 'no_output'], + ) def validate_output(self, output): """ @@ -1282,7 +1282,7 @@ class Method(Attribute, Command): >>> from ipalib import create_api >>> api = create_api() >>> class user_add(Method): - ... def run(self): + ... def run(self, **options): ... return dict(result='Added the user!') ... >>> class user(Object): |