Enable SVI networks with hosts running opflex agent

- Allow port binding on SVI networks with hosts running opflex agent
- Supported with vlan type networks (not opflex networks)
- Provides a flag indicating SVI network, the vlan id and the epg is
  set to a unique id (SVI network id) in response to get_gbp_details.
  This enables the opflex agent on the host to set up the data path
  appropriately.

Change-Id: Ia0a3e4354141b04693fda8c1079acbbc76f371d9
(cherry picked from commit 5aee410131)
(cherry picked from commit 0f3e3fb258)
(cherry picked from commit b3fb219e3f)
This commit is contained in:
Sridar Kandaswamy 2020-01-07 11:16:50 -08:00
parent 81794edd8a
commit be28c03e76
3 changed files with 73 additions and 4 deletions

View File

@ -2695,7 +2695,8 @@ class ApicMechanismDriver(api_plus.MechanismDriver,
def _opflex_bind_port(self, context, segment, agent):
network_type = segment[api.NETWORK_TYPE]
if self._is_opflex_type(network_type):
if (self._is_opflex_type(network_type) or
network_type == pconst.TYPE_VLAN):
opflex_mappings = agent['configurations'].get('opflex_networks')
LOG.debug("Checking segment: %(segment)s "
"for physical network: %(mappings)s ",

View File

@ -76,6 +76,7 @@ EndpointPortInfo = namedtuple(
# Not in newton: 'nested_domain_infra_vlan',
# Not in newton: 'nested_domain_service_vlan',
# Not in newton: 'nested_domain_node_network_vlan',
'svi',
'epg_name',
'epg_app_profile_name',
'epg_tenant_name',
@ -100,7 +101,8 @@ EndpointBindingInfo = namedtuple(
['host',
'level',
'network_type',
'physical_network'])
'physical_network',
'segmentation_id'])
EndpointSecurityGroupInfo = namedtuple(
'EndpointSecurityGroupInfo',
@ -508,6 +510,7 @@ class ApicRpcHandlerMixin(object):
# nested_domain_service_vlan,
# Not in newton: extension_db.NetworkExtensionDb.
# nested_domain_node_network_vlan,
extension_db.NetworkExtensionDb.svi,
db.NetworkMapping.epg_name,
db.NetworkMapping.epg_app_profile_name,
db.NetworkMapping.epg_tenant_name,
@ -599,6 +602,7 @@ class ApicRpcHandlerMixin(object):
ml2_models.PortBindingLevel.level,
segment_models.NetworkSegment.network_type,
segment_models.NetworkSegment.physical_network,
segment_models.NetworkSegment.segmentation_id,
))
query += lambda q: q.join(
segment_models.NetworkSegment,
@ -897,6 +901,7 @@ class ApicRpcHandlerMixin(object):
details['network_id'] = port_info.network_id
details['network_type'] = binding_info[-1].network_type
details['physical_network'] = binding_info[-1].physical_network
details['segmentation_id'] = binding_info[-1].segmentation_id
details['port_id'] = port_info.port_id
return details
@ -931,7 +936,11 @@ class ApicRpcHandlerMixin(object):
details['dns_domain'] = port_info.net_dns_domain or ''
details['enable_dhcp_optimization'] = self.enable_dhcp_opt
details['enable_metadata_optimization'] = self.enable_metadata_opt
details['endpoint_group_name'] = port_info.epg_name
if port_info.svi:
details['endpoint_group_name'] = port_info.network_id
details['svi'] = True
else:
details['endpoint_group_name'] = port_info.epg_name
details['floating_ip'] = self._build_fips(info)
details['host'] = port_info.host
details['host_snat_ips'] = self._build_host_snat_ips(

View File

@ -345,7 +345,8 @@ class ApicAimTestCase(test_address_scope.AddressScopeTestCase,
'apic:nat_type', SNAT_POOL,
ACTIVE_ACTIVE_AAP,
CIDR, PROV, CONS, SVI,
BGP, BGP_TYPE, ASN
BGP, BGP_TYPE, ASN,
'provider:network_type'
)
self.name_mapper = apic_mapper.APICNameMapper()
self.t1_aname = self.name_mapper.project(None, 't1')
@ -4722,6 +4723,28 @@ class TestPortBinding(ApicAimTestCase):
self.assertEqual({'port_filter': False, 'ovs_hybrid_plug': False},
port['binding:vif_details'])
def test_bind_opflex_agent_svi(self):
self._register_agent('host1', AGENT_CONF_OPFLEX)
aim_ctx = aim_context.AimContext(self.db_session)
hlink_1 = aim_infra.HostLink(
host_name='host1',
interface_name='eth1',
path='topology/pod-1/paths-102/pathep-[eth1/8]')
self.aim_mgr.create(aim_ctx, hlink_1)
net = self._make_network(self.fmt, 'net1', True,
arg_list=self.extension_attributes,
**{'apic:svi': 'True', 'provider:network_type': u'vlan'})
self._make_subnet(self.fmt, net, '10.0.1.1', '10.0.1.0/24')
port = self._make_port(self.fmt, net['network']['id'])['port']
port_id = port['id']
port = self._bind_port_to_host(port_id, 'host1')['port']
self.assertEqual('ovs', port['binding:vif_type'])
self.assertEqual({'port_filter': False, 'ovs_hybrid_plug': False},
port['binding:vif_details'])
def test_bind_opflex_agent_with_firewall_enabled(self):
self.driver.enable_iptables_firewall = True
self._register_agent('host1', AGENT_CONF_OPFLEX)
@ -9131,6 +9154,42 @@ class TestOpflexRpc(ApicAimTestCase):
def test_endpoint_details_bound_active_active_aap(self):
self._test_endpoint_details_bound(active_active_aap=True)
def test_endpoint_details_bound_svi(self):
self._register_agent('h1', AGENT_CONF_OPFLEX)
aim_ctx = aim_context.AimContext(self.db_session)
hlink_1 = aim_infra.HostLink(
host_name='h1',
interface_name='eth1',
path='topology/pod-1/paths-102/pathep-[eth1/8]')
self.aim_mgr.create(aim_ctx, hlink_1)
network = self._make_network(self.fmt, 'net1', True,
arg_list=self.extension_attributes,
**{'apic:svi': 'True',
'provider:network_type': u'vlan'})
net1 = network['network']
gw1_ip = '10.0.1.1'
self._make_subnet(self.fmt, network, gw1_ip, cidr='10.0.1.0/24')
# Make a VM port.
p1 = self._make_port(self.fmt, net1['id'],
device_owner='compute:')['port']
self._bind_port_to_host(p1['id'], 'h1')
request = {
'device': 'tap' + p1['id'],
'timestamp': 12345,
'request_id': 'a_request'
}
response = self.driver.request_endpoint_details(
n_context.get_admin_context(), request=request, host='h1')
gbp_details = response['gbp_details']
self.assertEqual(True, gbp_details.get('svi'))
neutron_details = response['neutron_details']
self.assertEqual(net1['provider:segmentation_id'],
neutron_details.get('segmentation_id'))
def test_endpoint_details_unbound(self):
host = 'host1'
net = self._make_network(self.fmt, 'net1', True)