This bug was discovered when writing tests for functionality introduced
in my PATCH 0051.
This patch should apply on top of PATCH 0051.
--
Martin^3 Babinsky
From 7b281ba47e4fec7da7eab4a861a7cbaceb2bd859 Mon Sep 17 00:00:00 2001
From: Martin Babinsky
Date: Thu, 6 Aug 2015 14:19:52 +0200
Subject: [PATCH] fix crash when installer with no positional arguments handles
invalid options
when ipa-server-install received an option value which did not pass knob
validator an Attribute error was raised due to incorrect error handling with
no positional arguments.
---
ipapython/install/cli.py | 51 +---
1 file changed, 31 insertions(+), 20 deletions(-)
diff --git a/ipapython/install/cli.py b/ipapython/install/cli.py
index 98297aa3d3361dbaa08529340e69e034fb04a4f8..242eb40550e92d41cc6ad31bffbd84bb3d332000 100644
--- a/ipapython/install/cli.py
+++ b/ipapython/install/cli.py
@@ -31,48 +31,59 @@ def install_tool(configurable_class, command_name, log_file_name,
configurable_class=configurable_class,
command_name=command_name,
log_file_name=uninstall_log_file_name,
-positional_arguments=uninstall_positional_arguments,
usage=uninstall_usage,
debug_option=debug_option,
)
+if uninstall_positional_arguments is not None:
+uninstall_kwargs.update(
+dict(positional_arguments=uninstall_positional_arguments)
+)
else:
uninstall_kwargs = None
+kwargs = dict(
+configurable_class=configurable_class,
+command_name=command_name,
+log_file_name=log_file_name,
+usage=usage,
+debug_option=debug_option,
+uninstall_kwargs=uninstall_kwargs,
+)
+
+if positional_arguments is not None:
+kwargs.update(dict(positional_arguments=positional_arguments))
+
return type(
'install_tool({0})'.format(configurable_class.__name__),
(InstallTool,),
-dict(
-configurable_class=configurable_class,
-command_name=command_name,
-log_file_name=log_file_name,
-positional_arguments=positional_arguments,
-usage=usage,
-debug_option=debug_option,
-uninstall_kwargs=uninstall_kwargs,
-)
+kwargs
)
def uninstall_tool(configurable_class, command_name, log_file_name,
positional_arguments=None, usage=None, debug_option=False):
+kwargs = dict(
+configurable_class=configurable_class,
+command_name=command_name,
+log_file_name=log_file_name,
+usage=usage,
+debug_option=debug_option,
+)
+
+if positional_arguments is not None:
+kwargs.update(dict(positional_arguments=positional_arguments))
+
return type(
'uninstall_tool({0})'.format(configurable_class.__name__),
(UninstallTool,),
-dict(
-configurable_class=configurable_class,
-command_name=command_name,
-log_file_name=log_file_name,
-positional_arguments=positional_arguments,
-usage=usage,
-debug_option=debug_option,
-)
+kwargs
)
class ConfigureTool(admintool.AdminTool):
configurable_class = None
debug_option = False
-positional_arguments = None
+positional_arguments = ()
cfgr = None
@staticmethod
@@ -311,7 +322,7 @@ class ConfigureTool(admintool.AdminTool):
knob_cls = getattr(transformed_cls, e.name)
try:
index = self.positional_arguments.index(e.name)
-except IndexError:
+except ValueError:
cli_name = knob_cls.cli_name or e.name.replace('_', '-')
desc = "option --{0}".format(cli_name)
else:
--
2.4.3
--
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code