Yedidyah Bar David has uploaded a new change for review.

Change subject: packaging: setup: wait for cluster to become ready
......................................................................

packaging: setup: wait for cluster to become ready

Change-Id: I6a6fb4bdafe37e363aefae11a2655a4189ae2ecb
Bug-Url: https://bugzilla.redhat.com/1048479
Signed-off-by: Yedidyah Bar David <d...@redhat.com>
---
M src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
1 file changed, 26 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-setup 
refs/changes/55/22955/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 1425a1d..a235aac 100644
--- a/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
+++ b/src/plugins/ovirt-hosted-engine-setup/engine/add_host.py
@@ -241,6 +241,31 @@
             ))
         return isUp
 
+    def _wait_cluster_cpu_ready(self, cluster):
+        tries = self.VDSM_RETRIES
+        cpu = None
+        while cpu is None and tries > 0:
+            tries -= 1
+            cpu = cluster.get_cpu()
+            if cpu is None:
+                self.logger.debug(
+                    'cluster {cluster} cluster.__dict__ {cdict}'.format(
+                        cluster=cluster,
+                        cdict=cluster.__dict__,
+                    )
+                )
+                if tries % 30 == 0:
+                    self.logger.info(_(
+                        'Waiting for default cluster to become operational...'
+                    ))
+                time.sleep(self.VDSM_DELAY)
+        if cpu is None and tries == 0:
+            self.logger.error(_(
+                'Timed out while waiting for cluster to become ready. '
+                'Please check the logs.'
+            ))
+        return cpu
+
     @plugin.event(
         stage=plugin.Stages.STAGE_INIT,
     )
@@ -434,7 +459,7 @@
             try:
                 cluster = engine_api.clusters.get('Default')
                 self.logger.debug(cluster.__dict__)
-                cpu = cluster.get_cpu()
+                cpu = self._wait_cluster_cpu_ready(cluster)
                 self.logger.debug(cpu.__dict__)
                 cpu.set_id(self.environment[ohostedcons.VDSMEnv.ENGINE_CPU])
                 cluster.set_cpu(cpu)


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a6fb4bdafe37e363aefae11a2655a4189ae2ecb
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-setup
Gerrit-Branch: master
Gerrit-Owner: Yedidyah Bar David <d...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to