add get_vrf_details rpc method to apic mapping
Change-Id: Iaa4e54e0618212a9307b703743d180f03d7b0666 Closes-bug: 1497019
This commit is contained in:
parent
fd4aa91d76
commit
a53a2db8e1
@ -176,6 +176,12 @@ class ApicMappingDriver(api.ResourceMappingDriver):
|
||||
.get("GROUP_POLICY"))
|
||||
return self._gbp_plugin
|
||||
|
||||
# RPC Method
|
||||
def get_vrf_details(self, context, **kwargs):
|
||||
details = {'l3_policy_id': kwargs['vrf_id']}
|
||||
self._add_vrf_details(context, details)
|
||||
return details
|
||||
|
||||
# RPC Method
|
||||
def get_gbp_details(self, context, **kwargs):
|
||||
port_id = self._core_plugin._device_to_port_id(
|
||||
@ -271,7 +277,7 @@ class ApicMappingDriver(api.ResourceMappingDriver):
|
||||
filters={'id': [ip['subnet_id'] for ip in port['fixed_ips']]})
|
||||
|
||||
def _add_vrf_details(self, context, details):
|
||||
l3p = self._gbp_plugin.get_l3_policy(context, details['l3_policy_id'])
|
||||
l3p = self.gbp_plugin.get_l3_policy(context, details['l3_policy_id'])
|
||||
details['vrf_tenant'] = self.apic_manager.apic.fvTenant.name(
|
||||
self._tenant_by_sharing_policy(l3p))
|
||||
details['vrf_name'] = str(self.name_mapper.l3_policy(
|
||||
|
@ -129,6 +129,10 @@ class ApicMappingTestCase(
|
||||
amap.apic_manager.TENANT_COMMON = 'common'
|
||||
self.common_tenant = amap.apic_manager.TENANT_COMMON
|
||||
|
||||
def echo2(string):
|
||||
return string
|
||||
self.driver.apic_manager.apic.fvTenant.name = echo2
|
||||
|
||||
def _build_external_dict(self, name, cidr_exposed):
|
||||
return {name: {
|
||||
'switch': mocked.APIC_EXT_SWITCH,
|
||||
@ -232,6 +236,19 @@ class TestPolicyTarget(ApicMappingTestCase):
|
||||
# Issue notification for the agent
|
||||
self.assertTrue(self.driver.notifier.port_update.called)
|
||||
|
||||
def test_get_vrf_details(self):
|
||||
l3p = self.create_l3_policy(name='myl3')['l3_policy']
|
||||
details = self.driver.get_vrf_details(
|
||||
context.get_admin_context(),
|
||||
vrf_id=l3p['id'], host='h1')
|
||||
self.assertEqual(l3p['id'], details['l3_policy_id'])
|
||||
pool = set([l3p['ip_pool']])
|
||||
if 'proxy_ip_pool' in l3p:
|
||||
pool.add(l3p['proxy_ip_pool'])
|
||||
self.assertEqual(pool, set(details['vrf_subnets']))
|
||||
self.assertEqual(l3p['tenant_id'], details['vrf_tenant'])
|
||||
self.assertEqual(l3p['id'], details['vrf_name'])
|
||||
|
||||
def test_get_gbp_details(self):
|
||||
l3p = self.create_l3_policy(name='myl3')['l3_policy']
|
||||
l2p = self.create_l2_policy(name='myl2',
|
||||
@ -242,9 +259,6 @@ class TestPolicyTarget(ApicMappingTestCase):
|
||||
policy_target_group_id=ptg['id'])['policy_target']
|
||||
self._bind_port_to_host(pt1['port_id'], 'h1')
|
||||
|
||||
def echo(string):
|
||||
return string
|
||||
self.driver.apic_manager.apic.fvTenant.name = echo
|
||||
mapping = self.driver.get_gbp_details(context.get_admin_context(),
|
||||
device='tap%s' % pt1['port_id'], host='h1')
|
||||
self.assertEqual(pt1['port_id'], mapping['port_id'])
|
||||
|
Loading…
Reference in New Issue
Block a user