Expect a single host; remove CONF.pvm_host_mtms
The nova-powervm driver will operate on a native management partition which manages only the host on which it resides. There is therefore no need to specify that host's MTMS in the configuration; and it is an error if the PowerVM REST API does not return exactly one host. Change-Id: I0f77add7c09760a54c8d7662bfe3c6810095620b
This commit is contained in:
parent
6149fe1611
commit
2f99f2f4fe
|
@ -23,6 +23,9 @@ import mock
|
|||
from nova_powervm.virt.powervm import driver
|
||||
|
||||
from nova.virt import fake
|
||||
from pypowervm.tests.wrappers.util import pvmhttp
|
||||
|
||||
MS_HTTPRESP_FILE = "managedsystem.txt"
|
||||
|
||||
|
||||
class PyPowerVM(fixtures.Fixture):
|
||||
|
@ -91,8 +94,12 @@ class PowerVMComputeDriver(fixtures.Fixture):
|
|||
pass
|
||||
|
||||
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage')
|
||||
@mock.patch('pypowervm.wrappers.managed_system.find_entry_by_mtms')
|
||||
@mock.patch('nova_powervm.virt.powervm.driver.PowerVMDriver._get_adapter')
|
||||
def _init_host(self, *args):
|
||||
ms_http = pvmhttp.load_pvm_resp(MS_HTTPRESP_FILE).get_response()
|
||||
# Pretend it just returned one host
|
||||
ms_http.feed.entries = [ms_http.feed.entries[0]]
|
||||
self.drv.adapter.read.return_value = ms_http
|
||||
self.drv.init_host('FakeHost')
|
||||
|
||||
def setUp(self):
|
||||
|
@ -103,8 +110,8 @@ class PowerVMComputeDriver(fixtures.Fixture):
|
|||
self.addCleanup(self.pypvm.cleanUp)
|
||||
|
||||
self.drv = driver.PowerVMDriver(fake.FakeVirtAPI())
|
||||
self._init_host()
|
||||
self.drv.adapter = self.pypvm.apt
|
||||
self._init_host()
|
||||
self.drv.image_api = mock.Mock()
|
||||
|
||||
# Set up the mock volume and disk drivers.
|
||||
|
|
|
@ -100,15 +100,6 @@ class TestPowerVMDriver(test.TestCase):
|
|||
self.assertIsNotNone(vol_connector['wwpns'])
|
||||
self.assertIsNotNone(vol_connector['host'])
|
||||
|
||||
@mock.patch('pypowervm.wrappers.managed_system.find_entry_by_mtms')
|
||||
@mock.patch('nova_powervm.virt.powervm.disk.localdisk.LocalStorage')
|
||||
def test_driver_init(self, mock_disk, mock_find):
|
||||
"""Validates the PowerVM driver can be initialized for the host."""
|
||||
drv = driver.PowerVMDriver(fake.FakeVirtAPI())
|
||||
drv.init_host('FakeHost')
|
||||
# Nothing to really check here specific to the host.
|
||||
self.assertIsNotNone(drv)
|
||||
|
||||
@mock.patch('nova_powervm.virt.powervm.vm.get_pvm_uuid')
|
||||
@mock.patch('nova.context.get_admin_context')
|
||||
@mock.patch('nova.objects.flavor.Flavor.get_by_id')
|
||||
|
|
|
@ -40,11 +40,6 @@ pvm_opts = [
|
|||
default='/tmp/cfgdrv/',
|
||||
help='The location where the config drive ISO files should be '
|
||||
'built.'),
|
||||
cfg.StrOpt('pvm_host_mtms',
|
||||
default='',
|
||||
help='The Model Type/Serial Number of the host server to '
|
||||
'manage. Format is MODEL-TYPE*SERIALNUM. Example is '
|
||||
'8286-42A*1234ABC.'),
|
||||
cfg.StrOpt('fc_attach_strategy',
|
||||
default='vscsi',
|
||||
help='The Fibre Channel Volume Strategy defines how FC Cinder '
|
||||
|
|
|
@ -108,12 +108,13 @@ class PowerVMDriver(driver.ComputeDriver):
|
|||
DISK_ADPT_NS, DISK_ADPT_MAPPINGS[CONF.disk_driver], conn_info)
|
||||
|
||||
def _get_host_uuid(self):
|
||||
# Need to get a list of the hosts, then find the matching one
|
||||
resp = self.adapter.read(pvm_ms.System.schema_type)
|
||||
mtms = CONF.pvm_host_mtms
|
||||
self.host_wrapper = pvm_ms.find_entry_by_mtms(resp, mtms)
|
||||
if not self.host_wrapper:
|
||||
raise Exception("Host %s not found" % CONF.pvm_host_mtms)
|
||||
"""Get the System wrapper and its UUID for the (single) host."""
|
||||
syswraps = pvm_ms.System.wrap(
|
||||
self.adapter.read(pvm_ms.System.schema_type))
|
||||
if len(syswraps) != 1:
|
||||
raise Exception(
|
||||
_("Expected exactly one host; found %d"), len(syswraps))
|
||||
self.host_wrapper = syswraps[0]
|
||||
self.host_uuid = self.host_wrapper.uuid
|
||||
LOG.info(_LI("Host UUID is:%s") % self.host_uuid)
|
||||
|
||||
|
|
Loading…
Reference in New Issue