Add a method to Installer classes to validate argument input
authorRob Crittenden <rcritten@redhat.com>
Thu, 26 Mar 2015 18:55:27 +0000 (14:55 -0400)
committerPatrick Uiterwijk <puiterwijk@redhat.com>
Fri, 27 Mar 2015 18:46:52 +0000 (19:46 +0100)
There was no way to validate argument input from plugins and
cause the installer to bail out. If a plugin needs to validate
some input it can use the validate_args() method and raise
ConfigurationError() if an issue is found.

https://fedorahosted.org/ipsilon/ticket/78

Signed-off-by: Rob Crittenden <rcritten@redhat.com>
Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
ipsilon/helpers/common.py
ipsilon/info/common.py
ipsilon/install/ipsilon-server-install
ipsilon/login/common.py
ipsilon/providers/common.py

index dcbde2b..8eff274 100644 (file)
@@ -33,6 +33,9 @@ class EnvHelpersInstaller(object):
     def install_args(self, group):
         raise NotImplementedError
 
+    def validate_args(self, args):
+        return
+
     def configure_server(self, opts):
         raise NotImplementedError
 
index 725f0fa..dd48ae9 100644 (file)
@@ -94,6 +94,9 @@ class InfoProviderInstaller(object):
     def install_args(self, group):
         raise NotImplementedError
 
+    def validate_args(self, args):
+        return
+
     def unconfigure(self, opts):
         return
 
index edcccb6..8f915f3 100755 (executable)
@@ -348,6 +348,11 @@ def parse_args(plugins):
     if len(args['hostname'].split('.')) < 2:
         raise ConfigurationError('Hostname: %s is not a FQDN')
 
+    for plugin_group in plugins:
+        for plugin_name in plugins[plugin_group]:
+            plugin = plugins[plugin_group][plugin_name]
+            plugin.validate_args(args)
+
     try:
         pwd.getpwnam(args['system_user'])
     except KeyError:
index a3020a4..9beb741 100644 (file)
@@ -310,6 +310,9 @@ class LoginManagerInstaller(object):
     def install_args(self, group):
         raise NotImplementedError
 
+    def validate_args(self, args):
+        return
+
     def configure(self, opts):
         raise NotImplementedError
 
index 169fddc..74c00df 100644 (file)
@@ -125,6 +125,9 @@ class ProviderInstaller(object):
     def install_args(self, group):
         raise NotImplementedError
 
+    def validate_args(self, args):
+        return
+
     def configure(self, opts):
         raise NotImplementedError