From 98dc3001087ed743f81db70f86802eded6a1a045 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Sat, 25 Nov 2017 23:06:26 -0800 Subject: [PATCH] NSX|V: support name update for VLAN and FLAT networks Ensure that the VC updates the network name for a network update for a VLAN/FLAT provider network. This is only for networks created by the plugin. Change-Id: I7f784a47697a13b5366bf78dba5b789b9d93bbd2 --- vmware_nsx/dvs/dvs.py | 3 +++ vmware_nsx/plugins/nsx_v/plugin.py | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/vmware_nsx/dvs/dvs.py b/vmware_nsx/dvs/dvs.py index 7d4792c74a..5ed3271e9f 100644 --- a/vmware_nsx/dvs/dvs.py +++ b/vmware_nsx/dvs/dvs.py @@ -440,6 +440,9 @@ class DvsManager(VCManagerBase): standby = list(set(uplinks.uplinkPortName) - set(ports)) policy.uplinkPortOrder.standbyUplinkPort = standby + def update_port_group_spec_name(self, pg_spec, name): + pg_spec.name = name + def update_port_group_spec_trunk(self, pg_spec, trunk_data): port_conf = pg_spec.defaultPortConfig port_conf.vlan = self._get_trunk_vlan_spec() diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index 07a0499787..37b54ecd08 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -1688,6 +1688,29 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, net_res[qos_consts.QOS_POLICY_ID] = ( qos_com_utils.get_network_policy_id(context, id)) + # Handle case of network name update - this only is relevant for + # networks that we create - not portgroup providers + if (net_attrs.get('name') and + orig_net.get('name') != net_attrs.get('name') and + (orig_net.get(pnet.NETWORK_TYPE) == + c_utils.NsxVNetworkTypes.VLAN or + orig_net.get(pnet.NETWORK_TYPE) == + c_utils.NsxVNetworkTypes.FLAT)): + # Only update networks created by plugin + mappings = nsx_db.get_nsx_network_mappings(context.session, id) + for mapping in mappings: + network_name = self._get_vlan_network_name(net_res, + mapping.dvs_id) + try: + self._vcm.update_port_groups_config( + mapping.dvs_id, id, mapping.nsx_id, + self._dvs.update_port_group_spec_name, + network_name) + except Exception as e: + LOG.error('Unable to update name for net %(net_id)s. ' + 'Error: %(e)s', + {'net_id': id, 'e': e}) + return net_res def _validate_address_pairs(self, attrs, db_port):