Merge "Generate only one pair of wwpns when instance has multiple block devices"

This commit is contained in:
Jenkins
2016-05-03 20:53:15 +00:00
committed by Gerrit Code Review
2 changed files with 28 additions and 3 deletions

View File

@@ -248,7 +248,8 @@ class TestNPIVAdapter(test_vol.TestVolumeAdapter):
# Set state to REBUILD_SPAWNING and that should return this is as
# an intial wwpn
self.vol_drv.instance.task_state = task_states.REBUILD_SPAWNING
self.assertTrue(self.vol_drv._is_initial_wwpn(npiv.FS_UNMAPPED, 'a'))
self.assertTrue(self.vol_drv._is_initial_wwpn(npiv.FS_INST_MAPPED,
'a'))
# Set a good task state, but fails due to the WWPNs already being
# hosted
@@ -354,6 +355,27 @@ class TestNPIVAdapter(test_vol.TestVolumeAdapter):
self.assertEqual(1, mock_derive.call_count)
self.assertTrue(self.vol_drv.instance.save.called)
@mock.patch('pypowervm.tasks.vfc_mapper.build_wwpn_pair')
@mock.patch('pypowervm.tasks.vfc_mapper.derive_npiv_map')
@mock.patch('nova_powervm.virt.powervm.volume.npiv.NPIVVolumeAdapter.'
'_get_fabric_meta')
def test_wwpns_on_rebuild(self, mock_fabric_meta, mock_derive,
mock_build):
# Mock Data
mock_derive.return_value = [('21000024FF649104', 'AA BB'),
('21000024FF649105', 'CC DD')]
self.vol_drv.instance.host = CONF.host
self.vol_drv.instance.task_state = task_states.REBUILD_SPAWNING
self.vol_drv.instance.system_metadata = {
self.vol_drv._sys_meta_fabric_key('A'): 'phys1,a,b,phys2,c,d',
self.vol_drv._sys_fabric_state_key('A'): npiv.FS_INST_MAPPED}
# Invoke and Verify
self.assertListEqual(['AA', 'CC'], self.vol_drv.wwpns())
# call again
self.assertListEqual(['AA', 'CC'], self.vol_drv.wwpns())
self.assertEqual(1, mock_fabric_meta.call_count)
@mock.patch('nova_powervm.virt.powervm.volume.npiv.NPIVVolumeAdapter.'
'_get_fabric_state')
def test_wwpns_on_sys_meta(self, mock_fabric_state):

View File

@@ -226,7 +226,8 @@ class NPIVVolumeAdapter(v_driver.FibreChannelVolumeAdapter):
"""
# For RR we generate new wwpns so that the vm on the source loses
# access to the disk if it comes back up again.
if self.instance.task_state == task_states.REBUILD_SPAWNING:
if (self.instance.task_state == task_states.REBUILD_SPAWNING and
fc_state != FS_UNMAPPED):
return True
# Easy fabric state check. If its a state other than unmapped, it
@@ -368,7 +369,9 @@ class NPIVVolumeAdapter(v_driver.FibreChannelVolumeAdapter):
self._set_fabric_meta(fabric, port_maps)
self._set_fabric_state(fabric, FS_UNMAPPED)
self.instance.save()
elif self._is_migration_wwpn(fc_state):
elif self._is_migration_wwpn(fc_state) and not (
self.instance.task_state
in [task_states.REBUILDING, task_states.REBUILD_SPAWNING]):
# The migration process requires the 'second' wwpn from the
# fabric to be used.
port_maps = self._configure_wwpns_for_migration(fabric)