Simone Tiraboschi has uploaded a new change for review.

Change subject: packaging: setup: enforcing required networks configuration 
additional hosts
......................................................................

packaging: setup: enforcing required networks configuration additional hosts

On additional hosts, waiting for the user to configure
the additional required networks before checking
host status.

Change-Id: I259b78e6a5c3009c29a7e3c8573500f12247acbc
Bug-Url: https://bugzilla.redhat.com/1086032
Signed-off-by: Simone Tiraboschi <stira...@redhat.com>
(cherry picked from commit 5406ce6525f79ddf9ac38bd4a06c2e62a206bae6)
---
M src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
1 file changed, 57 insertions(+), 1 deletion(-)


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

diff --git a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py 
b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
index ca6d269..879f3a8 100644
--- a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
+++ b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
@@ -205,6 +205,7 @@
             'Waiting for the host to become operational in the engine. '
             'This may take several minutes...'
         ))
+
         tries = self.VDSM_RETRIES
         isUp = False
         while not isUp and tries > 0:
@@ -245,6 +246,56 @@
                 'Please check the logs.'
             ))
         return isUp
+
+    def _check_network_configuration(self, engine_api, host):
+        try:
+            cluster = engine_api.clusters.get(
+                self.environment[
+                    ohostedcons.EngineEnv.HOST_CLUSTER_NAME
+                ]
+            )
+            h = engine_api.hosts.get(host)
+            required_networks = set(
+                [
+                    rn.get_id()
+                    for rn in cluster.networks.list(required=True)
+                ]
+            )
+            configured_networks = set(
+                [
+                    nic.get_network().get_id()
+                    for nic in h.nics.list()
+                    if nic.get_network()
+                ]
+            )
+            if (
+                len(required_networks) > 1 and
+                required_networks > configured_networks
+            ):
+                tbc = required_networks - configured_networks
+                rnet = [
+                    engine_api.networks.get(id=rn).get_name() for rn in tbc
+                ]
+                self.dialog.note(
+                    _(
+                        '\nThe following required networks\n'
+                        '  {rnet}\n'
+                        'still need to be configured on {host} '
+                        'in order to make it\n'
+                        'operational. Please setup them via the engine '
+                        'webadmin UI or flag them as not required.\n'
+                    ).format(
+                        rnet=rnet,
+                        host=host,
+                    )
+                )
+        except Exception as exc:
+            # Sadly all ovirtsdk errors inherit only from Exception
+            self.logger.debug(
+                'Error fetching the network configuration: {error}'.format(
+                    error=str(exc),
+                )
+            )
 
     def _wait_cluster_cpu_ready(self, engine_api, cluster_name):
         tries = self.VDSM_RETRIES
@@ -518,9 +569,14 @@
                 )
             )
 
-        if not self.environment[
+        if self.environment[
             ohostedcons.CoreEnv.IS_ADDITIONAL_HOST
         ]:
+            self._check_network_configuration(
+                engine_api,
+                self.environment[ohostedcons.EngineEnv.APP_HOST_NAME],
+            )
+        else:
             up = self._wait_host_ready(
                 engine_api,
                 self.environment[ohostedcons.EngineEnv.APP_HOST_NAME]


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

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