Catch up RPC context fixes on NEC OpenFlow plugin

Fixes bug 1099179

Change-Id: Ib61081c3aaed8770906dd57874c45358b0418c3f
This commit is contained in:
Akihiro MOTOKI 2012-12-31 05:58:36 +09:00
parent 25a1279f1c
commit b97dc058e2
2 changed files with 9 additions and 11 deletions

View File

@ -28,7 +28,7 @@ import time
from quantum.agent.linux import ovs_lib from quantum.agent.linux import ovs_lib
from quantum.common import config as logging_config from quantum.common import config as logging_config
from quantum.common import topics 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 log as logging
from quantum.openstack.common import rpc from quantum.openstack.common import rpc
from quantum.plugins.nec.common import config 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() self.datapath_id = "0x%s" % self.int_br.get_datapath_id()
# RPC network init # RPC network init
self.context = context.RequestContext('quantum', 'quantum', self.context = context.get_admin_context_without_session()
is_admin=False)
self.conn = rpc.create_connection(new=True) self.conn = rpc.create_connection(new=True)
def update_ports(self, port_added=[], port_removed=[]): def update_ports(self, port_added=[], port_removed=[]):

View File

@ -16,12 +16,12 @@
# @author: Ryota MIBU # @author: Ryota MIBU
from quantum.common import topics from quantum.common import topics
from quantum.common import rpc as q_rpc
from quantum import context from quantum import context
from quantum.db import dhcp_rpc_base from quantum.db import dhcp_rpc_base
from quantum.db import l3_db from quantum.db import l3_db
from quantum.openstack.common import log as logging from quantum.openstack.common import log as logging
from quantum.openstack.common import rpc 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 config
from quantum.plugins.nec.common import exceptions as nexc from quantum.plugins.nec.common import exceptions as nexc
from quantum.plugins.nec.db import api as ndb from quantum.plugins.nec.db import api as ndb
@ -495,7 +495,6 @@ class NECPluginV2RPCCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
def __init__(self, plugin): def __init__(self, plugin):
self.plugin = plugin self.plugin = plugin
self.admin_context = context.get_admin_context()
def create_rpc_dispatcher(self): def create_rpc_dispatcher(self):
'''Get the rpc dispatcher for this manager. '''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 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. 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): def update_ports(self, rpc_context, **kwargs):
"""Update ports' information and activate/deavtivate them. """Update ports' information and activate/deavtivate them.
@ -521,15 +520,15 @@ class NECPluginV2RPCCallbacks(dhcp_rpc_base.DhcpRpcCallbackMixin):
datapath_id = kwargs['datapath_id'] datapath_id = kwargs['datapath_id']
for p in kwargs.get('port_added', []): for p in kwargs.get('port_added', []):
id = p['id'] 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): if port and ndb.get_portinfo(id):
ndb.del_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'], ndb.add_portinfo(id, datapath_id, p['port_no'],
mac=p.get('mac', '')) 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', []): 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): if port and ndb.get_portinfo(id):
ndb.del_portinfo(id) ndb.del_portinfo(id)
self.plugin.deactivate_port(self.admin_context, port) self.plugin.deactivate_port(rpc_context, port)