diff --git a/vmware_nsx/dvs/dvs.py b/vmware_nsx/dvs/dvs.py index 0f0a207db8..85299a14cf 100644 --- a/vmware_nsx/dvs/dvs.py +++ b/vmware_nsx/dvs/dvs.py @@ -447,3 +447,21 @@ class DvsManager(object): vm_moref, "config.hardware.device") return hardware_devices + + def update_port_group_spec_teaming(self, pg_spec, teaming_data): + mapping = {'FAILOVER_ORDER': 'failover_explicit', + 'ETHER_CHANNEL': 'loadbalance_ip', + 'LACP_ACTIVE': 'loadbalance_ip', + 'LACP_PASSIVE': 'loadbalance_ip', + 'LACP_V2': 'loadbalance_ip', + 'LOADBALANCE_SRCID': 'loadbalance_srcid', + 'LOADBALANCE_SRCMAC': 'loadbalance_srcmac', + 'LOADBALANCE_LOADBASED': 'loadbalance_loadbased'} + port_conf = pg_spec.defaultPortConfig + policy = port_conf.uplinkTeamingPolicy + policy.inherited = False + policy.policy.inherited = False + policy.policy.value = mapping[teaming_data['teamingPolicy']] + policy.uplinkPortOrder.inherited = False + ports = teaming_data['failoverUplinkPortNames'] + policy.uplinkPortOrder.activeUplinkPort = ports diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index 12378d4893..d2e57730e1 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -700,6 +700,19 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, return '%s-%s-%s' % (dvs_id[:8], net_data['name'][:35], net_data['id']) + def _update_network_teaming(self, dvs_id, net_id, net_moref): + if self._dvs: + h, switch = self.nsx_v.vcns.get_vdn_switch(dvs_id) + try: + self._dvs.update_port_groups_config( + net_id, net_moref, + self._dvs.update_port_group_spec_teaming, + switch) + except Exception as e: + LOG.error(_LE('Unable to update teaming information for ' + 'net %(net_id)s. Error: %(e)s'), + {'net_id': net_id, 'e': e}) + def _create_vlan_network_at_backend(self, net_data, dvs_id): network_name = self._get_vlan_network_name(net_data, dvs_id) segment = net_data[mpnet.SEGMENTS][0] @@ -715,12 +728,13 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, try: h, c = self.nsx_v.vcns.create_port_group(dvs_id, config_spec) - return c except Exception as e: error = (_("Failed to create port group on DVS: %(dvs_id)s. " "Reason: %(reason)s") % {'dvs_id': dvs_id, 'reason': e.response}) raise nsx_exc.NsxPluginException(err_msg=error) + self._update_network_teaming(dvs_id, net_data['id'], c) + return c def _get_dvs_ids(self, physical_network): """Extract DVS-IDs provided in the physical network field. diff --git a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py index 3f4fef372b..fa6e38fbbc 100644 --- a/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py +++ b/vmware_nsx/plugins/nsx_v/vshield/edge_utils.py @@ -448,7 +448,8 @@ class EdgeManager(object): context, network_id) pg, port_group_id = self.nsxv_manager.vcns.create_port_group( dvs_id, config_spec) - + # Ensure that the portgroup has the correct teaming + self.plugin._update_network_teaming(dvs_id, None, port_group_id) interface = { 'name': _uuid(), 'tunnelId': tunnel_index,