Merge "NSX|V3: fix short-name notation"
This commit is contained in:
commit
4e64429d6b
@ -200,7 +200,6 @@ def read_file(path):
|
||||
|
||||
|
||||
def get_name_and_uuid(name, uuid, maxlen=80):
|
||||
# TODO(garyk):the second '_' should be '...'. Pending backend support
|
||||
short_uuid = '_' + uuid[:5] + '_' + uuid[-5:]
|
||||
short_uuid = '_' + uuid[:5] + '...' + uuid[-5:]
|
||||
maxlen = maxlen - len(short_uuid)
|
||||
return name[:maxlen] + short_uuid
|
||||
|
@ -439,3 +439,15 @@ class TestNsxV3Utils(NsxV3PluginTestCaseMixin):
|
||||
|
||||
expect_true = utils.is_internal_resource({'tags': internal_tag})
|
||||
self.assertTrue(expect_true)
|
||||
|
||||
def test_get_name_and_uuid(self):
|
||||
uuid = 'afc40f8a-4967-477e-a17a-9d560d1786c7'
|
||||
suffix = '_afc40...786c7'
|
||||
expected = 'maldini%s' % suffix
|
||||
short_name = utils.get_name_and_uuid('maldini', uuid)
|
||||
self.assertEqual(expected, short_name)
|
||||
|
||||
name = 'X' * 255
|
||||
expected = '%s%s' % ('X' * (80 - len(suffix)), suffix)
|
||||
short_name = utils.get_name_and_uuid(name, uuid)
|
||||
self.assertEqual(expected, short_name)
|
||||
|
Loading…
x
Reference in New Issue
Block a user