From 4ace160de4762f58566ec24723858a400956bc4b Mon Sep 17 00:00:00 2001 From: Yu Zhang Date: Fri, 13 Apr 2018 02:42:37 -0400 Subject: [PATCH] IBM XIV: enable FC zoning to all the ports Define FC host just considers connected FC target ports, which should enable host to connect to all the storage FC ports for zoning. Change-Id: Ibb20917c8ed80cb1413de1d61104d495605ec3df Closes-Bug:#1759994 --- .../unit/volume/drivers/ibm/test_xiv_proxy.py | 18 +++++++++++++++ .../drivers/ibm/ibm_storage/xiv_proxy.py | 23 ++++++++++++------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/cinder/tests/unit/volume/drivers/ibm/test_xiv_proxy.py b/cinder/tests/unit/volume/drivers/ibm/test_xiv_proxy.py index 0f2d9606dde..3152e8b0259 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_xiv_proxy.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_xiv_proxy.py @@ -1464,6 +1464,24 @@ class XIVProxyTest(test.TestCase): FC_TARGETS_OPTIMIZED, fc_targets, "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): driver = mock.MagicMock() driver.VERSION = "VERSION" diff --git a/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py b/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py index 861d6e6e3e3..15545a3e8ac 100644 --- a/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py +++ b/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py @@ -2478,7 +2478,9 @@ class XIVProxy(proxy.IBMStorageProxy): fcaddress=wwpn) if len(connected_wwpns) == 0: 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: msg = _("No Fibre Channel HBA's are defined on the host.") LOG.error(msg) @@ -2600,13 +2602,7 @@ class XIVProxy(proxy.IBMStorageProxy): raise self._get_exception()(msg) @proxy._trace_time - def _get_fc_targets(self, host): - """Get FC targets - - :host: host bunch - :returns: array of FC target WWPNs - """ - target_wwpns = [] + def _get_all_target_ports(self): all_target_ports = [] 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('role') == 'Target' and 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: host_conect_list = self._call_xiv_xcli("host_connectivity_list",