[apic-mapping] PTGs on preexisting BDs to not provide service contracts
Change-Id: I6f18013440e4da6d8f15df9c4d2b2147e3dcc483 Closes-Bug: 1541166
This commit is contained in:
parent
98025322bc
commit
8e606f5a6a
@ -733,10 +733,11 @@ class ApicMappingDriver(api.ResourceMappingDriver,
|
||||
self.apic_manager.ensure_epg_created(tenant, epg,
|
||||
bd_owner=bd_owner,
|
||||
bd_name=l2_policy)
|
||||
self._configure_epg_service_contract(
|
||||
context, context.current, l2p, epg, transaction=trs)
|
||||
self._configure_epg_implicit_contract(
|
||||
context, context.current, l2p, epg, transaction=trs)
|
||||
if not self.name_mapper._is_apic_reference(l2_policy_object):
|
||||
self._configure_epg_service_contract(
|
||||
context, context.current, l2p, epg, transaction=trs)
|
||||
self._configure_epg_implicit_contract(
|
||||
context, context.current, l2p, epg, transaction=trs)
|
||||
|
||||
l3p = context._plugin.get_l3_policy(
|
||||
context._plugin_context, l2_policy_object['l3_policy_id'])
|
||||
|
@ -1060,6 +1060,26 @@ class TestPolicyTargetGroup(ApicMappingTestCase):
|
||||
self.assertNotEqual(sub_ptg_1, sub_ptg_2)
|
||||
self.assertFalse(sub_ptg_1 & sub_ptg_2)
|
||||
|
||||
def test_preexisting_l2p_no_service_contracts(self):
|
||||
# Circumvent name validation
|
||||
self.driver.name_mapper.has_valid_name = (
|
||||
self.driver.name_mapper._is_apic_reference)
|
||||
self.driver.name_mapper.tenant = mock.Mock(
|
||||
return_value=self._tenant_id)
|
||||
self.driver.name_mapper.dn_manager.decompose_bridge_domain = mock.Mock(
|
||||
return_value=['preexisting'])
|
||||
self.driver._configure_epg_service_contract = mock.Mock()
|
||||
self.driver._configure_epg_implicit_contract = mock.Mock()
|
||||
l2p = self.create_l2_policy(name='apic:preexisting')['l2_policy']
|
||||
self.create_policy_target_group(l2_policy_id=l2p['id'])
|
||||
self.assertFalse(self.driver._configure_epg_service_contract.called)
|
||||
self.assertFalse(self.driver._configure_epg_implicit_contract.called)
|
||||
|
||||
# Use non-preexisting L2P
|
||||
self.create_policy_target_group()
|
||||
self.assertTrue(self.driver._configure_epg_service_contract.called)
|
||||
self.assertTrue(self.driver._configure_epg_implicit_contract.called)
|
||||
|
||||
def _create_explicit_subnet_ptg(self, cidr, shared=False):
|
||||
l2p = self.create_l2_policy(name="l2p", shared=shared)
|
||||
l2p_id = l2p['l2_policy']['id']
|
||||
|
Loading…
Reference in New Issue
Block a user