NSX|V3: ensure that tag length does not exceed 40 characters
This is alimitation on the backend platforms. Change-Id: Ic26525a4eca8114d31abe484a1c2c4075889e675 Closes-bug: #1530058
This commit is contained in:
parent
cf31578ac9
commit
ce351637ed
@ -29,6 +29,7 @@ LOG = log.getLogger(__name__)
|
||||
|
||||
MAX_DISPLAY_NAME_LEN = 40
|
||||
MAX_RESOURCE_TYPE_LEN = 20
|
||||
MAX_TAG_LEN = 40
|
||||
NEUTRON_VERSION = version.version_info.release_string()
|
||||
NSX_NEUTRON_PLUGIN = 'NSX Neutron plugin'
|
||||
OS_NEUTRON_ID_SCOPE = 'os-neutron-id'
|
||||
@ -132,13 +133,13 @@ def build_v3_tags_payload(resource, resource_type, project_name):
|
||||
if not project_name:
|
||||
project_name = 'NSX Neutron plugin'
|
||||
return [{'scope': resource_type,
|
||||
'tag': resource.get('id', '')},
|
||||
'tag': resource.get('id', '')[:MAX_TAG_LEN]},
|
||||
{'scope': 'os-project-id',
|
||||
'tag': resource.get('tenant_id', '')},
|
||||
'tag': resource.get('tenant_id', '')[:MAX_TAG_LEN]},
|
||||
{'scope': 'os-project-name',
|
||||
'tag': project_name},
|
||||
'tag': project_name[:MAX_TAG_LEN]},
|
||||
{'scope': 'os-api-version',
|
||||
'tag': version.version_info.release_string()}]
|
||||
'tag': version.version_info.release_string()[:MAX_TAG_LEN]}]
|
||||
|
||||
|
||||
def retry_upon_exception_nsxv3(exc, delay=500, max_delay=2000,
|
||||
|
@ -451,3 +451,16 @@ class TestNsxV3Utils(NsxV3PluginTestCaseMixin):
|
||||
expected = '%s%s' % ('X' * (80 - len(suffix)), suffix)
|
||||
short_name = utils.get_name_and_uuid(name, uuid)
|
||||
self.assertEqual(expected, short_name)
|
||||
|
||||
def test_build_v3_tags_max_length_payload(self):
|
||||
result = utils.build_v3_tags_payload(
|
||||
{'id': 'X' * 255,
|
||||
'tenant_id': 'X' * 255},
|
||||
resource_type='os-neutron-net-id',
|
||||
project_name='X' * 255)
|
||||
expected = [{'scope': 'os-neutron-net-id', 'tag': 'X' * 40},
|
||||
{'scope': 'os-project-id', 'tag': 'X' * 40},
|
||||
{'scope': 'os-project-name', 'tag': 'X' * 40},
|
||||
{'scope': 'os-api-version',
|
||||
'tag': version.version_info.release_string()}]
|
||||
self.assertEqual(expected, result)
|
||||
|
Loading…
Reference in New Issue
Block a user