From a64aba36a42397b02b4032dcd7e7cfa84ae6d30f Mon Sep 17 00:00:00 2001 From: Jan Cholasta Date: Tue, 14 Jun 2016 13:37:23 +0200 Subject: [PATCH] schema: exclude local commands Commands inherited from Local can't be executed remotely, so exclude them from API schema. https://fedorahosted.org/freeipa/ticket/4739 Reviewed-By: David Kupka --- ipaserver/plugins/schema.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ipaserver/plugins/schema.py b/ipaserver/plugins/schema.py index ae233d205..e5aac6ff9 100644 --- a/ipaserver/plugins/schema.py +++ b/ipaserver/plugins/schema.py @@ -10,7 +10,7 @@ import six from ipalib import errors from ipalib.crud import PKQuery, Retrieve, Search -from ipalib.frontend import Command, Method, Object +from ipalib.frontend import Command, Local, Method, Object from ipalib.output import Entry, ListOfEntries, ListOfPrimaryKeys, PrimaryKey from ipalib.parameters import Bool, Dict, Flag, Int, Str from ipalib.plugable import Registry @@ -188,16 +188,22 @@ class command(MetaObject): def _retrieve(self, name, **kwargs): try: - return self.api.Command[name] + command = self.api.Command[name] + if not isinstance(command, Local): + return command except KeyError: - raise errors.NotFound( - reason=_("%(pkey)s: %(oname)s not found") % { - 'pkey': name, 'oname': self.name, - } - ) + pass + + raise errors.NotFound( + reason=_("%(pkey)s: %(oname)s not found") % { + 'pkey': name, 'oname': self.name, + } + ) def _search(self, **kwargs): - return self.api.Command() + for command in self.api.Command(): + if not isinstance(command, Local): + yield command @register()