From 5ad6870b550d1362c84902aabe96b804c8cd0458 Mon Sep 17 00:00:00 2001 From: Helen Walsh Date: Tue, 16 Feb 2016 21:16:49 +0000 Subject: [PATCH] EMC VMAX - SSl connection is not picking up values Setting ssl configuration in cinder.conf and in emc vmax xml, the parameters aren't being picked up in the emc_vmax_common.py thereby preventing ssl communication with the vmax. Change-Id: Ie7d50c565c73f097257fb25d911ccc7b7c3de8e4 Closes-Bug: #1546184 --- cinder/tests/unit/test_emc_vmax.py | 29 ++++++++--- cinder/volume/drivers/emc/emc_vmax_common.py | 51 +++++++------------- 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/cinder/tests/unit/test_emc_vmax.py b/cinder/tests/unit/test_emc_vmax.py index a297145ac..30122e7c8 100644 --- a/cinder/tests/unit/test_emc_vmax.py +++ b/cinder/tests/unit/test_emc_vmax.py @@ -28,6 +28,8 @@ from cinder import exception from cinder.i18n import _ from cinder.objects import fields from cinder import test + +from cinder.volume import configuration as conf from cinder.volume.drivers.emc import emc_vmax_common from cinder.volume.drivers.emc import emc_vmax_fast from cinder.volume.drivers.emc import emc_vmax_fc @@ -38,7 +40,6 @@ from cinder.volume.drivers.emc import emc_vmax_provision_v3 from cinder.volume.drivers.emc import emc_vmax_utils from cinder.volume import volume_types - CINDER_EMC_CONFIG_DIR = '/etc/cinder/' @@ -1693,12 +1694,15 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase): self.config_file_path = None self.create_fake_config_file_no_fast() self.addCleanup(self._cleanup) - - configuration = mock.Mock() - configuration.safe_get.return_value = 'ISCSINoFAST' - configuration.cinder_emc_config_file = self.config_file_path + configuration = conf.Configuration(None) + configuration.append_config_values = mock.Mock(return_value=0) configuration.config_group = 'ISCSINoFAST' - + configuration.cinder_emc_config_file = self.config_file_path + self.stubs.Set(configuration, 'safe_get', + self.fake_safe_get({'driver_use_ssl': + True, + 'volume_backend_name': + 'ISCSINoFAST'})) self.stubs.Set(emc_vmax_iscsi.EMCVMAXISCSIDriver, 'smis_do_iscsi_discovery', self.fake_do_iscsi_discovery) @@ -1717,6 +1721,11 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase): self.driver = driver self.driver.utils = emc_vmax_utils.EMCVMAXUtils(object) + def fake_safe_get(self, values): + def _safe_get(key): + return values.get(key) + return _safe_get + def create_fake_config_file_no_fast(self): doc = minidom.Document() @@ -3783,6 +3792,14 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase): self.assertEqual([{'status': 'available', 'id': '2'}], volumes_model_update) + @mock.patch.object( + emc_vmax_common.EMCVMAXCommon, + '_update_pool_stats', + return_value={1, 2, 3}) + def test_ssl_support(self, pool_stats): + self.driver.common.update_volume_stats() + self.assertTrue(self.driver.common.ecomUseSSL) + def _cleanup(self): if self.config_file_path: bExists = os.path.exists(self.config_file_path) diff --git a/cinder/volume/drivers/emc/emc_vmax_common.py b/cinder/volume/drivers/emc/emc_vmax_common.py index 164b3fa74..918e4aba4 100644 --- a/cinder/volume/drivers/emc/emc_vmax_common.py +++ b/cinder/volume/drivers/emc/emc_vmax_common.py @@ -14,7 +14,6 @@ # under the License. import ast -import inspect import os.path from oslo_config import cfg @@ -1279,36 +1278,25 @@ class EMCVMAXCommon(object): :returns: pywbem.WBEMConnection -- conn, the ecom connection :raises: VolumeBackendAPIException """ - + ecomx509 = None if self.ecomUseSSL: - argspec = inspect.getargspec(pywbem.WBEMConnection.__init__) - if any("ca_certs" in s for s in argspec.args): - updatedPywbem = True - else: - updatedPywbem = False + if (self.configuration.safe_get('driver_client_cert_key') and + self.configuration.safe_get('driver_client_cert')): + ecomx509 = {"key_file": + self.configuration.safe_get( + 'driver_client_cert_key'), + "cert_file": + self.configuration.safe_get( + 'driver_client_cert')} pywbem.cim_http.wbem_request = emc_vmax_https.wbem_request - if updatedPywbem: - conn = pywbem.WBEMConnection( - self.url, - (self.user, self.passwd), - default_namespace='root/emc', - x509={"key_file": - self.configuration.safe_get( - 'driver_client_cert_key'), - "cert_file": - self.configuration.safe_get('driver_client_cert')}, - ca_certs=self.ecomCACert, - no_verification=self.ecomNoVerification) - else: - conn = pywbem.WBEMConnection( - self.url, - (self.user, self.passwd), - default_namespace='root/emc', - x509={"key_file": - self.configuration.safe_get( - 'driver_client_cert_key'), - "cert_file": - self.configuration.safe_get('driver_client_cert')}) + conn = pywbem.WBEMConnection( + self.url, + (self.user, self.passwd), + default_namespace='root/emc', + x509=ecomx509, + ca_certs=self.configuration.safe_get('driver_ssl_cert_path'), + no_verification=not self.configuration.safe_get( + 'driver_ssl_cert_verify')) else: conn = pywbem.WBEMConnection( @@ -1316,7 +1304,6 @@ class EMCVMAXCommon(object): (self.user, self.passwd), default_namespace='root/emc') - conn.debug = True if conn is None: exception_message = (_("Cannot connect to ECOM server.")) raise exception.VolumeBackendAPIException(data=exception_message) @@ -1691,9 +1678,7 @@ class EMCVMAXCommon(object): port = arrayInfo['EcomServerPort'] self.user = arrayInfo['EcomUserName'] self.passwd = arrayInfo['EcomPassword'] - self.ecomUseSSL = arrayInfo['EcomUseSSL'] - self.ecomCACert = arrayInfo['EcomCACert'] - self.ecomNoVerification = arrayInfo['EcomNoVerification'] + self.ecomUseSSL = self.configuration.safe_get('driver_use_ssl') ip_port = ("%(ip)s:%(port)s" % {'ip': ip, 'port': port}) -- 2.45.2