From 7e305fe827e2f29c4d44dfab873e6527e5789781 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Tue, 2 Dec 2014 16:20:23 +0000 Subject: [PATCH] Remove RpcProxy class All users of this class have now been converted to use oslo.messaging APIs directly, so this compatibility class can be removed. Part of blueprint drop-rpc-compat. Change-Id: Ife5c96d2d737694b9e79fe079d62dc48f23c033a --- neutron/common/rpc.py | 53 ------------------------------------------- neutron/tests/base.py | 6 ----- 2 files changed, 59 deletions(-) diff --git a/neutron/common/rpc.py b/neutron/common/rpc.py index 995f6f6cd..37e9e3273 100644 --- a/neutron/common/rpc.py +++ b/neutron/common/rpc.py @@ -19,7 +19,6 @@ from oslo import messaging from oslo.messaging import serializer as om_serializer from neutron.common import exceptions -from neutron.common import log from neutron import context from neutron.openstack.common import log as logging from neutron.openstack.common import service @@ -135,58 +134,6 @@ class RequestContextSerializer(om_serializer.Serializer): load_admin_roles=False, **rpc_ctxt_dict) -class RpcProxy(object): - ''' - This class is created to facilitate migration from oslo-incubator - RPC layer implementation to oslo.messaging and is intended to - emulate RpcProxy class behaviour using oslo.messaging API once the - migration is applied. - ''' - RPC_API_NAMESPACE = None - - def __init__(self, topic, default_version, version_cap=None): - super(RpcProxy, self).__init__() - self.topic = topic - target = messaging.Target(topic=topic, version=default_version) - self._client = get_client(target, version_cap=version_cap) - - def make_msg(self, method, **kwargs): - return {'method': method, - 'namespace': self.RPC_API_NAMESPACE, - 'args': kwargs} - - @log.log - def call(self, context, msg, **kwargs): - return self.__call_rpc_method( - context, msg, rpc_method='call', **kwargs) - - @log.log - def cast(self, context, msg, **kwargs): - self.__call_rpc_method(context, msg, rpc_method='cast', **kwargs) - - @log.log - def fanout_cast(self, context, msg, **kwargs): - kwargs['fanout'] = True - self.__call_rpc_method(context, msg, rpc_method='cast', **kwargs) - - def __call_rpc_method(self, context, msg, **kwargs): - options = dict( - ((opt, kwargs[opt]) - for opt in ('fanout', 'timeout', 'topic', 'version') - if kwargs.get(opt)) - ) - if msg['namespace']: - options['namespace'] = msg['namespace'] - - if options: - callee = self._client.prepare(**options) - else: - callee = self._client - - func = getattr(callee, kwargs['rpc_method']) - return func(context, msg['method'], **msg['args']) - - class RpcCallback(object): ''' This class is created to facilitate migration from oslo-incubator diff --git a/neutron/tests/base.py b/neutron/tests/base.py index a55068c06..07914f531 100644 --- a/neutron/tests/base.py +++ b/neutron/tests/base.py @@ -28,7 +28,6 @@ import os.path import sys import fixtures -import mock from oslo.config import cfg from oslo.messaging import conffixture as messaging_conffixture @@ -109,11 +108,6 @@ class BaseTestCase(sub_base.SubBaseTestCase): 'neutron.common.rpc.Connection.consume_in_threads', fake_consume_in_threads)) - # immediately return RPC calls - self.useFixture(fixtures.MonkeyPatch( - 'neutron.common.rpc.RpcProxy._RpcProxy__call_rpc_method', - mock.MagicMock())) - self.useFixture(fixtures.MonkeyPatch( 'oslo.messaging.Notifier', fake_notifier.FakeNotifier)) -- 2.45.2