command_defaults: Don't crash on nonexistent command

It's common for ipa commands to raise NotFound in such a case.

Fixes: https://pagure.io/freeipa/issue/8954
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Stanislav Levin 2021-08-13 15:19:25 +03:00 committed by Florence Blanc-Renaud
parent 7706dfaf09
commit 210739c0ed

View File

@ -292,6 +292,13 @@ class command_defaults(PKQuery):
)
def execute(self, name, **options):
if name not in self.api.Command:
raise errors.NotFound(
reason=_("{oname}: {command_name} not found").format(
oname=self.name, command_name=name
)
)
command = self.api.Command[name]
params = options.get('params') or []