]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Drop RpcProxy usage from bigswitch plugin
authorRussell Bryant <rbryant@redhat.com>
Thu, 20 Nov 2014 22:22:41 +0000 (22:22 +0000)
committerRussell Bryant <rbryant@redhat.com>
Fri, 21 Nov 2014 13:40:01 +0000 (13:40 +0000)
This patch drops the usage of the RpcProxy compatibility class from
the bigswitch plugin.  The equivalent usage of oslo.messaging APIs is
now used instead.

Note that there is one very minor functional change included.  The
previous code set the base version to '1.1'.  It should be '1.0'.  The
proper pattern to use is to set the base version on the client side to
be the initial version of the API (X.0).  Then, any methods that
require a newer version need to specify it.  In this case, verison
'1.1' was the security group methods, and those specify '1.1' as you
would expect.

Part of blueprint drop-rpc-compat.

Change-Id: I695d2a26db9c01b0be65b11cd4e4063567b5f20d

neutron/plugins/bigswitch/plugin.py

index 52b32de485486e49f62f33044291dbfad4b690fa..e3c4febc92cf44518e0454e0c78e563c5f158572 100644 (file)
@@ -47,6 +47,7 @@ import re
 
 import eventlet
 from oslo.config import cfg
+from oslo import messaging
 from sqlalchemy.orm import exc as sqlexc
 
 from neutron.agent import securitygroups_rpc as sg_rpc
@@ -92,22 +93,18 @@ SYNTAX_ERROR_MESSAGE = _('Syntax error in server config file, aborting plugin')
 METADATA_SERVER_IP = '169.254.169.254'
 
 
-class AgentNotifierApi(n_rpc.RpcProxy,
-                       sg_rpc.SecurityGroupAgentRpcApiMixin):
-
-    BASE_RPC_API_VERSION = '1.1'
+class AgentNotifierApi(sg_rpc.SecurityGroupAgentRpcApiMixin):
 
     def __init__(self, topic):
-        super(AgentNotifierApi, self).__init__(
-            topic=topic, default_version=self.BASE_RPC_API_VERSION)
-        self.topic_port_update = topics.get_topic_name(
-            topic, topics.PORT, topics.UPDATE)
+        self.topic = topic
+        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)
+        topic_port_update = topics.get_topic_name(self.client.target.topic,
+                                                  topics.PORT, topics.UPDATE)
+        cctxt = self.client.prepare(fanout=True, topic=topic_port_update)
+        cctxt.cast(context, 'port_update', port=port)
 
 
 class SecurityGroupServerRpcMixin(sg_db_rpc.SecurityGroupServerRpcMixin):