Simone Tiraboschi has uploaded a new change for review.

Change subject: packaging: setup: asking about retriyng VG creation with force 
option
......................................................................

packaging: setup: asking about retriyng VG creation with force option

On dirty storage devices CreateVG could fail, force option can
prevent failures destroying any existent data.
Asking about retriyng VG creation with force option if first
attempt fails.

Change-Id: I496c34e6b9f0d84443a8d5bc68d77916be6cb504
Signed-off-by: Simone Tiraboschi <stira...@redhat.com>
---
M src/ovirt_hosted_engine_setup/constants.py
M src/plugins/ovirt-hosted-engine-setup/storage/blockd.py
2 files changed, 44 insertions(+), 2 deletions(-)


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

diff --git a/src/ovirt_hosted_engine_setup/constants.py 
b/src/ovirt_hosted_engine_setup/constants.py
index 70170ea..e4c248e 100644
--- a/src/ovirt_hosted_engine_setup/constants.py
+++ b/src/ovirt_hosted_engine_setup/constants.py
@@ -582,6 +582,8 @@
     def LOCKSPACE_IMAGE_UUID(self):
         return 'OVEHOSTED_STORAGE/lockspaceImageUUID'
 
+    PROMPT_RETRY_CREATEVG = 'OVEHOSTED_ENGINE/promptRetryCreateVG'
+
 
 @util.export
 @util.codegen
diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/blockd.py 
b/src/plugins/ovirt-hosted-engine-setup/storage/blockd.py
index 64edb1d..5f3b1d4 100644
--- a/src/plugins/ovirt-hosted-engine-setup/storage/blockd.py
+++ b/src/plugins/ovirt-hosted-engine-setup/storage/blockd.py
@@ -450,6 +450,10 @@
             ohostedcons.StorageEnv.GUID,
             None
         )
+        self.environment.setdefault(
+            ohostedcons.StorageEnv.PROMPT_RETRY_CREATEVG,
+            None
+        )
 
     @plugin.event(
         stage=plugin.Stages.STAGE_CUSTOMIZATION,
@@ -555,11 +559,47 @@
                 [
                     self.environment[ohostedcons.StorageEnv.LUN_ID],
                 ],
-                False,
+                force=False,
             )
             self.logger.debug(dom)
             if dom['status']['code'] != 0:
-                raise RuntimeError(dom['status']['message'])
+                if self.environment[
+                    ohostedcons.StorageEnv.PROMPT_RETRY_CREATEVG
+                ] is None:
+                    self.environment[
+                        ohostedcons.StorageEnv.PROMPT_RETRY_CREATEVG
+                    ] = self.dialog.queryString(
+                        name='OVEHOSTED_RETRY_CREATEVG',
+                        note=_(
+                            'Error creating Volume Group: {message}\n'
+                            'The selected device was probably dirty.\n\n'
+                            'Retry forcing VG creation\n'
+                            '(warning: it can destroy any existing data on '
+                            'the specified device)\n'
+                            "(@VALUES@)[@DEFAULT@]? "
+                        ).format(
+                            message=dom['status']['message']
+                        ),
+                        prompt=True,
+                        validValues=(_('Retry'), _('Abort')),
+                        caseSensitive=False,
+                        default=_('Retry'),
+                    ).lower() == _('Retry').lower()
+                if self.environment[
+                    ohostedcons.StorageEnv.PROMPT_RETRY_CREATEVG
+                ]:
+                    dom = self.cli.createVG(
+                        self.environment[ohostedcons.StorageEnv.SD_UUID],
+                        [
+                            self.environment[ohostedcons.StorageEnv.LUN_ID],
+                        ],
+                        force=True,
+                    )
+                    self.logger.debug(dom)
+                    if dom['status']['code'] != 0:
+                        raise RuntimeError(dom['status']['message'])
+                else:
+                    raise RuntimeError(dom['status']['message'])
             self.environment[
                 ohostedcons.StorageEnv.VG_UUID
             ] = dom['uuid']


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

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

Reply via email to