Use CONF.host for powervm nodename

The get_available_nodes method of the powervm virt driver was
returning a string based on the machine type, model, and serial
number of the host. This was inconsistent with other drivers. It also
required a working NovaLink connection, which cannot be guaranteed.
This change replaces the MTMS string with CONF.host.

The same change was made to the in-tree driver with nova commits
f2e8244e169ed2ecb8e06e76de1755033be87f21 and
de5b7d8f257ba89d5f3dab805f8e49ffc6eda4aa

Change-Id: Id41c4576c32e7e8cf6b2c3c2020303f87ecaf3d3
This commit is contained in:
Matthew Edmonds 2017-06-15 18:33:39 -04:00
parent 74f92e1397
commit f5b61f15d4
4 changed files with 12 additions and 7 deletions

View File

@ -138,6 +138,10 @@ class TestPowerVMDriver(test.TestCase):
self.inst_ibmi = objects.Instance(**powervm.TEST_INST_SPAWNING)
self.inst_ibmi.system_metadata = {'image_os_distro': 'ibmi'}
def test_get_available_nodes(self):
self.flags(host='hostname')
self.assertEqual(['hostname'], self.drv.get_available_nodes('node'))
def test_driver_capabilities(self):
"""Test the default capabilities."""
test_driver = driver.PowerVMDriver(fake.FakeVirtAPI())

View File

@ -23,7 +23,6 @@ from oslo_serialization import jsonutils
import pypowervm.tests.test_fixtures as pvm_fx
from pypowervm.wrappers import iocard as pvm_card
from pypowervm.wrappers import managed_system as pvm_ms
from pypowervm.wrappers import mtms as pvm_mtms
from nova_powervm.virt.powervm import host as pvm_host
@ -50,8 +49,6 @@ class TestPowerVMHost(test.NoDBTestCase):
mock_sriov(1, [mock_pport(2, 'foo', 1), mock_pport(3, '', 2)]),
mock_sriov(4, [mock_pport(5, 'bar', 3)])]
ms_wrapper = mock.create_autospec(pvm_ms.System, spec_set=True)
mtms = mock.create_autospec(pvm_mtms.MTMS, spec_set=True)
mtms.configure_mock(mtms_str='8484923A123456')
asio = mock.create_autospec(pvm_ms.ASIOConfig, spec_set=True)
asio.configure_mock(sriov_adapters=sriov_adaps)
ms_wrapper.configure_mock(
@ -59,9 +56,9 @@ class TestPowerVMHost(test.NoDBTestCase):
proc_units_avail=500,
memory_configurable=5242880,
memory_free=5242752,
mtms=mtms,
memory_region_size='big',
asio_config=asio)
self.flags(host='the_hostname')
# Run the actual test
stats = pvm_host.build_host_resource_from_ms(ms_wrapper)
@ -71,7 +68,7 @@ class TestPowerVMHost(test.NoDBTestCase):
fields = (('vcpus', 500), ('vcpus_used', 0),
('memory_mb', 5242880), ('memory_mb_used', 128),
'hypervisor_type', 'hypervisor_version',
'hypervisor_hostname', 'cpu_info',
('hypervisor_hostname', 'the_hostname'), 'cpu_info',
'supported_instances', 'stats', 'pci_passthrough_devices')
for fld in fields:
if isinstance(fld, tuple):

View File

@ -69,6 +69,7 @@ from nova_powervm.virt.powervm.tasks import vm as tf_vm
from nova_powervm.virt.powervm import vm
from nova_powervm.virt.powervm import volume as vol_attach
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
@ -1048,7 +1049,7 @@ class PowerVMDriver(driver.ComputeDriver):
[hypervisor_hostname].
"""
return [self.host_wrapper.mtms.mtms_str]
return [CONF.host]
def legacy_nwinfo(self):
"""Indicate if the driver requires the legacy network_info format."""

View File

@ -22,9 +22,12 @@ from oslo_serialization import jsonutils
from pypowervm.tasks.monitor import util as pcm_util
import subprocess
from nova import conf as cfg
from nova_powervm.virt.powervm.i18n import _LW
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
# Power VM hypervisor info
# Normally, the hypervisor version is a string in the form of '8.0.0' and
@ -70,7 +73,7 @@ def build_host_resource_from_ms(ms_wrapper):
data["hypervisor_type"] = fields.HVType.PHYP
data["hypervisor_version"] = IBM_POWERVM_HYPERVISOR_VERSION
data["hypervisor_hostname"] = ms_wrapper.mtms.mtms_str
data["hypervisor_hostname"] = CONF.host
data["cpu_info"] = HOST_STATS_CPU_INFO
data["numa_topology"] = None
data["supported_instances"] = POWERVM_SUPPORTED_INSTANCES