Merge "IBM XIV: enable FC zoning to all the ports"

This commit is contained in:
Zuul 2018-05-09 01:44:01 +00:00 committed by Gerrit Code Review
commit d1aff563e0
2 changed files with 33 additions and 8 deletions

View File

@ -1464,6 +1464,24 @@ class XIVProxyTest(test.TestCase):
FC_TARGETS_OPTIMIZED, fc_targets, FC_TARGETS_OPTIMIZED, fc_targets,
"FC targets are different from the expected") "FC targets are different from the expected")
def test_define_fc_returns_all_wwpns_list(self):
driver = mock.MagicMock()
driver.VERSION = "VERSION"
p = self.proxy(
self.default_storage_info,
mock.MagicMock(),
test_mock.cinder.exception,
driver)
p.ibm_storage_cli = mock.MagicMock()
p.ibm_storage_cli.cmd.fc_port_list.return_value = FC_PORT_LIST_OUTPUT
p.ibm_storage_cli.fc_connectivity_list.return_value = ()
fc_targets = p._define_fc(p._define_host(TEST_CONNECTOR))
six.assertCountEqual(self,
FC_TARGETS_OPTIMIZED, fc_targets,
"FC targets are different from the expected")
def test_define_ports_returns_sorted_wwpns_list(self): def test_define_ports_returns_sorted_wwpns_list(self):
driver = mock.MagicMock() driver = mock.MagicMock()
driver.VERSION = "VERSION" driver.VERSION = "VERSION"

View File

@ -2478,7 +2478,9 @@ class XIVProxy(proxy.IBMStorageProxy):
fcaddress=wwpn) fcaddress=wwpn)
if len(connected_wwpns) == 0: if len(connected_wwpns) == 0:
LOG.error(CONNECTIVITY_FC_NO_TARGETS) LOG.error(CONNECTIVITY_FC_NO_TARGETS)
raise self._get_exception()(CONNECTIVITY_FC_NO_TARGETS) all_target_ports = self._get_all_target_ports()
fc_targets = list(set([target.get('wwpn')
for target in all_target_ports]))
else: else:
msg = _("No Fibre Channel HBA's are defined on the host.") msg = _("No Fibre Channel HBA's are defined on the host.")
LOG.error(msg) LOG.error(msg)
@ -2600,13 +2602,7 @@ class XIVProxy(proxy.IBMStorageProxy):
raise self._get_exception()(msg) raise self._get_exception()(msg)
@proxy._trace_time @proxy._trace_time
def _get_fc_targets(self, host): def _get_all_target_ports(self):
"""Get FC targets
:host: host bunch
:returns: array of FC target WWPNs
"""
target_wwpns = []
all_target_ports = [] all_target_ports = []
fc_port_list = self._call_xiv_xcli("fc_port_list") fc_port_list = self._call_xiv_xcli("fc_port_list")
@ -2614,6 +2610,17 @@ class XIVProxy(proxy.IBMStorageProxy):
t.get('wwpn') != '0000000000000000' and t.get('wwpn') != '0000000000000000' and
t.get('role') == 'Target' and t.get('role') == 'Target' and
t.get('port_state') == 'Online']) t.get('port_state') == 'Online'])
return all_target_ports
@proxy._trace_time
def _get_fc_targets(self, host):
"""Get FC targets
:host: A dictionary describing the host
:returns: array of FC target WWPNs
"""
target_wwpns = []
all_target_ports = self._get_all_target_ports()
if host: if host:
host_conect_list = self._call_xiv_xcli("host_connectivity_list", host_conect_list = self._call_xiv_xcli("host_connectivity_list",