Ensure that subnet update does not creat RPC client

Commit fc7cae844c would create
the notification class each time that the subnet update is
invoked.

Change-Id: Ie62f4bc4f152cb346d4e6de77b732a87ab6f2f28
Closes-bug: #1661181
This commit is contained in:
Gary Kotton 2017-02-02 00:37:32 -08:00
parent 0e71248955
commit 02f97dd9a0

View File

@ -825,6 +825,16 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
context.session.expire(subnet) context.session.expire(subnet)
return self._make_subnet_dict(subnet, context=context) return self._make_subnet_dict(subnet, context=context)
@property
def l3_rpc_notifier(self):
if not hasattr(self, '_l3_rpc_notifier'):
self._l3_rpc_notifier = l3_rpc_agent_api.L3AgentNotifyAPI()
return self._l3_rpc_notifier
@l3_rpc_notifier.setter
def l3_rpc_notifier(self, value):
self._l3_rpc_notifier = value
def _update_subnet_postcommit(self, context, orig, result): def _update_subnet_postcommit(self, context, orig, result):
"""Subnet update operations that happen after transaction completes. """Subnet update operations that happen after transaction completes.
@ -857,8 +867,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon,
self.update_port(context, port['id'], {'port': port}) self.update_port(context, port['id'], {'port': port})
# Send router_update to l3_agent # Send router_update to l3_agent
if routers: if routers:
l3_rpc_notifier = l3_rpc_agent_api.L3AgentNotifyAPI() self.l3_rpc_notifier.routers_updated(context, routers)
l3_rpc_notifier.routers_updated(context, routers)
if orig['gateway_ip'] != result['gateway_ip']: if orig['gateway_ip'] != result['gateway_ip']:
kwargs = {'context': context, 'subnet_id': result['id'], kwargs = {'context': context, 'subnet_id': result['id'],