diff --git a/vmware_nsx/common/utils.py b/vmware_nsx/common/utils.py index 5896094bdd..c24b636c9f 100644 --- a/vmware_nsx/common/utils.py +++ b/vmware_nsx/common/utils.py @@ -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 diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index 68e8a6e6a1..fe9783dee3 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -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)