From a80b967ab66d0ef440eb153be8d2a12ad3bdd860 Mon Sep 17 00:00:00 2001 From: Raghavendra Tilay Date: Mon, 21 Sep 2020 12:48:43 +0000 Subject: [PATCH] 3PAR: Allow iSCSI driver to be enabled for Primera 4.2 onwards. For HPE Primera 4.2 or higher versions, now iSCSI driver is supported along with existing FC driver. Accordingly updated code and documentation. Change-Id: Ie2542fc4b21050c4f14aea67ea488d9f9eeaae79 (cherry picked from commit 6cabe11c9207376f905db3a0bcadf6d43e2c2af1) --- .../unit/volume/drivers/hpe/test_hpe3par.py | 48 +++++++++++++++++-- cinder/volume/drivers/hpe/hpe_3par_iscsi.py | 17 +++++-- .../block-storage/drivers/hpe-3par-driver.rst | 6 +-- ...ar-primera-add-iscsi-5af339643dfa0928.yaml | 5 ++ 4 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 releasenotes/notes/hpe-3par-primera-add-iscsi-5af339643dfa0928.yaml diff --git a/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py b/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py index b915537777e..3ce6b4748cd 100644 --- a/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py +++ b/cinder/tests/unit/volume/drivers/hpe/test_hpe3par.py @@ -763,14 +763,15 @@ class HPE3PARBaseDriver(test.TestCase): spec=True, ) def setup_mock_client(self, _m_client, driver, conf=None, m_conf=None, - is_primera=False): + is_primera=False, + wsapi_version=wsapi_version_latest): _m_client = _m_client.return_value # Configure the base constants, defaults etc... _m_client.configure_mock(**self.mock_client_conf) - _m_client.getWsApiVersion.return_value = self.wsapi_version_latest + _m_client.getWsApiVersion.return_value = wsapi_version _m_client.is_primera_array.return_value = is_primera @@ -8901,10 +8902,49 @@ class TestHPE3PARISCSIDriver(HPE3PARBaseDriver): return mock_client - def test_iscsi_primera(self): + def test_iscsi_primera_old(self): + # primera 4.0.xx.yyy + wsapi_version_primera_old = {'major': 1, + 'build': 40000128, + 'minor': 8, + 'revision': 1} + self.assertRaises(NotImplementedError, self.setup_mock_client, driver=hpedriver.HPE3PARISCSIDriver, - is_primera=True) + is_primera=True, + wsapi_version=wsapi_version_primera_old) + + def test_iscsi_primera_new(self, config=None, mock_conf=None): + # primera 4.2.xx.yyy + wsapi_version_primera_new = {'major': 1, + 'build': 40202010, + 'minor': 8, + 'revision': 1} + + self.ctxt = context.get_admin_context() + + mock_client = self.setup_mock_client( + conf=config, + m_conf=mock_conf, + driver=hpedriver.HPE3PARISCSIDriver, + is_primera=True, + wsapi_version=wsapi_version_primera_new) + + expected_get_cpgs = [ + mock.call.getCPG(HPE3PAR_CPG), + mock.call.getCPG(HPE3PAR_CPG2)] + expected_get_ports = [mock.call.getPorts()] + expected_primera = [ + mock.call.is_primera_array(), + mock.call.getWsApiVersion()] + mock_client.assert_has_calls( + self.standard_login + + expected_get_cpgs + + self.standard_logout + + expected_primera + + self.standard_login + + expected_get_ports + + self.standard_logout) @ddt.data('volume', 'volume_name_id') def test_initialize_connection(self, volume_attr): diff --git a/cinder/volume/drivers/hpe/hpe_3par_iscsi.py b/cinder/volume/drivers/hpe/hpe_3par_iscsi.py index 83febae894a..0d809e048f1 100644 --- a/cinder/volume/drivers/hpe/hpe_3par_iscsi.py +++ b/cinder/volume/drivers/hpe/hpe_3par_iscsi.py @@ -128,10 +128,11 @@ class HPE3PARISCSIDriver(hpebasedriver.HPE3PARDriverBase): failover. bug #1773069 4.0.4 - Added Peer Persistence feature 4.0.5 - Added Primera array check. bug #1849525 + 4.0.6 - Allow iSCSI support for Primera 4.2 onwards """ - VERSION = "4.0.5" + VERSION = "4.0.6" # The name of the CI wiki page. CI_WIKI_NAME = "HPE_Storage_CI" @@ -144,9 +145,17 @@ class HPE3PARISCSIDriver(hpebasedriver.HPE3PARDriverBase): client_obj = common.client is_primera = client_obj.is_primera_array() if is_primera: - LOG.error("For Primera, only FC is supported. " - "iSCSI cannot be used") - raise NotImplementedError() + api_version = client_obj.getWsApiVersion() + array_version = api_version['build'] + LOG.debug("array version: %(version)s", + {'version': array_version}) + if array_version < 40200000: + err_msg = (_('The iSCSI driver is not supported for ' + 'Primera %(version)s. It is supported ' + 'for Primera 4.2 or higher versions.') + % {'version': array_version}) + LOG.error(err_msg) + raise NotImplementedError() self.iscsi_ips = {} common.client_login() diff --git a/doc/source/configuration/block-storage/drivers/hpe-3par-driver.rst b/doc/source/configuration/block-storage/drivers/hpe-3par-driver.rst index d013cdc0392..bad3e3d4c7d 100644 --- a/doc/source/configuration/block-storage/drivers/hpe-3par-driver.rst +++ b/doc/source/configuration/block-storage/drivers/hpe-3par-driver.rst @@ -378,15 +378,15 @@ OpenStack software. san_password=3parpass # FIBRE CHANNEL DRIVER - # Note: For Primera, only FC driver is supported as of now. # (uncomment the next line to enable the FC driver) #volume_driver=cinder.volume.drivers.hpe.hpe_3par_fc.HPE3PARFCDriver # iSCSI DRIVER # If you enable the iSCSI driver, you must also set values # for hpe3par_iscsi_ips or iscsi_ip_address in this file. - # Note: Primera currently requires the FC driver. If you - # configure iSCSI with Primera, the driver will fail to start. + # Note: The iSCSI driver is supported with 3PAR (all versions) + # and Primera (version 4.2 or higher). If you configure iSCSI + # with Primera 4.0 or 4.1, the driver will fail to start. # (uncomment the next line to enable the iSCSI driver) #volume_driver=cinder.volume.drivers.hpe.hpe_3par_iscsi.HPE3PARISCSIDriver diff --git a/releasenotes/notes/hpe-3par-primera-add-iscsi-5af339643dfa0928.yaml b/releasenotes/notes/hpe-3par-primera-add-iscsi-5af339643dfa0928.yaml new file mode 100644 index 00000000000..03166024b7a --- /dev/null +++ b/releasenotes/notes/hpe-3par-primera-add-iscsi-5af339643dfa0928.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + HPE 3PAR Driver: Add support of iSCSI driver for Primera 4.2 + or higher versions.