Set logical switch os_neutron_id tag
The os_neutron_id tag in logical switches had been omitted since the neutron id is the same as the UUID on the backend. However, users might perceive the blank space as missing information. Make an extra call to set the tag once the switch has been created. Closes-bug: #1527152 Change-Id: I800cb0736bc5e555e2b094458efb180eb7790db5
This commit is contained in:
parent
bcb424ac8d
commit
b3532f8378
@ -102,7 +102,7 @@ def get_logical_switch(logical_switch_id):
|
||||
|
||||
@utils.retry_upon_exception_nsxv3(nsx_exc.StaleRevision,
|
||||
max_attempts=cfg.CONF.nsx_v3.retries)
|
||||
def update_logical_switch(lswitch_id, name=None, admin_state=None):
|
||||
def update_logical_switch(lswitch_id, name=None, admin_state=None, tags=None):
|
||||
resource = "logical-switches/%s" % lswitch_id
|
||||
lswitch = get_logical_switch(lswitch_id)
|
||||
if name is not None:
|
||||
@ -112,6 +112,8 @@ def update_logical_switch(lswitch_id, name=None, admin_state=None):
|
||||
lswitch['admin_state'] = nsx_constants.ADMIN_STATE_UP
|
||||
else:
|
||||
lswitch['admin_state'] = nsx_constants.ADMIN_STATE_DOWN
|
||||
if tags is not None:
|
||||
lswitch['tags'] = tags
|
||||
return client.update_resource(resource, lswitch)
|
||||
|
||||
|
||||
|
@ -367,8 +367,22 @@ class NsxV3Plugin(addr_pair_db.AllowedAddressPairsMixin,
|
||||
result = nsxlib.create_logical_switch(net_name, physical_net, tags,
|
||||
admin_state=admin_state,
|
||||
vlan_id=vlan_id)
|
||||
|
||||
# The logical switch's UUID is used as the id for the neutron network
|
||||
# (via net_data, which is used below, in create_network). Now that we
|
||||
# have a UUID for the logical switch, set that as the neutron network
|
||||
# id in the switch's tags. Note errors but no rollback is needed here.
|
||||
network_id = result['id']
|
||||
net_data['id'] = network_id
|
||||
network_tags = result['tags']
|
||||
for tag in network_tags:
|
||||
if tag['scope'] == 'os-neutron-id':
|
||||
tag['tag'] = network_id
|
||||
try:
|
||||
nsxlib.update_logical_switch(network_id, tags=network_tags)
|
||||
except nsx_exc.ManagerError:
|
||||
LOG.exception(_LE("Unable to update network tags on NSX backend"))
|
||||
|
||||
return (is_provider_net, net_type, physical_net, vlan_id)
|
||||
|
||||
def _extend_network_dict_provider(self, context, network, bindings=None):
|
||||
|
Loading…
x
Reference in New Issue
Block a user