[apic-mapping] Explicit end of the chain for ptgs
Closes-bug: #1607967
Change-Id: I85ed4ccee67c9a38c37e6c22802be1e1322643a2
(cherry picked from commit 36c56dfd7b)
This commit is contained in:
@@ -240,6 +240,13 @@ class ApicMappingTestCase(
|
||||
self.driver.apic_manager.apic.fvCtx.name = echo2
|
||||
self._db_plugin = n_db.NeutronDbPluginV2()
|
||||
|
||||
def _get_pts_addresses(self, pts):
|
||||
addresses = []
|
||||
for pt in pts:
|
||||
port = self._get_object('ports', pt['port_id'], self.api)['port']
|
||||
addresses.extend([x['ip_address'] for x in port['fixed_ips']])
|
||||
return addresses
|
||||
|
||||
def _build_external_dict(self, name, cidr_exposed, is_edge_nat=False):
|
||||
ext_info = {
|
||||
'enable_nat': 'True' if self.nat_enabled else 'False'
|
||||
@@ -549,6 +556,24 @@ class TestPolicyTarget(ApicMappingTestCase):
|
||||
details['host_snat_ip'])
|
||||
self.assertEqual(24, details['prefixlen'])
|
||||
|
||||
def test_get_gbp_details_extra_ips_explicit_eoc(self):
|
||||
ptg = self.create_policy_target_group(
|
||||
name="ptg1")['policy_target_group']
|
||||
pt1 = self.create_policy_target(
|
||||
policy_target_group_id=ptg['id'])['policy_target']
|
||||
ptg2 = self.create_policy_target_group(
|
||||
name="ptg2",
|
||||
description='opflex_eoc:' + pt1['port_id'],
|
||||
is_admin_context=True)['policy_target_group']
|
||||
pt2 = self.create_policy_target(
|
||||
policy_target_group_id=ptg2['id'])['policy_target']
|
||||
mapping = self.driver.get_gbp_details(context.get_admin_context(),
|
||||
device='tap%s' % pt1['port_id'], host='h2')
|
||||
|
||||
# Extra ip set for pt2
|
||||
ips = self._get_pts_addresses([pt2])
|
||||
self.assertEqual(set(ips), set(mapping['extra_ips']))
|
||||
|
||||
def test_snat_pool_subnet_deletion(self):
|
||||
self._mock_external_dict([('supported', '192.168.0.2/24')])
|
||||
self.driver.apic_manager.ext_net_dict[
|
||||
@@ -1096,6 +1121,55 @@ class TestPolicyTarget(ApicMappingTestCase):
|
||||
self.assertEqual('1.1.1.1', entries[0].ha_ip_address)
|
||||
self.assertEqual('1.1.1.1', entries[1].ha_ip_address)
|
||||
|
||||
def test_explicit_end_of_chain(self):
|
||||
self.driver._notify_port_update = mock.Mock()
|
||||
ptg = self.create_policy_target_group(
|
||||
name="ptg1")['policy_target_group']
|
||||
pt1 = self.create_policy_target(
|
||||
policy_target_group_id=ptg['id'])['policy_target']
|
||||
ptg2 = self.create_policy_target_group(
|
||||
name="ptg2",
|
||||
description='opflex_eoc:' + pt1['port_id'],
|
||||
is_admin_context=True)['policy_target_group']
|
||||
self.create_policy_target(policy_target_group_id=ptg2['id'])
|
||||
# pt1 notified
|
||||
self.driver._notify_port_update.assert_called_once_with(
|
||||
mock.ANY, pt1['port_id'])
|
||||
|
||||
def test_explicit_end_of_chain_cluster(self):
|
||||
self.driver._notify_port_update = mock.Mock()
|
||||
ptg = self.create_policy_target_group(
|
||||
name="ptg1")['policy_target_group']
|
||||
pt1 = self.create_policy_target(
|
||||
policy_target_group_id=ptg['id'])['policy_target']
|
||||
# Same cluster
|
||||
pt2 = self.create_policy_target(
|
||||
policy_target_group_id=ptg['id'],
|
||||
cluster_id=pt1['id'])['policy_target']
|
||||
pt3 = self.create_policy_target(
|
||||
policy_target_group_id=ptg['id'],
|
||||
cluster_id=pt1['id'])['policy_target']
|
||||
ptg2 = self.create_policy_target_group(
|
||||
name="ptg2",
|
||||
description='opflex_eoc:' + pt1['port_id'],
|
||||
is_admin_context=True)['policy_target_group']
|
||||
self.create_policy_target(policy_target_group_id=ptg2['id'])
|
||||
# pt1, 2 and 3 notified
|
||||
expected_calls = [
|
||||
mock.call(mock.ANY, pt1['port_id']),
|
||||
mock.call(mock.ANY, pt2['port_id']),
|
||||
mock.call(mock.ANY, pt3['port_id'])]
|
||||
self._check_call_list(
|
||||
expected_calls, self.driver._notify_port_update.call_args_list)
|
||||
|
||||
def test_explicit_eoc_raises(self):
|
||||
ptg = self.create_policy_target_group(
|
||||
name="ptg1")['policy_target_group']
|
||||
self.create_policy_target_group(
|
||||
name="ptg2", description='opflex_eoc:', expected_res_status=400)
|
||||
self.update_policy_target_group(
|
||||
ptg['id'], description='opflex_eoc:', expected_res_status=400)
|
||||
|
||||
|
||||
class TestPolicyTargetVlanNetwork(ApicMappingVlanTestCase,
|
||||
TestPolicyTarget):
|
||||
|
||||
@@ -809,13 +809,6 @@ class TestApicChains(ApicMappingStitchingPlumberGBPTestCase,
|
||||
|
||||
class TestProxyGroup(ApicMappingStitchingPlumberGBPTestCase):
|
||||
|
||||
def _get_pts_addresses(self, pts):
|
||||
addresses = []
|
||||
for pt in pts:
|
||||
port = self._get_object('ports', pt['port_id'], self.api)['port']
|
||||
addresses.extend([x['ip_address'] for x in port['fixed_ips']])
|
||||
return addresses
|
||||
|
||||
def _proxy_tenant(self, ptg, admin_proxy):
|
||||
return 'admin' if admin_proxy else ptg['tenant_id']
|
||||
|
||||
@@ -926,7 +919,7 @@ class TestProxyGroup(ApicMappingStitchingPlumberGBPTestCase):
|
||||
# Shadow BD created
|
||||
self.mgr.ensure_bd_created_on_apic.assert_called_once_with(
|
||||
ptg['tenant_id'], 'Shd-' + ptg['id'], ctx_owner=l3p['tenant_id'],
|
||||
ctx_name=l3p['id'], allow_broadcast=False, unicast_route=False,
|
||||
ctx_name=l3p['id'], allow_broadcast=True, unicast_route=False,
|
||||
transaction=mock.ANY, enforce_subnet_check=False)
|
||||
# Proxied PTG moved
|
||||
expected_calls = [
|
||||
@@ -1217,7 +1210,7 @@ class TestProxyGroup(ApicMappingStitchingPlumberGBPTestCase):
|
||||
# Shadow BD created in non-admin tenant
|
||||
self.mgr.ensure_bd_created_on_apic.assert_called_once_with(
|
||||
'non-admin', 'Shd-' + ptg['id'], ctx_owner=l3p['tenant_id'],
|
||||
ctx_name=l3p['id'], allow_broadcast=False, unicast_route=False,
|
||||
ctx_name=l3p['id'], allow_broadcast=True, unicast_route=False,
|
||||
transaction=mock.ANY, enforce_subnet_check=False)
|
||||
# Proxied PTG moved
|
||||
expected_calls = [
|
||||
|
||||
Reference in New Issue
Block a user