]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
EMC VMAX - SSl connection is not picking up values
authorHelen Walsh <helen.walsh@emc.com>
Tue, 16 Feb 2016 21:16:49 +0000 (21:16 +0000)
committerHelen Walsh <helen.walsh@emc.com>
Fri, 11 Mar 2016 23:21:13 +0000 (23:21 +0000)
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
cinder/volume/drivers/emc/emc_vmax_common.py

index a297145ac004174b3430f07cbefa1352daba7dae..30122e7c88d3f97345d2672238a4e5f33d4b61b0 100644 (file)
@@ -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)
index 164b3fa747b29565ecc927a7fd602b32667c30d7..918e4aba4ebdd42ece9f2eee34fb277ffec5e0aa 100644 (file)
@@ -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})