Sandro Bonazzola has uploaded a new change for review.

Change subject: packaging: setup: handle answerfile correctly
......................................................................

packaging: setup: handle answerfile correctly

Previously if CREATE_READONLY_USER was specified
in answer file, the readonly user was not created.

Now if CREATE_READONLY_USER is set to yes or true
it will be created using validated values from:
- READONLY_SECURE
- READONLY_USER
- READONLY_PASS

Change-Id: I1598f4bfaf82b1713f6b0e4ee5b61d1053542702
Bug-Url: https://bugzilla.redhat.com/1040029
Signed-off-by: Sandro Bonazzola <[email protected]>
---
M packaging/ovirt-engine-dwh-setup.py
1 file changed, 29 insertions(+), 13 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-dwh refs/changes/69/22369/1

diff --git a/packaging/ovirt-engine-dwh-setup.py 
b/packaging/ovirt-engine-dwh-setup.py
index 5a001a6..6d536fb 100755
--- a/packaging/ovirt-engine-dwh-setup.py
+++ b/packaging/ovirt-engine-dwh-setup.py
@@ -100,9 +100,9 @@
             params[param] = fconf.get('general', param)
             if params[param] == 'None':
                 params[param] = None
-            elif params[param] in ('True', 'true'):
+            elif params[param].lower() in ('true', 'yes'):
                 params[param] = True
-            elif params[param] in ('False', 'false'):
+            elif params[param].lower() in ('false', 'no'):
                 params[param] = False
 
     return params
@@ -415,22 +415,22 @@
                 # Handle postgres configuration for the read-only user
                 # on local installations only
 
-                if (
-                    db_dict['readonly'] is None and
-                    options['CREATE_READONLY_USER'] is None
-                ):
-                    # Ask user how would the user be created
-                    createReadUser = utils.askYesNo(
-                        question=(
-                            '\nThis utility can configure a read only user for 
DB access. '
-                            'Would you like to do so?'
+                if db_dict['readonly'] is None:
+                    if options['CREATE_READONLY_USER'] is None:
+                        # Ask user how would the user be created
+                        createReadUser = utils.askYesNo(
+                            question=(
+                                '\nThis utility can configure a read only user 
for DB access. '
+                                'Would you like to do so?'
+                            )
                         )
-                    )
+                    else:
+                        createReadUser = options['CREATE_READONLY_USER']
 
                     if not createReadUser:
                         logging.debug('Skipping creation of read only DB 
user.')
                         print 'Skipping creation of read only DB user.'
-                    else:
+                    elif options['CREATE_READONLY_USER'] is None:
                         readonly_user = ''
                         while not utils.userValid(readonly_user):
                             readonly_user = utils.askQuestion(
@@ -444,6 +444,22 @@
                                 'Should postgresql be setup with secure 
connection?'
                             )
                         )
+                    else:
+                        # validate answer file values only
+                        if readonly_user is None or not 
utils.userValid(readonly_user):
+                            raise RuntimeError(
+                                'Invalid read only user in answer file'
+                            )
+                        if readonly_pass is None:
+                            raise RuntimeError(
+                                'Missing password for read only user '
+                                'in answer file'
+                            )
+                        if readonly_secure is None:
+                            raise RuntimeError(
+                                'Missing parameter READONLY_SECURE '
+                                'in answerfile'
+                            )
 
             # Save configuration to the conf.d file
             utils.saveConfig(


-- 
To view, visit http://gerrit.ovirt.org/22369
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1598f4bfaf82b1713f6b0e4ee5b61d1053542702
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-dwh
Gerrit-Branch: master
Gerrit-Owner: Sandro Bonazzola <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to