Sandro Bonazzola has uploaded a new change for review.

Change subject: packaging: setup: skip space check on additional hosts
......................................................................

packaging: setup: skip space check on additional hosts

On first host we need to check if we have enough space too.
We must skip this check on additional hosts because the space is
already filled with the Hosted Engine VM image.
Sadly we can't go back to previous customization stage so here
we can only fail the setup.

Change-Id: Ie6dae85998d8f946cca6d1f8ba3750353af002e1
Signed-off-by: Sandro Bonazzola <sbona...@redhat.com>
(cherry picked from commit 176e44585404624c5c290db092dd65668b37e3ea)
---
M src/plugins/ovirt-hosted-engine-setup/storage/nfs.py
1 file changed, 63 insertions(+), 5 deletions(-)


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

diff --git a/src/plugins/ovirt-hosted-engine-setup/storage/nfs.py 
b/src/plugins/ovirt-hosted-engine-setup/storage/nfs.py
index 62fc94f..3e03b05 100644
--- a/src/plugins/ovirt-hosted-engine-setup/storage/nfs.py
+++ b/src/plugins/ovirt-hosted-engine-setup/storage/nfs.py
@@ -147,17 +147,18 @@
                 )
             )
 
-    def _validateDomain(self, connection, domain_type):
+    def _validateDomain(self, connection, domain_type, check_space):
         path = tempfile.mkdtemp()
         try:
             self._mount(path, connection, domain_type)
             self._checker.check_valid_path(path)
             self._check_domain_rights(path)
             self._checker.check_base_writable(path)
-            self._checker.check_available_space(
-                path,
-                ohostedcons.Const.MINIMUM_SPACE_STORAGEDOMAIN_MB
-            )
+            if check_space:
+                self._checker.check_available_space(
+                    path,
+                    ohostedcons.Const.MINIMUM_SPACE_STORAGEDOMAIN_MB
+                )
         finally:
             if self._umount(path) == 0:
                 os.rmdir(path)
@@ -222,6 +223,7 @@
                     domain_type=self.environment[
                         ohostedcons.StorageEnv.DOMAIN_TYPE
                     ],
+                    check_space=False,
                 )
                 validDomain = True
             except (ValueError, RuntimeError) as e:
@@ -267,3 +269,59 @@
                             )
                         )
                     )
+
+    @plugin.event(
+        stage=plugin.Stages.STAGE_CUSTOMIZATION,
+        after=(
+            ohostedcons.Stages.CONFIG_STORAGE_LATE,
+        ),
+        before=(
+            ohostedcons.Stages.DIALOG_TITLES_E_STORAGE,
+        ),
+        condition=(
+            lambda self: (
+                not self.environment[
+                    ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
+                ] and
+                self.environment[ohostedcons.StorageEnv.DOMAIN_TYPE] in (
+                    # ohostedcons.DomainTypes.GLUSTERFS,
+                    ohostedcons.DomainTypes.NFS3,
+                    ohostedcons.DomainTypes.NFS4,
+                )
+            )
+        ),
+    )
+    def _late_customization(self):
+        # On first host we need to check if we have enough space too.
+        # We must skip this check on additional hosts because the space is
+        # already filled with the Hosted Engine VM image.
+        # Sadly we can't go back to previous customization stage so here
+        # we can only fail the setup.
+        try:
+            self._validateDomain(
+                connection=self.environment[
+                    ohostedcons.StorageEnv.STORAGE_DOMAIN_CONNECTION
+                ],
+                domain_type=self.environment[
+                    ohostedcons.StorageEnv.DOMAIN_TYPE
+                ],
+                check_space=True,
+            )
+        except ohosteddomains.InsufficientSpaceError as e:
+            self.logger.debug('exception', exc_info=True)
+            self.logger.debug(e)
+            min_requirement = '%0.2f' % (
+                ohostedcons.Const.MINIMUM_SPACE_STORAGEDOMAIN_MB / 1024.0
+            )
+            raise RuntimeError(
+                _(
+                    'Storage domain for self hosted engine '
+                    'is too small: '
+                    'you should have at least {min_r} GB free'.format(
+                        min_r=min_requirement,
+                    )
+                )
+            )
+
+
+# vim: expandtab tabstop=4 shiftwidth=4


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie6dae85998d8f946cca6d1f8ba3750353af002e1
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: ovirt-hosted-engine-setup-1.2
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