From 777c9d0f7c89d7b35ceb808498a779f268a21ab0 Mon Sep 17 00:00:00 2001 From: Helen Walsh Date: Tue, 26 Jan 2016 23:12:37 +0000 Subject: [PATCH] EMC VMAX - Limit SG and MV to 64 characters VMAX restricts storage group and masking view names to a maximum length of 64 characters. This patch only adds extra unit tests to prove that both MV and SG names are below the 64 chars in all scenarios. Change-Id: I72917a56083eb25f876b9cdeaa30511793922497 --- cinder/tests/unit/test_emc_vmax.py | 18 +++++++++++++++++- cinder/volume/drivers/emc/emc_vmax_utils.py | 6 ++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cinder/tests/unit/test_emc_vmax.py b/cinder/tests/unit/test_emc_vmax.py index bd87d3474..ad02ca296 100644 --- a/cinder/tests/unit/test_emc_vmax.py +++ b/cinder/tests/unit/test_emc_vmax.py @@ -1933,14 +1933,30 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase): self.assertEqual( 'OS-fakehost-gold_pool-I-MV', maskingViewDict['maskingViewName']) + def test_populate_masking_dict_fast_both_exceeding(self): # If the length of the FAST policy name is greater than 14 chars and # the length of the short host is more than 38 characters + extraSpecs = self.populate_masking_dict_setup() connector = {'host': 'SHORT_HOST_MORE_THEN THIRTY_EIGHT_CHARACTERS'} extraSpecs['storagetype:fastpolicy'] = ( 'GOLD_MORE_THAN_FOURTEEN_CHARACTERS') maskingViewDict = self.driver.common._populate_masking_dict( self.data.test_volume, connector, extraSpecs) - self.assertLessEqual(64, len(maskingViewDict['sgGroupName'])) + self.assertLessEqual(len(maskingViewDict['sgGroupName']), 64) + self.assertLessEqual(len(maskingViewDict['maskingViewName']), 64) + + def test_populate_masking_dict_no_fast_both_exceeding(self): + # If the length of the FAST policy name is greater than 14 chars and + # the length of the short host is more than 38 characters + extraSpecs = self.populate_masking_dict_setup() + connector = {'host': 'SHORT_HOST_MORE_THEN THIRTY_EIGHT_CHARACTERS'} + extraSpecs['storagetype:pool'] = ( + 'GOLD_POOL_MORE_THAN_SIXTEEN_CHARACTERS') + extraSpecs['storagetype:fastpolicy'] = None + maskingViewDict = self.driver.common._populate_masking_dict( + self.data.test_volume, connector, extraSpecs) + self.assertLessEqual(len(maskingViewDict['sgGroupName']), 64) + self.assertLessEqual(len(maskingViewDict['maskingViewName']), 64) def test_filter_list(self): portgroupnames = ['pg3', 'pg1', 'pg4', 'pg2'] diff --git a/cinder/volume/drivers/emc/emc_vmax_utils.py b/cinder/volume/drivers/emc/emc_vmax_utils.py index a065a2505..ba7167035 100644 --- a/cinder/volume/drivers/emc/emc_vmax_utils.py +++ b/cinder/volume/drivers/emc/emc_vmax_utils.py @@ -40,6 +40,8 @@ except ImportError: STORAGEGROUPTYPE = 4 POSTGROUPTYPE = 3 CLONE_REPLICATION_TYPE = 10 +MAX_POOL_LENGTH = 16 +MAX_FASTPOLICY_LENGTH = 14 EMC_ROOT = 'root/emc' CONCATENATED = 'concatenated' @@ -2363,7 +2365,7 @@ class EMCVMAXUtils(object): :param poolName: long pool name :returns: truncated pool name """ - if poolName and len(poolName) > 16: + if poolName and len(poolName) > MAX_POOL_LENGTH: return ( ("%(first)s_%(last)s" % {'first': poolName[:8], @@ -2377,7 +2379,7 @@ class EMCVMAXUtils(object): :param fastPolicyName: long fast policy name :returns: truncated fast policy name """ - if fastPolicyName and len(fastPolicyName) > 14: + if fastPolicyName and len(fastPolicyName) > MAX_FASTPOLICY_LENGTH: return ( ("%(first)s_%(last)s" % {'first': fastPolicyName[:7], -- 2.45.2