From 6ef666ed12fd73026f0f1d49faba152ae27d6082 Mon Sep 17 00:00:00 2001 From: David Kupka Date: Dec 14 2016 10:50:35 +0000 Subject: ipaclient.plugins: Use api_version from internally called commands In client plugins make sure the api_version is 'inherited' from server command that is internally called. Otherwise the api_version is obtained from client API instance. When calling server command from client command 'version' is passed in options and it overrides the right one. Server then refuses to handle such call. https://fedorahosted.org/freeipa/ticket/6539 Reviewed-By: Martin Basti --- diff --git a/ipaclient/plugins/automount.py b/ipaclient/plugins/automount.py index 3742705..680e7c8 100644 --- a/ipaclient/plugins/automount.py +++ b/ipaclient/plugins/automount.py @@ -60,6 +60,10 @@ class automountlocation_tofiles(MethodOverride): NO_CLI = classproperty(__NO_CLI_getter) + @property + def api_version(self): + return self.api.Command.automountlocation_show.api_version + def output_for_cli(self, textui, result, *keys, **options): maps = result['result']['maps'] keys = result['result']['keys'] diff --git a/ipaclient/plugins/otptoken_yubikey.py b/ipaclient/plugins/otptoken_yubikey.py index 1075b6d..759b722 100644 --- a/ipaclient/plugins/otptoken_yubikey.py +++ b/ipaclient/plugins/otptoken_yubikey.py @@ -81,6 +81,10 @@ class otptoken_add_yubikey(Command): NO_CLI = classproperty(__NO_CLI_getter) + @property + def api_version(self): + return self.api.Command.otptoken_add.api_version + def get_args(self): for arg in self.api.Command.otptoken_add.args(): yield arg diff --git a/ipaclient/plugins/vault.py b/ipaclient/plugins/vault.py index 08bbeb5..28ee4f9 100644 --- a/ipaclient/plugins/vault.py +++ b/ipaclient/plugins/vault.py @@ -210,6 +210,10 @@ class vault_add(Local): NO_CLI = classproperty(__NO_CLI_getter) + @property + def api_version(self): + return self.api.Command.vault_add_internal.api_version + def get_args(self): for arg in self.api.Command.vault_add_internal.args(): yield arg @@ -416,6 +420,10 @@ class vault_mod(Local): NO_CLI = classproperty(__NO_CLI_getter) + @property + def api_version(self): + return self.api.Command.vault_mod_internal.api_version + def get_args(self): for arg in self.api.Command.vault_mod_internal.args(): yield arg @@ -603,6 +611,10 @@ class vault_archive(Local): NO_CLI = classproperty(__NO_CLI_getter) + @property + def api_version(self): + return self.api.Command.vault_archive_internal.api_version + def get_args(self): for arg in self.api.Command.vault_archive_internal.args(): yield arg @@ -860,6 +872,10 @@ class vault_retrieve(Local): NO_CLI = classproperty(__NO_CLI_getter) + @property + def api_version(self): + return self.api.Command.vault_retrieve_internal.api_version + def get_args(self): for arg in self.api.Command.vault_retrieve_internal.args(): yield arg