From b97dc058e28d6d8c93dafd0e35524d1b957ada75 Mon Sep 17 00:00:00 2001 From: Akihiro MOTOKI Date: Mon, 31 Dec 2012 05:58:36 +0900 Subject: [PATCH] Catch up RPC context fixes on NEC OpenFlow plugin Fixes bug 1099179 Change-Id: Ib61081c3aaed8770906dd57874c45358b0418c3f --- quantum/plugins/nec/agent/nec_quantum_agent.py | 5 ++--- quantum/plugins/nec/nec_plugin.py | 15 +++++++-------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/quantum/plugins/nec/agent/nec_quantum_agent.py b/quantum/plugins/nec/agent/nec_quantum_agent.py index 7e557fd4e7..8c8786b4e2 100755 --- a/quantum/plugins/nec/agent/nec_quantum_agent.py +++ b/quantum/plugins/nec/agent/nec_quantum_agent.py @@ -28,7 +28,7 @@ import time from quantum.agent.linux import ovs_lib from quantum.common import config as logging_config from quantum.common import topics -from quantum.openstack.common import context +from quantum import context from quantum.openstack.common import log as logging from quantum.openstack.common import rpc from quantum.plugins.nec.common import config @@ -54,8 +54,7 @@ class NECQuantumAgent(object): self.datapath_id = "0x%s" % self.int_br.get_datapath_id() # RPC network init - self.context = context.RequestContext('quantum', 'quantum', - is_admin=False) + self.context = context.get_admin_context_without_session() self.conn = rpc.create_connection(new=True) def update_ports(self, port_added=[], port_removed=[]): diff --git a/quantum/plugins/nec/nec_plugin.py b/quantum/plugins/nec/nec_plugin.py index 3c82b52a13..734f86385a 100644 --- a/quantum/plugins/nec/nec_plugin.py +++ b/quantum/plugins/nec/nec_plugin.py @@ -16,12 +16,12 @@ # @author: Ryota MIBU from quantum.common import topics +from quantum.common import rpc as q_rpc from quantum import context from quantum.db import dhcp_rpc_base from quantum.db import l3_db from quantum.openstack.common import log as logging from quantum.openstack.common import rpc -from quantum.openstack.common.rpc import dispatcher from quantum.plugins.nec.common import config from quantum.plugins.nec.common import exceptions as nexc from quantum.plugins.nec.db import api as ndb @@ -495,7 +495,6 @@ class NECPluginV2RPCCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin): def __init__(self, plugin): self.plugin = plugin - self.admin_context = context.get_admin_context() def create_rpc_dispatcher(self): '''Get the rpc dispatcher for this manager. @@ -503,7 +502,7 @@ class NECPluginV2RPCCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin): If a manager would like to set an rpc API version, or support more than one class as the target of rpc messages, override this method. ''' - return dispatcher.RpcDispatcher([self]) + return q_rpc.PluginRpcDispatcher([self]) def update_ports(self, rpc_context, **kwargs): """Update ports' information and activate/deavtivate them. @@ -521,15 +520,15 @@ class NECPluginV2RPCCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin): datapath_id = kwargs['datapath_id'] for p in kwargs.get('port_added', []): id = p['id'] - port = self.plugin.get_port(self.admin_context, id) + port = self.plugin.get_port(rpc_context, id) if port and ndb.get_portinfo(id): ndb.del_portinfo(id) - self.plugin.deactivate_port(self.admin_context, port) + self.plugin.deactivate_port(rpc_context, port) ndb.add_portinfo(id, datapath_id, p['port_no'], mac=p.get('mac', '')) - self.plugin.activate_port_if_ready(self.admin_context, port) + self.plugin.activate_port_if_ready(rpc_context, port) for id in kwargs.get('port_removed', []): - port = self.plugin.get_port(self.admin_context, id) + port = self.plugin.get_port(rpc_context, id) if port and ndb.get_portinfo(id): ndb.del_portinfo(id) - self.plugin.deactivate_port(self.admin_context, port) + self.plugin.deactivate_port(rpc_context, port)