Merge "ibm-storage: enable FC zonning to all ports"

This commit is contained in:
Jenkins 2017-10-10 15:33:52 +00:00 committed by Gerrit Code Review
commit 51de9ad740
2 changed files with 40 additions and 14 deletions

View File

@ -110,6 +110,11 @@ HOST_CONNECTIVITY_LIST = [
'local_fc_port': '1:FC_Port:4:1', 'local_iscsi_port': '',
'module': '1:Module:4', 'type': 'FC'}]
HOST_CONNECTIVITY_LIST_UNKNOWN_HOST = [
{'host': 'nova-compute-c5507606d5680f115', 'host_port': '10000000C97D26DE',
'local_fc_port': '1:FC_Port:3:1', 'local_iscsi_port': '',
'module': '1:Module:3', 'type': 'FC'}]
REPLICA_ID = 'WTF32'
REPLICA_IP = '1.2.3.4'
REPLICA_USER = 'WTF64'
@ -1415,6 +1420,26 @@ class XIVProxyTest(test.TestCase):
self.assertEqual(FC_TARGETS_OPTIMIZED_WITH_HOST, fc_targets,
"FC targets are different from the expected")
def test_get_fc_targets_returns_host_all_wwpns_list(self):
driver = mock.MagicMock()
driver.VERSION = "VERSION"
p = self.proxy(
self.default_storage_info,
mock.MagicMock(),
test_mock.cinder.exception,
driver)
hostname = storage.get_host_or_create_from_iqn(TEST_CONNECTOR)
host = {'name': hostname}
p.ibm_storage_cli = mock.MagicMock()
p.ibm_storage_cli.cmd.fc_port_list.return_value = FC_PORT_LIST_OUTPUT
p.ibm_storage_cli.cmd.host_connectivity_list.return_value = (
HOST_CONNECTIVITY_LIST_UNKNOWN_HOST)
fc_targets = p._get_fc_targets(host)
self.assertEqual(FC_TARGETS_OPTIMIZED, fc_targets,
"FC targets are different from the expected")
def test_define_ports_returns_sorted_wwpns_list(self):
driver = mock.MagicMock()
driver.VERSION = "VERSION"

View File

@ -2615,27 +2615,28 @@ class XIVProxy(proxy.IBMStorageProxy):
:returns: array of FC target WWPNs
"""
target_wwpns = []
all_target_ports = []
fc_port_list = self._call_xiv_xcli("fc_port_list")
if host is None:
target_wwpns += (
[t.get('wwpn') for t in
fc_port_list if
t.get('wwpn') != '0000000000000000' and
t.get('role') == 'Target' and
t.get('port_state') == 'Online'])
else:
all_target_ports += ([t for t in fc_port_list if
t.get('wwpn') != '0000000000000000' and
t.get('role') == 'Target' and
t.get('port_state') == 'Online'])
if host:
host_conect_list = self._call_xiv_xcli("host_connectivity_list",
host=host.get('name'))
for connection in host_conect_list:
fc_port = connection.get('local_fc_port')
target_wwpns += (
[t.get('wwpn') for t in
fc_port_list if
t.get('wwpn') != '0000000000000000' and
t.get('role') == 'Target' and
t.get('port_state') == 'Online' and
t.get('component_id') == fc_port])
[target.get('wwpn') for target in all_target_ports if
target.get('component_id') == fc_port])
if not target_wwpns:
LOG.debug('No fc targets found accessible to host: %s. Return list'
' of all available FC targets', host)
target_wwpns = ([target.get('wwpn')
for target in all_target_ports])
fc_targets = list(set(target_wwpns))
fc_targets.sort(key=self._sort_last_digit)