diff --git a/nova_powervm/tests/virt/powervm/volume/test_fileio.py b/nova_powervm/tests/virt/powervm/volume/test_fileio.py index a250d60b..d12fd17c 100644 --- a/nova_powervm/tests/virt/powervm/volume/test_fileio.py +++ b/nova_powervm/tests/virt/powervm/volume/test_fileio.py @@ -49,8 +49,10 @@ class TestFileIOVolumeAdapter(test_vol.TestVolumeAdapter): self.adpt = self.useFixture(pvm_fx.AdapterFx()).adpt mock_inst = mock.MagicMock(uuid='2BC123') - self.vol_drv = FakeFileIOVolAdapter(self.adpt, 'host_uuid', mock_inst, - dict(serial='volid1')) + self.vol_drv = FakeFileIOVolAdapter( + self.adpt, 'host_uuid', mock_inst, + {'data': {'volume_id': 'a_vol_id'}, + 'serial': 'volid1'}) self.fake_vios = pvm_vios.VIOS.bld( self.adpt, 'vios1', @@ -96,7 +98,7 @@ class TestFileIOVolumeAdapter(test_vol.TestVolumeAdapter): # Validate mock_file_bld.assert_called_once_with( self.adpt, 'fake_path', - backstore_type=pvm_stg.BackStoreType.FILE_IO) + backstore_type=pvm_stg.BackStoreType.FILE_IO, tag='a_vol_id') self.assertEqual(1, mock_build_map.call_count) self.assertEqual(1, mock_udid_to_map.call_count) @@ -128,7 +130,7 @@ class TestFileIOVolumeAdapter(test_vol.TestVolumeAdapter): # Validate mock_file_bld.assert_called_once_with( self.adpt, 'fake_path', - backstore_type=pvm_stg.BackStoreType.FILE_IO) + backstore_type=pvm_stg.BackStoreType.FILE_IO, tag='a_vol_id') self.assertEqual(0, mock_build_map.call_count) @mock.patch('pypowervm.tasks.partition.get_mgmt_partition', autospec=True) diff --git a/nova_powervm/tests/virt/powervm/volume/test_iscsi.py b/nova_powervm/tests/virt/powervm/volume/test_iscsi.py index 49ebdf30..37aec3ed 100644 --- a/nova_powervm/tests/virt/powervm/volume/test_iscsi.py +++ b/nova_powervm/tests/virt/powervm/volume/test_iscsi.py @@ -74,7 +74,8 @@ class TestISCSIAdapter(test_vol.TestVolumeAdapter): 'target_lun': self.lun, 'target_portal': self.host_ip, 'auth_username': self.user, - 'auth_password': self.password + 'auth_password': self.password, + 'volume_id': 'a_volume_id', }, } self.auth_method = 'CHAP' @@ -94,7 +95,8 @@ class TestISCSIAdapter(test_vol.TestVolumeAdapter): 'discovery_auth_password': self.password, 'target_iqns': [self.iqn], 'target_luns': [self.lun], - 'target_portals': [self.host_ip] + 'target_portals': [self.host_ip], + 'volume_id': 'b_volume_id', }, } mock_inst = mock.MagicMock() @@ -135,6 +137,7 @@ class TestISCSIAdapter(test_vol.TestVolumeAdapter): self.assertIsInstance(vios_w, pvm_vios.VIOS) self.assertEqual('1234', lpar_uuid) self.assertIsInstance(pv, pvm_stor.PV) + self.assertEqual('_volume_id', pv.tag[1:]) self.assertEqual(62, lpar_slot_num) self.assertEqual('the_lua', lua) self.assertEqual('ISCSI-bar_%s' % self.lun, target_name) diff --git a/nova_powervm/tests/virt/powervm/volume/test_rbd.py b/nova_powervm/tests/virt/powervm/volume/test_rbd.py index 6536022c..b3264286 100644 --- a/nova_powervm/tests/virt/powervm/volume/test_rbd.py +++ b/nova_powervm/tests/virt/powervm/volume/test_rbd.py @@ -45,9 +45,10 @@ class TestRBDVolumeAdapter(test_vol.TestVolumeAdapter): self.adpt = self.useFixture(pvm_fx.AdapterFx()).adpt mock_inst = mock.MagicMock(uuid='2BC123') - self.vol_drv = FakeRBDVolAdapter(self.adpt, 'host_uuid', mock_inst, - {'data': {'name': 'pool/image'}, - 'serial': 'volid1'}) + self.vol_drv = FakeRBDVolAdapter( + self.adpt, 'host_uuid', mock_inst, + {'data': {'name': 'pool/image', 'volume_id': 'a_vol_id'}, + 'serial': 'volid1'}) self.fake_vios = pvm_vios.VIOS.bld( self.adpt, 'vios1', @@ -95,7 +96,7 @@ class TestRBDVolumeAdapter(test_vol.TestVolumeAdapter): # Validate mock_rbd_bld_ref.assert_called_once_with( - self.adpt, 'pool/image') + self.adpt, 'pool/image', tag='a_vol_id') self.assertEqual(1, mock_build_map.call_count) self.assertEqual(1, mock_udid_to_map.call_count) @@ -128,7 +129,7 @@ class TestRBDVolumeAdapter(test_vol.TestVolumeAdapter): # Validate mock_rbd_bld_ref.assert_called_once_with( - self.adpt, 'pool/image') + self.adpt, 'pool/image', tag='a_vol_id') self.assertEqual(0, mock_build_map.call_count) @mock.patch('pypowervm.entities.Entry.uuid', diff --git a/nova_powervm/tests/virt/powervm/volume/test_vscsi.py b/nova_powervm/tests/virt/powervm/volume/test_vscsi.py index 9202a24f..d68f7a45 100644 --- a/nova_powervm/tests/virt/powervm/volume/test_vscsi.py +++ b/nova_powervm/tests/virt/powervm/volume/test_vscsi.py @@ -69,7 +69,8 @@ class BaseVSCSITest(test_vol.TestVolumeAdapter): p_wwpn1: ['t1'], p_wwpn2: ['t2', 't3'] }, - 'target_lun': '1' + 'target_lun': '1', + 'volume_id': 'a_volume_identifier', }, } mock_inst = mock.MagicMock() @@ -210,6 +211,7 @@ class TestVSCSIAdapter(BaseVSCSITest): self.assertIsInstance(vios_w, pvm_vios.VIOS) self.assertEqual('1234', lpar_uuid) self.assertIsInstance(pv, pvm_stor.PV) + self.assertEqual('a_volume_identifier', pv.tag) self.assertEqual(62, lpar_slot_num) self.assertEqual('the_lua', lua) return 'fake_map' diff --git a/nova_powervm/virt/powervm/volume/fileio.py b/nova_powervm/virt/powervm/volume/fileio.py index 3a422103..b462ea11 100644 --- a/nova_powervm/virt/powervm/volume/fileio.py +++ b/nova_powervm/virt/powervm/volume/fileio.py @@ -94,10 +94,10 @@ class FileIOVolumeAdapter(v_driver.PowerVMVolumeAdapter): def _connect_volume(self, slot_mgr): path = self._get_path() - # Get the File Path + volid = self.connection_info['data']['volume_id'] fio = pvm_stg.FileIO.bld( self.adapter, path, - backstore_type=pvm_stg.BackStoreType.FILE_IO) + backstore_type=pvm_stg.BackStoreType.FILE_IO, tag=volid) def add_func(vios_w): # If the vios doesn't match, just return diff --git a/nova_powervm/virt/powervm/volume/iscsi.py b/nova_powervm/virt/powervm/volume/iscsi.py index 4e0d30e6..4af073e6 100644 --- a/nova_powervm/virt/powervm/volume/iscsi.py +++ b/nova_powervm/virt/powervm/volume/iscsi.py @@ -163,12 +163,13 @@ class IscsiVolumeAdapter(volume.VscsiVolumeAdapter, iqn = self.connection_info["data"]["target_iqn"] lun = self.connection_info["data"]["target_lun"] target_name = "ISCSI-%s_%s" % (iqn.split(":")[1], str(lun)) + volume_id = self.connection_info["data"]["volume_id"] # Found a hdisk on this Virtual I/O Server. Add the action to # map it to the VM when the stg_ftsk is executed. with lockutils.lock(hash(self)): self._add_append_mapping( vios_w.uuid, device_name, lpar_slot_num=slot, lua=lua, - target_name=target_name, udid=udid) + target_name=target_name, udid=udid, tag=volume_id) # Save the devname for the disk in the connection info. It is # used for the detach. diff --git a/nova_powervm/virt/powervm/volume/rbd.py b/nova_powervm/virt/powervm/volume/rbd.py index 136985c1..f7d64219 100644 --- a/nova_powervm/virt/powervm/volume/rbd.py +++ b/nova_powervm/virt/powervm/volume/rbd.py @@ -87,8 +87,8 @@ class RBDVolumeAdapter(v_driver.PowerVMVolumeAdapter): def _connect_volume(self, slot_mgr): name = self.connection_info["data"]["name"] - # Get the File Path - rbd = pvm_stg.RBD.bld_ref(self.adapter, name) + volid = self.connection_info["data"]["volume_id"] + rbd = pvm_stg.RBD.bld_ref(self.adapter, name, tag=volid) def add_func(vios_w): # If the vios doesn't match, just return diff --git a/nova_powervm/virt/powervm/volume/volume.py b/nova_powervm/virt/powervm/volume/volume.py index cf3216de..a82581cf 100644 --- a/nova_powervm/virt/powervm/volume/volume.py +++ b/nova_powervm/virt/powervm/volume/volume.py @@ -129,11 +129,12 @@ class VscsiVolumeAdapter(object): raise p_exc.VolumeAttachFailed(**ex_args) def _add_append_mapping(self, vios_uuid, device_name, lpar_slot_num=None, - lua=None, target_name=None, udid=None): + lua=None, target_name=None, udid=None, + tag=None): """Update the stg_ftsk to append the mapping to the VIOS. :param vios_uuid: The UUID of the vios for the pypowervm adapter. - :param device_name: The The hdisk device name. + :param device_name: The hdisk device name. :param lpar_slot_num: (Optional, Default:None) If specified, the client lpar slot number to use on the mapping. If left as None, it will use the next available slot @@ -142,11 +143,19 @@ class VscsiVolumeAdapter(object): the TargetDevice. If None, the LUA will be assigned by the server. Should be specified for all of the VSCSIMappings for a particular bus, or none of them. + :param target_name: (Optional. Default: None) Name to set on the + TargetDevice. If None, it will be assigned by the + server. + :param udid: (Optional. Default: None) Universal Disk IDentifier of + the physical volume to attach. Used to resolve name + conflicts. + :param tag: String tag to set on the physical volume. """ def add_func(vios_w): LOG.info("Adding vSCSI mapping to Physical Volume %(dev)s", {'dev': device_name}, instance=self.instance) - pv = pvm_stor.PV.bld(self.adapter, device_name, udid) + pv = pvm_stor.PV.bld(self.adapter, device_name, udid=udid, + tag=tag) v_map = tsk_map.build_vscsi_mapping( self.host_uuid, vios_w, self.vm_uuid, pv, lpar_slot_num=lpar_slot_num, lua=lua, target_name=target_name) diff --git a/nova_powervm/virt/powervm/volume/vscsi.py b/nova_powervm/virt/powervm/volume/vscsi.py index 70e1874c..a028ae24 100644 --- a/nova_powervm/virt/powervm/volume/vscsi.py +++ b/nova_powervm/virt/powervm/volume/vscsi.py @@ -232,11 +232,13 @@ class PVVscsiFCVolumeAdapter(volume.VscsiVolumeAdapter, return False if hdisk.good_discovery(status, device_name): + volume_id = self.connection_info["data"]["volume_id"] # Found a hdisk on this Virtual I/O Server. Add the action to # map it to the VM when the stg_ftsk is executed. with lockutils.lock(hash(self)): self._add_append_mapping(vios_w.uuid, device_name, - lpar_slot_num=slot, lua=lua) + lpar_slot_num=slot, lua=lua, + tag=volume_id) # Save the UDID for the disk in the connection info. It is # used for the detach.