HPE3PAR: Create FC vlun as host sees

Host sees VLUN template allows host connected
to any port to see a vv. so, only one vlun
template will be created per host irrespective
of number of FC ports available.

Change-Id: I623d6114db866a465955f8a5ae7f40b69c781622
Closes-Bug: #1734505
This commit is contained in:
Vivek Soni 2017-11-26 01:11:20 -08:00
parent 92d9f19f99
commit cd18537fd6
2 changed files with 18 additions and 96 deletions

View File

@ -5547,12 +5547,10 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
hpeexceptions.HTTPNotFound('fake'),
[{'active': True,
'volumeName': self.VOLUME_3PAR_NAME,
'portPos': {'node': 7, 'slot': 1, 'cardPort': 1},
'remoteName': self.wwn[1],
'lun': 90, 'type': 0}],
[{'active': True,
'volumeName': self.VOLUME_3PAR_NAME,
'portPos': {'node': 6, 'slot': 1, 'cardPort': 1},
'remoteName': self.wwn[0],
'lun': 90, 'type': 0}]]
@ -5570,8 +5568,8 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
'target_wwn': ['0987654321234', '123456789000987'],
'target_discovered': True,
'initiator_target_map':
{'123456789012345': ['123456789000987'],
'123456789054321': ['0987654321234']}}}
{'123456789012345': ['0987654321234', '123456789000987'],
'123456789054321': ['0987654321234', '123456789000987']}}}
with mock.patch.object(hpecommon.HPE3PARCommon,
'_create_client') as mock_create_client:
@ -5589,27 +5587,17 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
mock.call.getHost(self.FAKE_HOST),
mock.call.getPorts(),
mock.call.getHostVLUNs(self.FAKE_HOST),
mock.call.getPorts(),
mock.call.createVLUN(
self.VOLUME_3PAR_NAME,
auto=True,
hostname=self.FAKE_HOST,
lun=None,
portPos={'node': 7, 'slot': 1, 'cardPort': 1}),
mock.call.getHostVLUNs(self.FAKE_HOST),
mock.call.createVLUN(
self.VOLUME_3PAR_NAME,
auto=False,
hostname=self.FAKE_HOST,
lun=90,
portPos={'node': 6, 'slot': 1, 'cardPort': 1}),
lun=None),
mock.call.getHostVLUNs(self.FAKE_HOST)]
mock_client.assert_has_calls(
self.standard_login +
expected +
self.standard_logout)
self.assertDictEqual(expected_properties, result)
def test_initialize_connection_single_path(self):
@ -5625,8 +5613,6 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
'firmwareVersion': None,
'hostSpeed': 0,
'model': None,
'portPos': {'cardPort': 1, 'node': 7,
'slot': 1},
'vendor': None,
'wwn': self.wwn[0]}]}]
mock_client.queryHost.return_value = {
@ -5674,13 +5660,11 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
mock.call.getHost(self.FAKE_HOST),
mock.call.getPorts(),
mock.call.getHostVLUNs(self.FAKE_HOST),
mock.call.getPorts(),
mock.call.createVLUN(
self.VOLUME_3PAR_NAME,
auto=True,
hostname=self.FAKE_HOST,
lun=None,
portPos={'node': 7, 'slot': 1, 'cardPort': 1}),
lun=None),
mock.call.getHostVLUNs(self.FAKE_HOST)]
mock_client.assert_has_calls(
@ -5797,16 +5781,12 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
'firmwareVersion': None,
'hostSpeed': 0,
'model': None,
'portPos': {'cardPort': 1, 'node': 7,
'slot': 1},
'vendor': None,
'wwn': self.wwn[0]},
{'driverVersion': None,
'firmwareVersion': None,
'hostSpeed': 0,
'model': None,
'portPos': {'cardPort': 1, 'node': 6,
'slot': 1},
'vendor': None,
'wwn': self.wwn[1]}]}]
mock_client.queryHost.return_value = {
@ -5820,11 +5800,9 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
[{'active': True,
'volumeName': self.VOLUME_3PAR_NAME,
'lun': 90, 'type': 0,
'remoteName': self.wwn[1],
'portPos': {'cardPort': 1, 'node': 7, 'slot': 1}}],
'remoteName': self.wwn[1]}],
[{'active': True,
'volumeName': self.VOLUME_3PAR_NAME,
'portPos': {'node': 6, 'slot': 1, 'cardPort': 1},
'remoteName': self.wwn[0],
'lun': 90, 'type': 0}]]
@ -5842,8 +5820,8 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
'target_wwn': ['0987654321234', '123456789000987'],
'target_discovered': True,
'initiator_target_map':
{'123456789012345': ['123456789000987'],
'123456789054321': ['0987654321234']}}}
{'123456789012345': ['0987654321234', '123456789000987'],
'123456789054321': ['0987654321234', '123456789000987']}}}
with mock.patch.object(hpecommon.HPE3PARCommon,
'_create_client') as mock_create_client:
@ -5861,27 +5839,17 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver):
mock.call.getHost(self.FAKE_HOST),
mock.call.getPorts(),
mock.call.getHostVLUNs(self.FAKE_HOST),
mock.call.getPorts(),
mock.call.createVLUN(
self.VOLUME_3PAR_NAME,
auto=True,
hostname=self.FAKE_HOST,
lun=None,
portPos={'node': 7, 'slot': 1, 'cardPort': 1}),
mock.call.getHostVLUNs(self.FAKE_HOST),
mock.call.createVLUN(
self.VOLUME_3PAR_NAME,
auto=False,
hostname=self.FAKE_HOST,
lun=90,
portPos={'node': 6, 'slot': 1, 'cardPort': 1}),
lun=None),
mock.call.getHostVLUNs(self.FAKE_HOST)]
mock_client.assert_has_calls(
self.standard_login +
expected +
self.standard_logout)
self.assertDictEqual(expected_properties, result)
def test_terminate_connection(self):

View File

@ -37,8 +37,6 @@ except ImportError:
from oslo_log import log as logging
from oslo_utils.excutils import save_and_reraise_exception
from cinder import exception
from cinder.i18n import _
from cinder import interface
from cinder import utils
from cinder.volume.drivers.hpe import hpe_3par_base as hpebasedriver
@ -109,10 +107,11 @@ class HPE3PARFCDriver(hpebasedriver.HPE3PARDriverBase):
4.0.0 - Adds base class.
4.0.1 - Added check to remove FC zones. bug #1730720
4.0.2 - Create one vlun in single path configuration. bug #1727176
4.0.3 - Create FC vlun as host sees. bug #1734505
"""
VERSION = "4.0.2"
VERSION = "4.0.3"
# The name of the CI wiki page.
CI_WIKI_NAME = "HPE_Storage_CI"
@ -179,61 +178,16 @@ class HPE3PARFCDriver(hpebasedriver.HPE3PARDriverBase):
vlun = None
if existing_vlun is None:
# now that we have a host, create the VLUN
nsp = None
lun_id = None
active_fc_port_list = common.get_active_fc_target_ports()
if self.lookup_service:
if not init_targ_map:
msg = _("Setup is incomplete. Device mapping "
"not found from FC network. "
"Cannot perform VLUN creation.")
LOG.error(msg)
raise exception.FCSanLookupServiceException(msg)
for target_wwn in target_wwns:
for port in active_fc_port_list:
if port['portWWN'].lower() == target_wwn.lower():
nsp = port['nsp']
vlun = common.create_vlun(volume,
host,
nsp,
lun_id=lun_id)
if lun_id is None:
lun_id = vlun['lun']
break
else:
init_targ_map.clear()
del target_wwns[:]
host_connected_nsp = []
for fcpath in host['FCPaths']:
if 'portPos' in fcpath:
host_connected_nsp.append(
common.build_nsp(fcpath['portPos']))
if self.lookup_service is not None and numPaths == 1:
nsp = None
active_fc_port_list = common.get_active_fc_target_ports()
for port in active_fc_port_list:
if (
port['type'] == common.client.PORT_TYPE_HOST and
port['nsp'] in host_connected_nsp
):
if port['portWWN'].lower() == target_wwns[0].lower():
nsp = port['nsp']
vlun = common.create_vlun(volume,
host,
nsp,
lun_id=lun_id)
target_wwns.append(port['portWWN'])
if vlun['remoteName'] in init_targ_map:
init_targ_map[vlun['remoteName']].append(
port['portWWN'])
else:
init_targ_map[vlun['remoteName']] = [
port['portWWN']]
if lun_id is None:
lun_id = vlun['lun']
if lun_id is None:
# New vlun creation failed
msg = _('No new vlun(s) were created')
LOG.error(msg)
raise exception.VolumeDriverException(msg)
break
vlun = common.create_vlun(volume, host, nsp)
else:
vlun = common.create_vlun(volume, host)
else:
vlun = existing_vlun