From 6f406ca747ce0d3cf2cbba3dd3da6303c2c77d67 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Sun, 23 Nov 2014 02:37:46 +0000 Subject: [PATCH] Drop RpcProxy usage from oneconvergence plugin This patch removes usage of the RpcProxy compatibility class from the oneconvergence plugin. The equivalent usage of oslo.messaging APIs is now used intead. Part of blueprint drop-rpc-compat. Change-Id: Ifa74849ba9e3dc09cbb8cb3a723aeaa2b25b87ad --- .../oneconvergence/agent/nvsd_neutron_agent.py | 11 +++++++---- neutron/plugins/oneconvergence/plugin.py | 16 +++++++--------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py b/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py index fb19978ea8..5bac0646ca 100644 --- a/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py +++ b/neutron/plugins/oneconvergence/agent/nvsd_neutron_agent.py @@ -21,6 +21,8 @@ import time import eventlet eventlet.monkey_patch() +from oslo import messaging + from neutron.agent.linux import ovs_lib from neutron.agent import rpc as agent_rpc from neutron.agent import securitygroups_rpc as sg_rpc @@ -57,11 +59,12 @@ class NVSDAgentRpcCallback(n_rpc.RpcCallback): self.sg_agent.refresh_firewall() -class SecurityGroupServerRpcApi(n_rpc.RpcProxy, - sg_rpc.SecurityGroupServerRpcApiMixin): +class SecurityGroupServerRpcApi(sg_rpc.SecurityGroupServerRpcApiMixin): + def __init__(self, topic): - super(SecurityGroupServerRpcApi, self).__init__( - topic=topic, default_version=sg_rpc.SG_RPC_VERSION) + self.topic = topic + target = messaging.Target(topic=topic, version=sg_rpc.SG_RPC_VERSION) + self.client = n_rpc.get_client(target) class SecurityGroupAgentRpcCallback( diff --git a/neutron/plugins/oneconvergence/plugin.py b/neutron/plugins/oneconvergence/plugin.py index 5b612c6f83..990753032c 100644 --- a/neutron/plugins/oneconvergence/plugin.py +++ b/neutron/plugins/oneconvergence/plugin.py @@ -15,6 +15,7 @@ """Implementation of OneConvergence Neutron Plugin.""" from oslo.config import cfg +from oslo import messaging from oslo.utils import excutils from oslo.utils import importutils @@ -61,21 +62,18 @@ class SecurityGroupServerRpcMixin(sg_db_rpc.SecurityGroupServerRpcMixin): return port -class NVSDPluginV2AgentNotifierApi(n_rpc.RpcProxy, - sg_rpc.SecurityGroupAgentRpcApiMixin): - - BASE_RPC_API_VERSION = '1.0' +class NVSDPluginV2AgentNotifierApi(sg_rpc.SecurityGroupAgentRpcApiMixin): def __init__(self, topic): - super(NVSDPluginV2AgentNotifierApi, self).__init__( - topic=topic, default_version=self.BASE_RPC_API_VERSION) + self.topic = topic self.topic_port_update = topics.get_topic_name(topic, topics.PORT, topics.UPDATE) + target = messaging.Target(topic=topic, version='1.0') + self.client = n_rpc.get_client(target) def port_update(self, context, port): - self.fanout_cast(context, - self.make_msg('port_update', port=port), - topic=self.topic_port_update) + cctxt = self.client.prepare(topic=self.topic_port_update, fanout=True) + cctxt.cast(context, 'port_update', port=port) class OneConvergencePluginV2(db_base_plugin_v2.NeutronDbPluginV2,