Sandro Bonazzola has uploaded a new change for review.

Change subject: packaging: setup: confirmation through answerfile
......................................................................

packaging: setup: confirmation through answerfile

Allow to answer initial confirmation through answerfile.
Avoids also to ask anything else after first denied confirmation.

Change-Id: I56407b5f05f486f06143f91f96be7540c3a9acfc
Signed-off-by: Sandro Bonazzola <sbona...@redhat.com>
---
M src/ovirt_hosted_engine_setup/constants.py
M src/plugins/ovirt-hosted-engine-setup/core/misc.py
M src/plugins/ovirt-hosted-engine-setup/core/shell.py
3 files changed, 59 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/60/17560/1

diff --git a/src/ovirt_hosted_engine_setup/constants.py 
b/src/ovirt_hosted_engine_setup/constants.py
index 220b41a..4e80673 100644
--- a/src/ovirt_hosted_engine_setup/constants.py
+++ b/src/ovirt_hosted_engine_setup/constants.py
@@ -171,6 +171,8 @@
     ADDITIONAL_HOST_ENABLED = 'OVEHOSTED_CORE/additionalHostEnabled'
     IS_ADDITIONAL_HOST = 'OVEHOSTED_CORE/isAdditionalHost'
     TEMPDIR = 'OVEHOSTED_CORE/tempDir'
+    DEPLOY_PROCEED = 'OVEHOSTED_CORE/deployProceed'
+    SCREEN_PROCEED = 'OVEHOSTED_CORE/screenProceed'
 
 
 @util.export
@@ -447,6 +449,7 @@
     CPU_PROCEED = 'CPU_PROCEED'
     DISK_PROCEED = 'DISK_PROCEED'
     MEMORY_PROCEED = 'MEMORY_PROCEED'
+    SCREEN_PROCEED = 'SCREEN_PROCEED'
 
 
 # vim: expandtab tabstop=4 shiftwidth=4
diff --git a/src/plugins/ovirt-hosted-engine-setup/core/misc.py 
b/src/plugins/ovirt-hosted-engine-setup/core/misc.py
index 4be62d7..693e378 100644
--- a/src/plugins/ovirt-hosted-engine-setup/core/misc.py
+++ b/src/plugins/ovirt-hosted-engine-setup/core/misc.py
@@ -55,23 +55,37 @@
             otopicons.CoreEnv.LOG_FILE_NAME_PREFIX,
             ohostedcons.FileLocations.OVIRT_HOSTED_ENGINE_SETUP
         )
+        self.environment.setdefault(
+            ohostedcons.CoreEnv.DEPLOY_PROCEED,
+            None
+        )
 
     @plugin.event(
         stage=plugin.Stages.STAGE_INIT,
         priority=plugin.Stages.PRIORITY_FIRST,
     )
     def _confirm(self):
-        if not self.dialog.confirm(
-            name=ohostedcons.Confirms.DEPLOY_PROCEED,
-            description='Proceed with ovirt-hosted-engine-setup',
-            note=_(
-                'Continuing will configure this host for serving '
-                'as hypervisor and create a VM where oVirt Engine '
-                'will be installed afterwards.\n'
-                'Are you sure you want to continue? (yes/no) '
-            ),
-            prompt=True,
-        ):
+        interactive = self.environment[
+            ohostedcons.CoreEnv.DEPLOY_PROCEED
+        ] is None
+        if interactive:
+            self.environment[
+                ohostedcons.CoreEnv.DEPLOY_PROCEED
+            ] = self.dialog.queryString(
+                name=ohostedcons.Confirms.DEPLOY_PROCEED,
+                note=_(
+                    'Continuing will configure this host for serving '
+                    'as hypervisor and create a VM where oVirt Engine '
+                    'will be installed afterwards.\n'
+                    'Are you sure you want to continue? '
+                    '(@VALUES@)[@DEFAULT@]: '
+                ),
+                prompt=True,
+                validValues=(_('Yes'), _('No')),
+                caseSensitive=False,
+                default=_('Yes')
+            ) == _('Yes').lower()
+        if not self.environment[ohostedcons.CoreEnv.DEPLOY_PROCEED]:
             raise context.Abort('Aborted by user')
 
         self.environment.setdefault(
diff --git a/src/plugins/ovirt-hosted-engine-setup/core/shell.py 
b/src/plugins/ovirt-hosted-engine-setup/core/shell.py
index 64f6593..e3f4fa0 100644
--- a/src/plugins/ovirt-hosted-engine-setup/core/shell.py
+++ b/src/plugins/ovirt-hosted-engine-setup/core/shell.py
@@ -27,6 +27,7 @@
 from otopi import util
 from otopi import context
 from otopi import plugin
+from otopi import constants as otopicons
 
 
 from ovirt_hosted_engine_setup import constants as ohostedcons
@@ -45,26 +46,41 @@
     @plugin.event(
         stage=plugin.Stages.STAGE_INIT,
         priority=plugin.Stages.PRIORITY_HIGH,
+        condition=lambda self: not self.environment[otopicons.BaseEnv.ABORTED],
     )
     def _init(self):
+        self.environment.setdefault(
+            ohostedcons.CoreEnv.SCREEN_PROCEED,
+            None
+        )
         ssh_connected = not os.getenv('SSH_CLIENT') is None
         screen_used = os.getenv('TERM') == 'screen'
         if ssh_connected and not screen_used:
-            if not self.dialog.confirm(
-                name=ohostedcons.Confirms.DEPLOY_PROCEED,
-                description='Proceed with ovirt-hosted-engine-setup',
-                note=_(
-                    'It has been detected that this program is executed '
-                    'through an SSH connection without using screen.\n'
-                    'Continuing with the installation may lead to broken '
-                    'installation if the network connection fails.\n'
-                    'It is highly recommended to abort the installation and '
-                    'run it inside a screen session.\n'
-                    'Do you want to continue anyway? (yes/no) '
-                ),
-                prompt=True,
-            ):
-                raise context.Abort('Aborted by user')
+            interactive = self.environment[
+                ohostedcons.CoreEnv.SCREEN_PROCEED
+            ] is None
+            if interactive:
+                self.environment[
+                    ohostedcons.CoreEnv.SCREEN_PROCEED
+                ] = self.dialog.queryString(
+                    name=ohostedcons.Confirms.SCREEN_PROCEED,
+                    note=_(
+                        'It has been detected that this program is executed '
+                        'through an SSH connection without using screen.\n'
+                        'Continuing with the installation may lead to broken '
+                        'installation if the network connection fails.\n'
+                        'It is highly recommended to abort the installation '
+                        'and run it inside a screen session.\n'
+                        'Do you want to continue anyway? '
+                        '(@VALUES@)[@DEFAULT@]: '
+                    ),
+                    prompt=True,
+                    validValues=(_('Yes'), _('No')),
+                    caseSensitive=False,
+                    default=_('No')
+                ) == _('Yes').lower()
+                if not self.environment[ohostedcons.CoreEnv.SCREEN_PROCEED]:
+                    raise context.Abort('Aborted by user')
 
 
 # vim: expandtab tabstop=4 shiftwidth=4


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I56407b5f05f486f06143f91f96be7540c3a9acfc
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: master
Gerrit-Owner: Sandro Bonazzola <sbona...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to