Merge "NSX|V: ensure that DVS name is unique"

This commit is contained in:
Jenkins 2017-03-05 14:47:48 +00:00 committed by Gerrit Code Review
commit 319b125fa9
2 changed files with 6 additions and 7 deletions

View File

@ -834,14 +834,13 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
def _get_vlan_network_name(self, net_data, dvs_id):
if net_data.get('name') is None:
net_data['name'] = ''
# Maximum name length is 80 characters. 'id' length is 36
# maximum prefix for name plus dvs-id is 43
if net_data['name'] == '':
# Include only the first 8 characters from the dvs-id.
return '%s-%s' % (dvs_id[:8], net_data['id'])
prefix = dvs_id[:43]
else:
# Maximum name length is 80 characters. 'id' length is 36
# maximum prefix for name plus dvs-id is 43
return '%s-%s-%s' % (dvs_id[:8], net_data['name'][:35],
net_data['id'])
prefix = ('%s-%s' % (dvs_id, net_data['name']))[:43]
return '%s-%s' % (prefix, net_data['id'])
def _update_network_teaming(self, dvs_id, net_id, net_moref):
if self._vcm:

View File

@ -212,7 +212,7 @@ class NsxVPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
name = 'X' * 500
net = {'name': name,
'id': net_id}
expected = '%s-%s-%s' % (dvs_id, name[:35], net_id)
expected = '%s-%s-%s' % (dvs_id, name[:36], net_id)
self.assertEqual(expected,
p._get_vlan_network_name(net, dvs_id))