Use hypervisor_hostname for host name

In Nova, "service host" is where nova-compute is running and
"hypervisor_hostname" represent each physical node that the virt
driver reports. They can be different in some of the hypervisor
backends where one nova-compute corresponds to multiple physical
nodes. Blazar holds the values separately as "service_name" and
"hypervisor_hostname".

Since Nova aggreate is associated to nova-compute service, we used
"service_name" with aggregate solution for reservation. However, now
we can use "hypervisor_hostname" with placement api solution for
reservation. This patch switches it.

Change-Id: I0e089c764e81894f065872e7b44a4ea8cfa49bd6
Closes-Bug: #1814594
This commit is contained in:
Tetsuro Nakamura 2019-01-23 17:06:13 +00:00 committed by Pierre Riteau
parent a75fb5f478
commit 7dc9a6a7bf
3 changed files with 18 additions and 13 deletions

View File

@ -301,7 +301,7 @@ class VirtualInstancePlugin(base.BasePlugin, nova.NovaClientWrapper):
% (host, reservation['aggregate_id']))
raise mgr_exceptions.NovaClientError(err_msg)
self.placement_client.update_reservation_inventory(
host['service_name'], reservation['id'], 1)
host['hypervisor_hostname'], reservation['id'], 1)
else:
try:
self.nova.nova.flavors.delete(reservation['id'])
@ -472,7 +472,7 @@ class VirtualInstancePlugin(base.BasePlugin, nova.NovaClientWrapper):
pool.add_computehost(instance_reservation['aggregate_id'],
host['service_name'], stay_in=True)
self.placement_client.update_reservation_inventory(
host['service_name'], reservation_id, 1)
host['hypervisor_hostname'], reservation_id, 1)
def on_end(self, resource_id):
instance_reservation = db_api.instance_reservation_get(resource_id)
@ -492,7 +492,7 @@ class VirtualInstancePlugin(base.BasePlugin, nova.NovaClientWrapper):
db_api.host_allocation_destroy(allocation['id'])
try:
self.placement_client.delete_reservation_inventory(
host['service_name'], reservation_id)
host['hypervisor_hostname'], reservation_id)
except openstack_ex.ResourceProviderNotFound:
pass
@ -559,7 +559,7 @@ class VirtualInstancePlugin(base.BasePlugin, nova.NovaClientWrapper):
host['service_name'])
try:
self.placement_client.delete_reservation_inventory(
host['service_name'], reservation['id'])
host['hypervisor_hostname'], reservation['id'])
except openstack_ex.ResourceProviderNotFound:
pass
@ -590,7 +590,7 @@ class VirtualInstancePlugin(base.BasePlugin, nova.NovaClientWrapper):
new_host['service_name'],
stay_in=True)
self.placement_client.update_reservation_inventory(
new_host['service_name'], reservation['id'], 1)
new_host['hypervisor_hostname'], reservation['id'], 1)
LOG.warn('Resource changed for reservation %s (lease: %s).',
reservation['id'], lease['name'])

View File

@ -362,7 +362,7 @@ class PhysicalHostPlugin(base.BasePlugin, nova.NovaClientWrapper):
raise manager_ex.ExtraCapabilityTooLong()
self.placement_client.create_reservation_provider(
host_details['service_name'])
host_details['hypervisor_hostname'])
pool = nova.ReservationPool()
pool.add_computehost(self.freepool_name,
@ -381,7 +381,7 @@ class PhysicalHostPlugin(base.BasePlugin, nova.NovaClientWrapper):
pool.remove_computehost(self.freepool_name,
host_details['service_name'])
self.placement_client.delete_reservation_provider(
host_details['service_name'])
host_details['hypervisor_hostname'])
raise e
for key in extra_capabilities:
values = {'computehost_id': host['id'],
@ -495,7 +495,7 @@ class PhysicalHostPlugin(base.BasePlugin, nova.NovaClientWrapper):
pool.remove_computehost(self.freepool_name,
host['service_name'])
self.placement_client.delete_reservation_provider(
host['service_name'])
host['hypervisor_hostname'])
# NOTE(sbauza): Extracapabilities will be destroyed thanks to
# the DB FK.
db_api.host_destroy(host_id)

View File

@ -686,7 +686,8 @@ class TestVirtualInstancePlugin(tests.TestCase):
def test_update_resources_in_active(self):
def fake_host_get(host_id):
return {'service_name': 'host' + host_id[-1]}
return {'service_name': 'host' + host_id[-1],
'hypervisor_hostname': 'host' + host_id[-1]}
reservation = {
'id': 'reservation-id1',
@ -851,7 +852,8 @@ class TestVirtualInstancePlugin(tests.TestCase):
def test_on_start(self):
def fake_host_get(host_id):
return {'service_name': 'host' + host_id[-1]}
return {'service_name': 'host' + host_id[-1],
'hypervisor_hostname': 'host' + host_id[-1]}
self.set_context(context.BlazarContext(project_id='fake-project'))
plugin = instance_plugin.VirtualInstancePlugin()
@ -907,7 +909,8 @@ class TestVirtualInstancePlugin(tests.TestCase):
mock_host_get = self.patch(db_api, 'host_get')
mock_host_get.side_effect = [
{'service_name': 'host1'}, {'service_name': 'host2'}
{'service_name': 'host1', 'hypervisor_hostname': 'host1'},
{'service_name': 'host2', 'hypervisor_hostname': 'host2'}
]
mock_delete_reservation_inventory = self.patch(
@ -1133,9 +1136,11 @@ class TestVirtualInstancePlugin(tests.TestCase):
def test_reallocate_active(self):
plugin = instance_plugin.VirtualInstancePlugin()
failed_host = {'id': '1',
'service_name': 'compute-1'}
'service_name': 'compute-1',
'hypervisor_hostname': 'compute-1'}
new_host = {'id': '2',
'service_name': 'compute-2'}
'service_name': 'compute-2',
'hypervisor_hostname': 'compute-2'}
dummy_allocation = {
'id': 'alloc-1',
'compute_host_id': failed_host['id'],