Multi storage adapter support broken

The initator-target map, we're not necessarily picking
the entry for our boot adapter, but just the first one
that is returned by get_partition_wwpns. But in fact
we must not take the first one, but we must take the
wwpn of our selected boot adapter as initiator wwpns
(and then lookup the target wwpns for it).

Closes-Bug: #1662511

Change-Id: Ib5890c9e696e6bfae5d2915f87b4baf151b2ed9a
Signed-off-by: Prabhat Ranjan <pranjank@in.ibm.com>
This commit is contained in:
Prabhat Ranjan 2017-04-25 13:29:30 +05:30
parent ff1b77f71a
commit 9b2dccbed8
2 changed files with 50 additions and 19 deletions

View File

@ -25,7 +25,7 @@ from nova_dpm.virt.dpm import driver
from nova_dpm.virt.dpm import exceptions
from nova_dpm.virt.dpm import vm
from nova_dpm.virt.dpm.volume import fibrechannel
from oslo_config import cfg
import mock
import zhmcclient
@ -51,7 +51,7 @@ def fake_session():
session = zhmcclient_mock.FakedSession(
'fake-host', 'fake-hmc', '2.13.1', '1.8')
session.hmc.cpcs.add({
cpc1 = session.hmc.cpcs.add({
'object-id': '6511ee0f-0d64-4392-b9e0-bbbbbbbbbbbb',
'name': 'cpc_1',
'description': 'CPC #1',
@ -60,6 +60,35 @@ def fake_session():
'storage-customer': 2048,
'se-version': '2.13.1'
})
partition1 = cpc1.partitions.add({
'name': 'OpenStack-foo-6511ee0f-0d64-4392-b9e0-aaaaaaaaaaaa',
'description': 'OpenStack CPCSubset=foo',
'initial-memory': 1,
'status': 'ACTIVE',
'maximum-memory': 512,
'ifl-processors': 3
})
adapter1 = cpc1.adapters.add({
'object-id': '6511ee0f-0d64-4392-b9e0-cdbea10a17c3',
'name': 'fcp_1',
'description': 'FCP #1',
'type': 'fcp',
})
adapter1.ports.add({
'element-id': '1',
'name': 'fcp_1_1',
'description': 'FCP #1 Port #1',
})
partition1.hbas.add({
'object-d': '1',
"adapter-port-uri":
"/api/adapters/"
+ "6511ee0f-0d64-4392-b9e0-cdbea10a17c3"
+ "/storage-ports/"
+ "1",
'wwpn': PARTITION_WWPN
})
return session
@ -73,6 +102,19 @@ class DPMdriverInitHostTestCase(TestCase):
self.dpmdriver = driver.DPMDriver(None)
self.dpmdriver._client = self.client
self.client = zhmcclient.Client(self.session)
self.cpc = self.client.cpcs.find(**{"name": "cpc_1"})
self.partition = self.cpc.partitions.find(
**{"name": "OpenStack-foo-6511ee0f-0d64-4392-b9e0-aaaaaaaaaaaa"})
adapter = self.cpc.adapters.find(**{'name': 'fcp_1'})
self.adapter_object_id = adapter.get_property('object-id')
self.port_element_id = adapter.ports.list()[0].get_property(
'element-id')
storage = self.adapter_object_id + ":" + self.port_element_id
cfg.CONF.set_override("physical_storage_adapter_mappings", [storage],
group="dpm", enforce_type=True)
self.flags(
group="dpm",
cpc_object_id="6511ee0f-0d64-4392-b9e0-bbbbbbbbbbbb")
@ -105,13 +147,11 @@ class DPMdriverInitHostTestCase(TestCase):
None)
@mock.patch.object(vm.PartitionInstance, 'get_partition')
@mock.patch.object(vm.PartitionInstance, 'get_partition_wwpns')
@mock.patch.object(basedriver, 'block_device_info_get_mapping')
def test_get_fc_boot_props(self, mock_block_device,
mock_get_partition_wwpns,
mock_get_partition):
mock_get_partition.return_value = self.partition
mock_block_device.return_value = BLOCK_DEVICE
mock_get_partition_wwpns.return_value = [PARTITION_WWPN]
inst = vm.PartitionInstance(mock.Mock(), mock.Mock())
target_wwpn, lun = self.dpmdriver.get_fc_boot_props(
mock.Mock(), inst)
@ -144,13 +184,11 @@ class DPMdriverInitHostTestCase(TestCase):
self.dpmdriver._validate_volume_type(bdms)
@mock.patch.object(vm.PartitionInstance, 'get_partition')
@mock.patch.object(vm.PartitionInstance, 'get_partition_wwpns')
@mock.patch.object(basedriver, 'block_device_info_get_mapping')
def test_get_fc_boot_props_ignore_list(self, mock_block_device,
mock_get_partition_wwpns,
mock_get_partition):
mock_get_partition.return_value = self.partition
mock_block_device.return_value = BLOCK_DEVICE
mock_get_partition_wwpns.return_value = [PARTITION_WWPN]
self.flags(group="dpm", target_wwpn_ignore_list=["500507680B214AC1"])
self.dpmdriver.init_host(None)
inst = vm.PartitionInstance(mock.Mock(), mock.Mock())

View File

@ -381,17 +381,10 @@ class DPMDriver(driver.ComputeDriver):
LOG.debug("Block device mapping %s", str(block_device_mapping))
wwpns = inst.get_partition_wwpns()
if not wwpns:
raise Exception(
'No initiator WWPNs found for instance %(instance)s'
% {'instance': inst.instance})
# In this release our consideration
# is we will use one wwpn to connect with
# volume. So will use first item in the list
partition_wwpn = wwpns[0]
partition_hba_uri = inst.get_boot_hba_uri()
partition_hba = inst.get_partition().hbas.find(**{
"element-uri": partition_hba_uri})
partition_wwpn = partition_hba.get_property('wwpn')
mapped_block_device = block_device_mapping[0]