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
from cinder.volume.drivers.emc import emc_vmax_utils
from cinder.volume import volume_types
-
CINDER_EMC_CONFIG_DIR = '/etc/cinder/'
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)
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()
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)
# under the License.
import ast
-import inspect
import os.path
from oslo_config import cfg
: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(
(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)
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})