From 0759ed18a95b438bf775d6905256119f1cee75db Mon Sep 17 00:00:00 2001 From: armando-migliaccio Date: Mon, 2 Jun 2014 07:31:33 -0700 Subject: [PATCH] Allow L3 base to handle extensions on router creation By changing the boolean flag, API extensions made to the router model can be handled correctly: this means that on router creation, the response body will contain all the extension attributes being part of the resource. Prior to this fix, it was only on GETs or PUTs, leaving the user at loss as to whether the flag was actually being processed. Closes-bug: #1325608 Supports-blueprint: neutron-ovs-dvr Change-Id: I6f913c8417676a789177e00f30eb5875e7aaa3ae --- neutron/db/l3_db.py | 2 +- neutron/plugins/midonet/plugin.py | 3 +-- neutron/tests/unit/test_l3_plugin.py | 12 ++++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index f8640137b..8575abf66 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -137,7 +137,7 @@ class L3_NAT_db_mixin(l3.RouterPluginBase): router_db = self._create_router_db(context, r, tenant_id, gw_info) if gw_info: self._update_router_gw_info(context, router_db['id'], gw_info) - return self._make_router_dict(router_db, process_extensions=False) + return self._make_router_dict(router_db) def _update_router_db(self, context, router_id, data, gw_info): """Update the DB object and related gw info, if available.""" diff --git a/neutron/plugins/midonet/plugin.py b/neutron/plugins/midonet/plugin.py index 0b590a187..9bf589959 100644 --- a/neutron/plugins/midonet/plugin.py +++ b/neutron/plugins/midonet/plugin.py @@ -757,8 +757,7 @@ class MidonetPluginV2(db_base_plugin_v2.NeutronDbPluginV2, self._update_router_gw_info(context, router_db['id'], gw_info) - router_data = self._make_router_dict(router_db, - process_extensions=False) + router_data = self._make_router_dict(router_db) except Exception: # Try removing the midonet router diff --git a/neutron/tests/unit/test_l3_plugin.py b/neutron/tests/unit/test_l3_plugin.py index 945c5ee4b..4aa444604 100644 --- a/neutron/tests/unit/test_l3_plugin.py +++ b/neutron/tests/unit/test_l3_plugin.py @@ -520,6 +520,18 @@ class L3NatTestCaseBase(L3NatTestCaseMixin): for k, v in expected_value: self.assertEqual(router['router'][k], v) + def test_router_create_call_extensions(self): + self.extension_called = False + + def _extend_router_dict_test_attr(*args, **kwargs): + self.extension_called = True + + db_base_plugin_v2.NeutronDbPluginV2.register_dict_extend_funcs( + l3.ROUTERS, [_extend_router_dict_test_attr]) + self.assertFalse(self.extension_called) + with self.router(): + self.assertTrue(self.extension_called) + def test_router_create_with_gwinfo(self): with self.subnet() as s: self._set_net_external(s['subnet']['network_id']) -- 2.45.2