Fix up adding availability zone (AZ) to a host on creation

1. Nova AZ returns hosts as service hosts as opposed to hypervisor
   hostnames
2. Handle case where a Nova AZ has no hosts

Change-Id: If6f6cf21170e95c58dd8a0a1b41b9b5f4797a627
Closes-Bug: #1880646
This commit is contained in:
Sam Morrison 2020-05-26 16:29:27 +10:00 committed by Pierre Riteau
parent 9cb7f6b52b
commit 532544efbf
3 changed files with 9 additions and 3 deletions

View File

@ -448,7 +448,7 @@ class FakeNovaHypervisors(object):
class FakeHost(object):
id = 1
availability_zone = 'fake_az1'
hypervisor_hostname = 'fake_name'
hypervisor_hostname = 'fake_name.openstack.org'
vcpus = 1
cpu_info = 'fake_cpu'
hypervisor_type = 'fake_type'

View File

@ -478,9 +478,9 @@ class NovaInventory(NovaClientWrapper):
az_name = ''
if CONF.nova.az_aware:
host_name = hypervisor.hypervisor_hostname
host_name = hypervisor.service['host']
for zone in self.nova.availability_zones.list(detailed=True):
if (host_name in zone.hosts
if (zone.hosts and host_name in zone.hosts
and 'nova-compute' in zone.hosts[host_name]):
az_name = zone.zoneName

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixes host creation in the presence of availability zones with no hosts.
For more details, see `bug 1880646
<https://bugs.launchpad.net/blazar/+bug/1880646>`_.