Remove host_uuid from config drive paths

host_uuid is no longer required to be passed to the pypowervm APIs
dealing with config drive and VSCSI mappings.  This allows us to remove
that parameter from the config drive Task chains.

Change-Id: I0734d17dc4d28e7daedabffce4c41c848ebc8cfb
This commit is contained in:
Eric Fried
2017-08-28 17:36:41 -05:00
parent f0db350243
commit 8c2fadba78
6 changed files with 36 additions and 41 deletions

View File

@@ -41,10 +41,10 @@ class TestStorage(test.TestCase):
# Test with no FeedTask
task = tf_stg.CreateAndConnectCfgDrive(
self.adapter, 'host_uuid', self.instance, 'injected_files',
self.adapter, self.instance, 'injected_files',
'network_info', 'admin_pass')
task.execute(lpar_w, 'mgmt_cna')
self.mock_cfg_drv.assert_called_once_with(self.adapter, 'host_uuid')
self.mock_cfg_drv.assert_called_once_with(self.adapter)
self.mock_mb.create_cfg_drv_vopt.assert_called_once_with(
self.instance, 'injected_files', 'network_info', lpar_w.uuid,
admin_pass='admin_pass', mgmt_cna='mgmt_cna', stg_ftsk=None)
@@ -67,10 +67,10 @@ class TestStorage(test.TestCase):
# With a specified FeedTask
task = tf_stg.CreateAndConnectCfgDrive(
self.adapter, 'host_uuid', self.instance, 'injected_files',
self.adapter, self.instance, 'injected_files',
'network_info', 'admin_pass', stg_ftsk='stg_ftsk')
task.execute(lpar_w, 'mgmt_cna')
self.mock_cfg_drv.assert_called_once_with(self.adapter, 'host_uuid')
self.mock_cfg_drv.assert_called_once_with(self.adapter)
self.mock_mb.create_cfg_drv_vopt.assert_called_once_with(
self.instance, 'injected_files', 'network_info', lpar_w.uuid,
admin_pass='admin_pass', mgmt_cna='mgmt_cna', stg_ftsk='stg_ftsk')
@@ -80,22 +80,26 @@ class TestStorage(test.TestCase):
task.revert(lpar_w, 'mgmt_cna', 'result', 'flow_failures')
self.mock_mb.assert_not_called()
def test_delete_vopt(self):
@mock.patch('nova_powervm.virt.powervm.vm.get_pvm_uuid')
def test_delete_vopt(self, mock_pvm_uuid):
# Test with no FeedTask
task = tf_stg.DeleteVOpt(self.adapter, 'huuid', self.instance, 'luuid')
mock_pvm_uuid.return_value = 'pvm_uuid'
task = tf_stg.DeleteVOpt(self.adapter, self.instance)
task.execute()
self.mock_cfg_drv.assert_called_once_with(self.adapter, 'huuid')
self.mock_mb.dlt_vopt.assert_called_once_with('luuid', stg_ftsk=None)
self.mock_cfg_drv.assert_called_once_with(self.adapter)
self.mock_mb.dlt_vopt.assert_called_once_with(
'pvm_uuid', stg_ftsk=None)
self.mock_cfg_drv.reset_mock()
self.mock_mb.reset_mock()
# With a specified FeedTask
task = tf_stg.DeleteVOpt(self.adapter, 'huuid', self.instance, 'luuid',
task = tf_stg.DeleteVOpt(self.adapter, self.instance,
stg_ftsk='ftsk')
task.execute()
self.mock_cfg_drv.assert_called_once_with(self.adapter, 'huuid')
self.mock_mb.dlt_vopt.assert_called_once_with('luuid', stg_ftsk='ftsk')
self.mock_cfg_drv.assert_called_once_with(self.adapter)
self.mock_mb.dlt_vopt.assert_called_once_with(
'pvm_uuid', stg_ftsk='ftsk')
def test_delete_disk(self):
stor_adpt_mappings = mock.Mock()

View File

@@ -43,7 +43,7 @@ class TestConfigDrivePowerVM(test.TestCase):
@mock.patch('nova.virt.configdrive.ConfigDriveBuilder.make_drive')
def test_crt_cfg_dr_iso(self, mock_mkdrv, mock_meta):
"""Validates that the image creation method works."""
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt, 'host_uuid')
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt)
mock_instance = mock.MagicMock()
mock_instance.name = 'fake-instance'
mock_instance.uuid = '1e46bbfd-73b6-3c2a-aeab-a1d3f065e92f'
@@ -92,7 +92,7 @@ class TestConfigDrivePowerVM(test.TestCase):
mock_upld.return_value = (mock.Mock(), None)
# Run
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt, 'fake_host')
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt)
cfg_dr_builder.create_cfg_drv_vopt(mock.MagicMock(), mock.MagicMock(),
mock.MagicMock(), 'fake_lpar')
self.assertTrue(mock_upld.called)
@@ -107,7 +107,7 @@ class TestConfigDrivePowerVM(test.TestCase):
mock_add_map):
# Create objects to test with
mock_instance = mock.MagicMock(name='fake-instance')
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt, 'fake_host')
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt)
vopt = mock.Mock()
mock_vios = mock.Mock(spec=pvm_vios.VIOS)
mock_vios.configure_mock(name='vios name')
@@ -121,7 +121,7 @@ class TestConfigDrivePowerVM(test.TestCase):
mock_wrapper_task.add_functor_subtask.side_effect = call_param
def validate_build(host_uuid, vios_w, lpar_uuid, vopt_elem):
self.assertEqual('fake_host', host_uuid)
self.assertEqual(None, host_uuid)
self.assertIsInstance(vios_w, pvm_vios.VIOS)
self.assertEqual('lpar_uuid', lpar_uuid)
self.assertEqual(vopt, vopt_elem)
@@ -147,7 +147,7 @@ class TestConfigDrivePowerVM(test.TestCase):
network_info = [{'type': 'lbr'}, {'type': 'pvm_sea'},
{'type': 'ovs'}]
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt, 'fake_host')
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt)
resp = cfg_dr_builder._sanitize_network_info(network_info)
expected_ret = [{'type': 'vif'}, {'type': 'vif'},
@@ -159,7 +159,7 @@ class TestConfigDrivePowerVM(test.TestCase):
mock_cna.mac = "FAD4433ED120"
# Run
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt, 'fake_host')
cfg_dr_builder = m.ConfigDrivePowerVM(self.apt)
vif = cfg_dr_builder._mgmt_cna_to_vif(mock_cna)
# Validate
@@ -201,7 +201,7 @@ class TestConfigDrivePowerVM(test.TestCase):
mock_find_maps.return_value = []
# Invoke the operation
cfg_dr = m.ConfigDrivePowerVM(self.apt, 'fake_host')
cfg_dr = m.ConfigDrivePowerVM(self.apt)
cfg_dr.dlt_vopt('2', remove_mappings=False)
# Verify expected methods were called
@@ -214,7 +214,7 @@ class TestConfigDrivePowerVM(test.TestCase):
@mock.patch('pypowervm.tasks.scsi_mapper.find_maps')
def test_add_dlt_vopt_tasks(self, mock_find_maps, mock_gen_match_func):
# Init objects to test with
cfg_dr = m.ConfigDrivePowerVM(self.apt, 'fake_host')
cfg_dr = m.ConfigDrivePowerVM(self.apt)
stg_ftsk = mock.MagicMock()
cfg_dr.vios_uuid = 'vios_uuid'
lpar_uuid = 'lpar_uuid'

View File

@@ -432,7 +432,7 @@ class PowerVMDriver(driver.ComputeDriver):
# after all the other I/O.
if configdrive.required_by(instance) and not recreate:
flow_spawn.add(tf_stg.CreateAndConnectCfgDrive(
self.adapter, self.host_uuid, instance, injected_files,
self.adapter, instance, injected_files,
network_info, admin_password, stg_ftsk=stg_ftsk))
# Add the transaction manager flow to the end of the 'I/O
@@ -591,8 +591,7 @@ class PowerVMDriver(driver.ComputeDriver):
# manager.
if configdrive.required_by(instance):
flow.add(tf_stg.DeleteVOpt(
self.adapter, self.host_uuid, instance, pvm_inst_uuid,
stg_ftsk=stg_ftsk))
self.adapter, instance, stg_ftsk=stg_ftsk))
# Determine if there are volumes to disconnect. If so, remove each
# volume (within the transaction manager)

View File

@@ -317,9 +317,8 @@ class LiveMigrationSrc(LiveMigration):
stg_ftsk = stor_task.ScrubOrphanStorageForLpar(self.drvr.adapter,
lpar_w.id)
# Add subtasks to remove the VOpt devices under the same FeedTask.
media.ConfigDrivePowerVM(self.drvr.adapter, self.drvr.host_uuid
).dlt_vopt(lpar_w.uuid, stg_ftsk=stg_ftsk,
remove_mappings=False)
media.ConfigDrivePowerVM(self.drvr.adapter).dlt_vopt(
lpar_w.uuid, stg_ftsk=stg_ftsk, remove_mappings=False)
# Now execute the FeedTask, performing both scrub and VOpt removal.
stg_ftsk.execute()

View File

@@ -50,14 +50,12 @@ CFG_DRV_SUFFIX = ".iso"
class ConfigDrivePowerVM(object):
def __init__(self, adapter, host_uuid):
def __init__(self, adapter):
"""Creates the config drive manager for PowerVM.
:param adapter: The pypowervm adapter to communicate with the system.
:param host_uuid: The UUID of the host system.
"""
self.adapter = adapter
self.host_uuid = host_uuid
# Validate that the virtual optical exists
self.vios_uuid, self.vg_uuid = tsk_vopt.validate_vopt_repo_exists(
@@ -210,7 +208,7 @@ class ConfigDrivePowerVM(object):
def add_func(vios_w):
LOG.info("Adding config drive mapping to Virtual I/O Server "
"%(vios)s", {'vios': vios_w.name}, instance=instance)
mapping = tsk_map.build_vscsi_mapping(self.host_uuid, vios_w,
mapping = tsk_map.build_vscsi_mapping(None, vios_w,
lpar_uuid, vopt)
return tsk_map.add_map(vios_w, mapping)

View File

@@ -24,6 +24,7 @@ from nova_powervm.virt.powervm.disk import driver as disk_driver
from nova_powervm.virt.powervm import exception as npvmex
from nova_powervm.virt.powervm import media
from nova_powervm.virt.powervm import mgmt
from nova_powervm.virt.powervm import vm
LOG = logging.getLogger(__name__)
@@ -337,7 +338,7 @@ class CreateAndConnectCfgDrive(task.Task):
"""The task to create the configuration drive."""
def __init__(self, adapter, host_uuid, instance, injected_files,
def __init__(self, adapter, instance, injected_files,
network_info, admin_pass, stg_ftsk=None):
"""Create the Task that create and connect the config drive.
@@ -346,7 +347,6 @@ class CreateAndConnectCfgDrive(task.Task):
the vscsi drive.
:param adapter: The adapter for the pypowervm API
:param host_uuid: The host UUID of the system.
:param instance: The nova instance
:param injected_files: A list of file paths that will be injected into
the ISO.
@@ -362,7 +362,6 @@ class CreateAndConnectCfgDrive(task.Task):
super(CreateAndConnectCfgDrive, self).__init__(
'cfg_drive', requires=['lpar_wrap', 'mgmt_cna'])
self.adapter = adapter
self.host_uuid = host_uuid
self.instance = instance
self.injected_files = injected_files
self.network_info = network_info
@@ -371,7 +370,7 @@ class CreateAndConnectCfgDrive(task.Task):
self.stg_ftsk = stg_ftsk
def execute(self, lpar_wrap, mgmt_cna):
self.mb = media.ConfigDrivePowerVM(self.adapter, self.host_uuid)
self.mb = media.ConfigDrivePowerVM(self.adapter)
self.mb.create_cfg_drv_vopt(self.instance, self.injected_files,
self.network_info, lpar_wrap.uuid,
admin_pass=self.ad_pass,
@@ -397,14 +396,11 @@ class DeleteVOpt(task.Task):
"""The task to delete the virtual optical."""
def __init__(self, adapter, host_uuid, instance, lpar_uuid,
stg_ftsk=None):
def __init__(self, adapter, instance, stg_ftsk=None):
"""Creates the Task to delete the instances virtual optical media.
:param adapter: The adapter for the pypowervm API
:param host_uuid: The host UUID of the system.
:param instance: The nova instance.
:param lpar_uuid: The UUID of the lpar that has media.
:param stg_ftsk: (Optional) The pypowervm transaction FeedTask for the
I/O Operations. If provided, the Virtual I/O Server
mapping updates will be added to the FeedTask. This
@@ -414,14 +410,13 @@ class DeleteVOpt(task.Task):
"""
super(DeleteVOpt, self).__init__('vopt_delete')
self.adapter = adapter
self.host_uuid = host_uuid
self.instance = instance
self.lpar_uuid = lpar_uuid
self.stg_ftsk = stg_ftsk
def execute(self):
media_builder = media.ConfigDrivePowerVM(self.adapter, self.host_uuid)
media_builder.dlt_vopt(self.lpar_uuid, stg_ftsk=self.stg_ftsk)
media_builder = media.ConfigDrivePowerVM(self.adapter)
media_builder.dlt_vopt(vm.get_pvm_uuid(self.instance),
stg_ftsk=self.stg_ftsk)
class DetachDisk(task.Task):