NSX|V: ensure correct teaming for port groups

Ensures that port groups created for VLAN's and edges have the
correct teaming policies.

Change-Id: Ie1adfdb216fe8745d0347deba1bb9701a51e6fe3
This commit is contained in:
Gary Kotton 2016-11-21 04:04:21 -08:00
parent 4798f3986d
commit 4eaf21c977
3 changed files with 35 additions and 2 deletions

View File

@ -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

View File

@ -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.

View File

@ -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,