Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
[apic-mapping]Put real port IDs in ha table when proxy port
Browse files Browse the repository at this point in the history
Closes-Bug: 1521835
Change-Id: Ic97087b20aeb5af320621e0d5de18d4ba2f65957
  • Loading branch information
ivar-lazzaro committed Dec 3, 2015
1 parent b048c61 commit f3fc14c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Expand Up @@ -239,7 +239,7 @@ def update_ip_owner(self, ip_owner_info):
LOG.debug("Replace port %s with port %s", port_id,
new_id)
port = self._get_port(context, new_id)
ip_owner_info['network_id'] = port['network_id']
ip_owner_info['port'] = port['id']
except n_exc.PortNotFound:
LOG.warn(_("Proxied port %s could not be found"),
new_id)
Expand Down Expand Up @@ -330,8 +330,11 @@ def is_port_promiscuous(port):
details['vm-name'] = vm.name if vm else port['device_id']
l3_policy = context._plugin.get_l3_policy(context,
l2p['l3_policy_id'])
own_addr = self._get_owned_addresses(
context, pt['port_id'] if (pt and not switched) else port_id)
own_addr = set()
if pt:
own_addr = set(self._get_owned_addresses(context,
pt['port_id']))
own_addr |= set(self._get_owned_addresses(context, port_id))
(details['floating_ip'], details['ip_mapping'],
details['host_snat_ips']) = (
self._get_ip_mapping_details(
Expand Down Expand Up @@ -560,9 +563,12 @@ def ip_address_owner_update(self, context, **kwargs):
if not kwargs.get('ip_owner_info'):
return
ports_to_update = self.update_ip_owner(kwargs['ip_owner_info'])
pts = self._get_policy_targets(context, {'port_id': ports_to_update})
for p in ports_to_update:
LOG.debug("APIC ownership update for port %s", p)
self._notify_port_update(context, p)
for pt in pts:
self._notify_head_chain_ports(pt['policy_target_group_id'])

def process_port_added(self, plugin_context, port):
pass
Expand Down
Expand Up @@ -598,6 +598,8 @@ def test_get_gbp_proxy_address_ownership(self):
policy_target_group_id=ptg_fake['id'])['policy_target']
pt_bound_2 = self.create_policy_target(
policy_target_group_id=ptg_fake['id'])['policy_target']
pt_bound_3 = self.create_policy_target(
policy_target_group_id=ptg_fake['id'])['policy_target']

l3p_real = self.create_l3_policy(name='myl3')['l3_policy']
# Build 2 L2Ps in order to get 2 networks.
Expand All @@ -616,6 +618,8 @@ def test_get_gbp_proxy_address_ownership(self):
policy_target_group_id=ptg_real_1['id'])['policy_target']
pt_unbound_2 = self.create_policy_target(
policy_target_group_id=ptg_real_2['id'])['policy_target']
pt_unbound_2_1 = self.create_policy_target(
policy_target_group_id=ptg_real_2['id'])['policy_target']

# Change description to link the ports. The bound one will point
# to the unbound one to get its info overridden
Expand All @@ -625,6 +629,9 @@ def test_get_gbp_proxy_address_ownership(self):
self.update_policy_target(
pt_bound_2['id'],
description=amap.PROXY_PORT_PREFIX + pt_unbound_2['port_id'])
self.update_policy_target(
pt_bound_3['id'],
description=amap.PROXY_PORT_PREFIX + pt_unbound_2_1['port_id'])

# Set up address ownership on the bound ports, and verify that both
# entries exists
Expand All @@ -641,6 +648,14 @@ def test_get_gbp_proxy_address_ownership(self):
self.assertEqual(2, len(entries))
self.assertEqual('1.1.1.1', entries[0].ha_ip_address)
self.assertEqual('1.1.1.1', entries[1].ha_ip_address)
self.driver.update_ip_owner({'port': pt_bound_3['port_id'],
'ip_address_v4': '1.1.1.1'})

entries = self.driver.ha_ip_handler.session.query(
ha_ip_db.HAIPAddressToPortAssocation).all()
self.assertEqual(2, len(entries))
self.assertEqual('1.1.1.1', entries[0].ha_ip_address)
self.assertEqual('1.1.1.1', entries[1].ha_ip_address)


class TestPolicyTargetGroup(ApicMappingTestCase):
Expand Down

0 comments on commit f3fc14c

Please sign in to comment.