CLOUDSTACK-4499: Wait until hosts are up before adding storage pools This works around the delay caused in adding Xen 6.1/6.2 hosts where host takes two attempts to transition to Up state. We will wait for one minute per cluster before attempting to add storage pool in the cluster.
Signed-off-by: Prasanna Santhanam <[email protected]> (cherry picked from commit 22ee499c3571b2a6b6921abb36c679128893c415) Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1058654c Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1058654c Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1058654c Branch: refs/heads/ldapplugin Commit: 1058654cb4e3bbc73315d5944541e20fb57eaecc Parents: da6f048 Author: Prasanna Santhanam <[email protected]> Authored: Thu Aug 29 12:33:26 2013 +0530 Committer: Prasanna Santhanam <[email protected]> Committed: Thu Aug 29 14:10:54 2013 +0530 ---------------------------------------------------------------------- tools/marvin/marvin/deployDataCenter.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1058654c/tools/marvin/marvin/deployDataCenter.py ---------------------------------------------------------------------- diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py index 5352029..4c34a50 100644 --- a/tools/marvin/marvin/deployDataCenter.py +++ b/tools/marvin/marvin/deployDataCenter.py @@ -22,6 +22,7 @@ import cloudstackTestClient import logging from cloudstackAPI import * from os import path +from time import sleep from optparse import OptionParser @@ -87,9 +88,28 @@ specify a valid config file" % cfgFile) if cluster.hypervisor.lower() != "vmware": self.addHosts(cluster.hosts, zoneId, podId, clusterId, cluster.hypervisor) + self.wait_for_host(zoneId, clusterId) self.createPrimaryStorages(cluster.primaryStorages, zoneId, podId, clusterId) + def wait_for_host(self, zoneId, clusterId): + """ + Wait for the hosts in the zoneid, clusterid to be up + + 2 retries with 30s delay + """ + retry, timeout = 2, 30 + cmd = listHosts.listHostsCmd() + cmd.clusterid, cmd.zoneid = clusterId, zoneId + hosts = self.apiClient.listHosts(cmd) + while retry != 0: + for host in hosts: + if host.state != 'Up': + break + sleep(timeout) + retry = retry - 1 + + def createPrimaryStorages(self, primaryStorages, zoneId, podId, clusterId): if primaryStorages is None: return
