diff --git a/neutron/agent/l3/dvr_local_router.py b/neutron/agent/l3/dvr_local_router.py index 3ec964e2a1d..be894b80f95 100644 --- a/neutron/agent/l3/dvr_local_router.py +++ b/neutron/agent/l3/dvr_local_router.py @@ -51,7 +51,9 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase): def get_floating_ips(self): """Filter Floating IPs to be hosted on this agent.""" floating_ips = super(DvrLocalRouter, self).get_floating_ips() - return [i for i in floating_ips if i['host'] == self.host] + return [i for i in floating_ips if ( + (i['host'] == self.host) or + (i.get('dest_host') == self.host))] def _handle_fip_nat_rules(self, interface_name): """Configures NAT rules for Floating IPs for DVR.""" diff --git a/neutron/tests/functional/agent/l3/test_dvr_router.py b/neutron/tests/functional/agent/l3/test_dvr_router.py index 202e19de305..2e9eef9f793 100644 --- a/neutron/tests/functional/agent/l3/test_dvr_router.py +++ b/neutron/tests/functional/agent/l3/test_dvr_router.py @@ -495,6 +495,30 @@ class TestDvrRouter(framework.L3AgentTestFramework): self.assertFalse(self._namespace_exists(fip_ns)) self._assert_snat_namespace_does_not_exist(router1) + def test_dvr_router_fip_create_for_migrating_port(self): + """Test to validate the floatingip create on port migrate. + + This test validates the condition where floatingip host + mismatches with the agent, but the 'dest_host' variable + matches with the agent host, due to port pre-migrate + phase. + + """ + self.agent.conf.agent_mode = 'dvr' + router_info = self.generate_dvr_router_info() + floating_ip = router_info['_floatingips'][0] + floating_ip['host'] = 'my_new_host' + floating_ip['dest_host'] = self.agent.host + # Now we have the floatingip 'host' pointing to host that + # does not match to the 'agent.host' and the floatingip + # 'dest_host' matches with the agent.host in the case + # of live migration due to the port_profile update from + # nova. + router1 = self.manage_router(self.agent, router_info) + fip_ns = router1.fip_ns.get_name() + self.assertTrue(self._namespace_exists(router1.ns_name)) + self.assertTrue(self._namespace_exists(fip_ns)) + def test_dvr_router_fip_late_binding(self): """Test to validate the floatingip migration or latebinding.