Skip to content

Commit

Permalink
Merge "make sure that the nova aggregate is created in a hybrid(libvi…
Browse files Browse the repository at this point in the history
…rt/docker) setup with proper hostname(short/full) name. Closes-Bug: 1484461" into R2.22-dev
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Aug 26, 2015
2 parents 286080f + b35deeb commit d4b8294
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions fabfile/tasks/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,36 +1005,45 @@ def setup_nova_aggregate():
def setup_nova_aggregate_node(*args):
for compute_host in env.roledefs['compute']:
hypervisor = get_hypervisor(compute_host)
host_name = None
host_names = None
for i in range(5):
try:
host_name = socket.gethostbyaddr(
hstr_to_ip(compute_host))[0].split('.')[0]
host_names = socket.gethostbyaddr(hstr_to_ip(compute_host))[:2]
host_names = [host_names[0], host_names[1][0]]
except socket.herror:
sleep(5)
continue
else:
break
if not host_name:
raise RuntimeError("Not able to get the hostname of compute host:%s", compute_host)
if not host_names:
raise RuntimeError("Not able to get the hostname of compute host:%s" % compute_host)
if hypervisor == 'docker':
env_vars = 'source /etc/contrail/openstackrc'
retry = 10
while retry:
with settings(warn_only=True):
aggregate_list = sudo("(source /etc/contrail/openstackrc; nova aggregate-list)")
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.
with settings(warn_only=True, prefix='source /etc/contrail/openstackrc'):
with prefix('source /etc/contrail/openstackrc'):
#aggregate_list = sudo("(%s; nova aggregate-list)" % env_vars)
aggregate_list = sudo("(nova aggregate-list)")
if aggregate_list.failed: # Services might be starting up after reboot
sleep(6)
retry -= 1
continue
for host_name in host_names:
if sudo("nova host-describe %s" % (host_name)).succeeded:
# This is the host_name known to nova api
break
else:
raise RuntimeError("Both hostnames %s are not known to nova api" % host_names)
aggregate_details = sudo("(nova aggregate-details %s)" % (hypervisor))
if host_name not in aggregate_details:
if hypervisor not in aggregate_list:
create = sudo("(nova aggregate-create %s nova/%s)" % (hypervisor, hypervisor))
if create.failed: # Services might be starting up after reboot
continue
if sudo("(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
Expand Down

0 comments on commit d4b8294

Please sign in to comment.