From a856341b73f490d6dcb8f09e06dc87a9bf9c2e87 Mon Sep 17 00:00:00 2001 From: Gary Kotton Date: Fri, 24 Feb 2017 06:55:41 -0800 Subject: [PATCH] NSX|V: add support for VLAN trunk with VLAN network Completes the VLAN trunk support Change-Id: Ied8a299428486938d2006badf572c1308ccf1269 --- vmware_nsx/dvs/dvs.py | 4 ++++ vmware_nsx/plugins/nsx_v/plugin.py | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/vmware_nsx/dvs/dvs.py b/vmware_nsx/dvs/dvs.py index 0b8d4985df..06c883ced3 100644 --- a/vmware_nsx/dvs/dvs.py +++ b/vmware_nsx/dvs/dvs.py @@ -428,6 +428,10 @@ class DvsManager(VCManagerBase): standby = list(set(uplinks.uplinkPortName) - set(ports)) policy.uplinkPortOrder.standbyUplinkPort = standby + def update_port_group_spec_trunk(self, pg_spec, trunk_data): + port_conf = pg_spec.defaultPortConfig + port_conf.vlan = self._get_trunk_vlan_spec() + class VMManager(VCManagerBase): """Management class for VMs related VC tasks.""" diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index ccf25a877f..78b14a9790 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -1087,9 +1087,6 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, net_morefs = [segment.get(pnet.PHYSICAL_NETWORK)] dvs_net_ids = [net_data['name']] else: - if vlt: - raise NotImplementedError(_("Transparent support only " - "for VXLANs")) segment = net_data[mpnet.SEGMENTS][0] physical_network = segment.get(pnet.PHYSICAL_NETWORK) # Retrieve the list of dvs-ids from physical network. @@ -1119,6 +1116,21 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, net_morefs.append(net_moref) dvs_net_ids.append(self._get_vlan_network_name( net_data, dvs_id)) + if vlt: + try: + self._vcm.update_port_groups_config( + dvs_id, net_data['id'], net_moref, + self._vcm.update_port_group_spec_trunk, + {}) + except Exception: + with excutils.save_and_reraise_exception(): + # Delete VLAN networks on other DVSes if it + # fails to be created on one DVS and reraise + # the original exception. + for dvsmoref, netmoref in six.iteritems( + dvs_pg_mappings): + self._delete_backend_network( + netmoref, dvsmoref) try: net_data[psec.PORTSECURITY] = net_data.get(psec.PORTSECURITY, True) # Create SpoofGuard policy for network anti-spoofing