diff --git a/fabfile/tasks/provision.py b/fabfile/tasks/provision.py index a7c5f9de1..103eddd28 100644 --- a/fabfile/tasks/provision.py +++ b/fabfile/tasks/provision.py @@ -923,14 +923,19 @@ def setup_nova_aggregate_node(*args): while retry: with settings(warn_only=True): aggregate_list = sudo("(source /etc/contrail/openstackrc; nova aggregate-list)") - if aggregate_list.failed: - sleep(6) - retry -= 1 - continue - break - if hypervisor not in aggregate_list: - sudo("(source /etc/contrail/openstackrc; nova aggregate-create %s nova/%s)" % (hypervisor, hypervisor)) - sudo("(source /etc/contrail/openstackrc; nova aggregate-add-host %s %s)" % (hypervisor, host_name)) + if aggregate_list.failed: # Services might be starting up after reboot + sleep(6) + retry -= 1 + continue + aggregate_details = sudo("(source /etc/contrail/openstackrc;nova aggregate-details %s)" % hypervisor) + if host_name not in aggregate_details: + if hypervisor not in aggregate_list: + create = sudo("(source /etc/contrail/openstackrc; nova aggregate-create %s nova/%s)" % (hypervisor, hypervisor)) + if create.failed: # Services might be starting up after reboot + continue + if sudo("(source /etc/contrail/openstackrc; nova aggregate-add-host %s %s)" % (hypervisor, host_name)).failed: + continue # Services might be starting up after reboot + break # Stop retrying as the aggregate is created and compute is added. @roles('openstack') @task