summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-14 22:43:09 +0000
committerGerrit Code Review <review@openstack.org>2017-06-14 22:43:09 +0000
commit172046863854f2d7241da3185c79d6a1f80a1285 (patch)
treed7a4d047c66abe3a5201ff49e4fe6239c682b14b
parent0ec5c033c296a2c33974bec41cac33c485be8ef0 (diff)
parentabe9938367f3f7cf21e5c0e42ee7b9b81b4960b0 (diff)
Merge "DVR: Fix DVR Router snat ports and gateway ports host binding issue"
-rw-r--r--neutron/db/l3_dvr_db.py10
-rw-r--r--neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py35
2 files changed, 42 insertions, 3 deletions
diff --git a/neutron/db/l3_dvr_db.py b/neutron/db/l3_dvr_db.py
index 6ae63eb..3189e66 100644
--- a/neutron/db/l3_dvr_db.py
+++ b/neutron/db/l3_dvr_db.py
@@ -963,10 +963,14 @@ class _DVRAgentInterfaceMixin(object):
963 return update_port 963 return update_port
964 964
965 965
966class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin, 966# NOTE: The order in which the parent classes are inherited sometimes
967 l3_attrs_db.ExtraAttributesMixin, 967# determines the functions defined in those classes to be executed.
968# So any new classes that overrides a function in the parent class should
969# be added before the parent class.
970class L3_NAT_with_dvr_db_mixin(_DVRAgentInterfaceMixin,
968 DVRResourceOperationHandler, 971 DVRResourceOperationHandler,
969 _DVRAgentInterfaceMixin): 972 l3_attrs_db.ExtraAttributesMixin,
973 l3_db.L3_NAT_db_mixin):
970 """Mixin class to enable DVR support.""" 974 """Mixin class to enable DVR support."""
971 router_device_owners = ( 975 router_device_owners = (
972 l3_db.L3_NAT_db_mixin.router_device_owners + 976 l3_db.L3_NAT_db_mixin.router_device_owners +
diff --git a/neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py b/neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py
index 4799c37..ea00b8e 100644
--- a/neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py
+++ b/neutron/tests/functional/services/l3_router/test_l3_dvr_router_plugin.py
@@ -37,6 +37,7 @@ class L3DvrTestCaseBase(ml2_test_base.ML2TestFramework):
37 def setUp(self): 37 def setUp(self):
38 super(L3DvrTestCaseBase, self).setUp() 38 super(L3DvrTestCaseBase, self).setUp()
39 self.l3_agent = helpers.register_l3_agent( 39 self.l3_agent = helpers.register_l3_agent(
40 host="host0",
40 agent_mode=constants.L3_AGENT_MODE_DVR_SNAT) 41 agent_mode=constants.L3_AGENT_MODE_DVR_SNAT)
41 # register OVS agents to avoid time wasted on committing 42 # register OVS agents to avoid time wasted on committing
42 # port binding failures on every port update 43 # port binding failures on every port update
@@ -715,6 +716,40 @@ class L3DvrTestCase(L3DvrTestCaseBase):
715 l3_notifier.add_arp_entry.assert_has_calls( 716 l3_notifier.add_arp_entry.assert_has_calls(
716 expected_calls) 717 expected_calls)
717 718
719 def test_dvr_gateway_host_binding_is_set(self):
720 router = self._create_router()
721 private_net1 = self._make_network(self.fmt, 'net1', True)
722 kwargs = {'arg_list': (external_net.EXTERNAL,),
723 external_net.EXTERNAL: True}
724 ext_net = self._make_network(self.fmt, '', True, **kwargs)
725 self._make_subnet(
726 self.fmt, ext_net, '10.20.0.1', '10.20.0.0/24',
727 ip_version=4, enable_dhcp=True)
728 # Set gateway to router
729 self.l3_plugin._update_router_gw_info(
730 self.context, router['id'],
731 {'network_id': ext_net['network']['id']})
732 private_subnet1 = self._make_subnet(
733 self.fmt,
734 private_net1,
735 '10.1.0.1',
736 cidr='10.1.0.0/24',
737 ip_version=4,
738 enable_dhcp=True)
739 self.l3_plugin.add_router_interface(
740 self.context, router['id'],
741 {'subnet_id': private_subnet1['subnet']['id']})
742 self.l3_plugin.schedule_router(self.context,
743 router['id'],
744 candidates=[self.l3_agent])
745 # Check for the gw_port_host in the router dict to make
746 # sure that the _build_routers_list in l3_dvr_db is called.
747 router_handle = (
748 self.l3_plugin.list_active_sync_routers_on_active_l3_agent(
749 self.context, self.l3_agent['host'], [router['id']]))
750 self.assertEqual(self.l3_agent['host'],
751 router_handle[0]['gw_port_host'])
752
718 def test_allowed_address_pairs_update_arp_entry(self): 753 def test_allowed_address_pairs_update_arp_entry(self):
719 HOST1 = 'host1' 754 HOST1 = 'host1'
720 helpers.register_l3_agent( 755 helpers.register_l3_agent(