diff --git a/cinder/tests/unit/volume/drivers/ibm/fake_pyxcli.py b/cinder/tests/unit/volume/drivers/ibm/fake_pyxcli.py index 18e148750c0..7f447326042 100644 --- a/cinder/tests/unit/volume/drivers/ibm/fake_pyxcli.py +++ b/cinder/tests/unit/volume/drivers/ibm/fake_pyxcli.py @@ -26,6 +26,7 @@ pyxcli_client.events = mock.Mock() pyxcli_client.mirroring = mock.Mock() pyxcli_client.transports = fake_pyxcli_exceptions pyxcli_client.mirroring.cg_recovery_manager = mock.Mock() +pyxcli_client.version = '1.1.5' sys.modules['pyxcli'] = pyxcli_client sys.modules['pyxcli.events'] = pyxcli_client.events 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 b1d0375b9be..0e06edd3541 100644 --- a/cinder/tests/unit/volume/drivers/ibm/test_xiv_proxy.py +++ b/cinder/tests/unit/volume/drivers/ibm/test_xiv_proxy.py @@ -150,6 +150,23 @@ class XIVProxyTest(test.TestCase): 'san_password': REPLICA_PASSWORD, } + @mock.patch("cinder.volume.drivers.ibm.ibm_storage." + "xiv_proxy.pyxcli") + def test_wrong_pyxcli(self, mock_pyxcli): + + driver = mock.MagicMock() + driver.VERSION = "VERSION" + + p = self.proxy( + self.default_storage_info, + mock.MagicMock(), + test_mock.cinder.exception, + driver) + + mock_pyxcli.version = '1.1.4' + self.assertRaises(test_mock.cinder.exception.CinderException, + p.setup, {}) + @mock.patch("cinder.volume.drivers.ibm.ibm_storage" ".xiv_proxy.socket.getfqdn", new=mock.MagicMock( return_value='test_hostname')) diff --git a/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py b/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py index 2b84e311ae3..d44bc8708f0 100644 --- a/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py +++ b/cinder/volume/drivers/ibm/ibm_storage/xiv_proxy.py @@ -57,6 +57,7 @@ SYNC = 'sync' ASYNC = 'async' SYNC_TIMEOUT = 300 SYNCHED_STATES = ['synchronized', 'rpo ok'] +PYXCLI_VERSION = '1.1.5' LOG = logging.getLogger(__name__) @@ -95,6 +96,9 @@ DELETE_VOLUME_BASE_ERROR = ("Unable to delete volume '%(volume)s': " MANAGE_VOLUME_BASE_ERROR = _("Unable to manage the volume '%(volume)s': " "%(error)s.") +INCOMPATIBLE_PYXCLI = _('Incompatible pyxcli found. Required: %(required)s ' + 'Found: %(found)s') + class XIVProxy(proxy.IBMStorageProxy): """Proxy between the Cinder Volume and Spectrum Accelerate Storage. @@ -134,6 +138,22 @@ class XIVProxy(proxy.IBMStorageProxy): @proxy._trace_time def setup(self, context): + msg = '' + if pyxcli: + if pyxcli.version != PYXCLI_VERSION: + msg = (INCOMPATIBLE_PYXCLI % + {'required': PYXCLI_VERSION, + 'found': pyxcli.version + }) + else: + msg = (SETUP_BASE_ERROR % + {'title': strings.TITLE, + 'details': "IBM Python XCLI Client (pyxcli) not found" + }) + if msg != '': + LOG.error(msg) + raise self._get_exception()(msg) + """Connect ssl client.""" LOG.info("Setting up connection to %(title)s...\n" "Active backend_id: '%(id)s'.", diff --git a/driver-requirements.txt b/driver-requirements.txt index 236cee37f26..85c13fce6cd 100644 --- a/driver-requirements.txt +++ b/driver-requirements.txt @@ -25,7 +25,7 @@ python-lefthandclient>=2.0.0 # Apache-2.0 pywbem>=0.7.0 # LGPLv2.1+ # IBM XIV -pyxcli>=1.1.0 # Apache-2.0 +pyxcli>=1.1.5 # Apache-2.0 # RBD rados # LGPLv2.1