From 86c28cd8ee19fa17f64d80c8929f73ea3f6aa389 Mon Sep 17 00:00:00 2001 From: Helen Walsh Date: Tue, 1 Dec 2015 22:38:33 +0000 Subject: [PATCH] EMC VMAX - get_short_host_name not called in find_device_number The get_short_host_name needs to be called in find_device_number. There are 2 reasons for this: 1. Sometimes the full host name is contained in the connector['host'] object. 2. When the short host name still exceeds 38 characters, it must be truncated, in order to guarantee a "contains string" match between the host and the masking view name. Change-Id: I9631f33eafe2cfb64388d8e19c6ed8d1e948a6fa Closes-Bug: #1520635 --- cinder/tests/unit/test_emc_vmax.py | 49 ++++++++++++++------ cinder/volume/drivers/emc/emc_vmax_common.py | 1 + cinder/volume/drivers/emc/emc_vmax_fc.py | 2 + cinder/volume/drivers/emc/emc_vmax_iscsi.py | 2 + 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/cinder/tests/unit/test_emc_vmax.py b/cinder/tests/unit/test_emc_vmax.py index d789a8523..3e7d510c3 100644 --- a/cinder/tests/unit/test_emc_vmax.py +++ b/cinder/tests/unit/test_emc_vmax.py @@ -813,8 +813,7 @@ class FakeEcomConnection(object): return unitnames - def _ref_unitnames2(self): - unitnames = [] + def mv_entry(self, mvname): unitname = {} dependent = {} @@ -829,28 +828,28 @@ class FakeEcomConnection(object): classcimproperty = Fake_CIMProperty() elementName = ( - classcimproperty.fake_getElementNameCIMProperty('OS-myhost-MV')) + classcimproperty.fake_getElementNameCIMProperty(mvname)) properties = {u'ElementName': elementName} antecedent.properties = properties unitname['Dependent'] = dependent unitname['Antecedent'] = antecedent unitname['CreationClassName'] = self.data.unit_creationclass + return unitname + + def _ref_unitnames2(self): + unitnames = [] + unitname = self.mv_entry('OS-myhost-MV') unitnames.append(unitname) # Second masking - unitname2 = unitname.copy() - elementName2 = ( - classcimproperty.fake_getElementNameCIMProperty('OS-fakehost-MV')) - properties2 = {u'ElementName': elementName2} - - antecedent2 = SYMM_LunMasking() - antecedent2['CreationClassName'] = self.data.lunmask_creationclass2 - antecedent2['SystemName'] = self.data.storage_system - - antecedent2.properties = properties2 - unitname2['Antecedent'] = antecedent2 + unitname2 = self.mv_entry('OS-fakehost-MV') unitnames.append(unitname2) + + # third masking + amended = 'OS-rslong493156848e71b072a17c1c4625e45f75-MV' + unitname3 = self.mv_entry(amended) + unitnames.append(unitname3) return unitnames def _default_ref(self, objectpath): @@ -2022,9 +2021,29 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase): data = ( self.driver.common.find_device_number(self.data.test_volume_v2, host)) - # Empty dict self.assertFalse(data) + def test_find_device_number_long_host(self): + # Long host name + host = 'myhost.mydomain.com' + data = ( + self.driver.common.find_device_number(self.data.test_volume_v2, + host)) + self.assertEqual('OS-myhost-MV', data['maskingview']) + + def test_find_device_number_short_name_over_38_chars(self): + # short name over 38 chars + host = 'myShortnameIsOverThirtyEightCharactersLong' + host = self.driver.common.utils.generate_unique_trunc_host(host) + amended = 'OS-' + host + '-MV' + v2_host_over_38 = self.data.test_volume_v2.copy() + # Pool aware scheduler enabled + v2_host_over_38['host'] = host + data = ( + self.driver.common.find_device_number(v2_host_over_38, + host)) + self.assertEqual(amended, data['maskingview']) + def test_unbind_and_get_volume_from_storage_pool(self): conn = self.fake_ecom_connection() common = self.driver.common diff --git a/cinder/volume/drivers/emc/emc_vmax_common.py b/cinder/volume/drivers/emc/emc_vmax_common.py index f1935fe54..928e0cd6c 100644 --- a/cinder/volume/drivers/emc/emc_vmax_common.py +++ b/cinder/volume/drivers/emc/emc_vmax_common.py @@ -1472,6 +1472,7 @@ class EMCVMAXCommon(object): {'volumeName': volumeName, 'volumeInstance': volumeInstance.path}) else: + host = self.utils.get_host_short_name(host) hoststr = ("-%(host)s-" % {'host': host}) diff --git a/cinder/volume/drivers/emc/emc_vmax_fc.py b/cinder/volume/drivers/emc/emc_vmax_fc.py index f8b44945b..4b3a286ed 100644 --- a/cinder/volume/drivers/emc/emc_vmax_fc.py +++ b/cinder/volume/drivers/emc/emc_vmax_fc.py @@ -44,6 +44,8 @@ class EMCVMAXFCDriver(driver.FibreChannelDriver): 2.2.4 - Create CG from CG snapshot 2.3.0 - Name change for MV and SG for FAST (bug #1515181) - Fix for randomly choosing port group. (bug #1501919) + - get_short_host_name needs to be called in find_device_number + (bug #1520635) """ VERSION = "2.3.0" diff --git a/cinder/volume/drivers/emc/emc_vmax_iscsi.py b/cinder/volume/drivers/emc/emc_vmax_iscsi.py index 3161a51ab..605aef1cf 100644 --- a/cinder/volume/drivers/emc/emc_vmax_iscsi.py +++ b/cinder/volume/drivers/emc/emc_vmax_iscsi.py @@ -52,6 +52,8 @@ class EMCVMAXISCSIDriver(driver.ISCSIDriver): 2.2.4 - Create CG from CG snapshot 2.3.0 - Name change for MV and SG for FAST (bug #1515181) - Fix for randomly choosing port group. (bug #1501919) + - get_short_host_name needs to be called in find_device_number + (bug #1520635) """ VERSION = "2.3.0" -- 2.45.2