From 83ae56e4f1fa5a35ed7cd87d5176c5f7c549674c Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 21 Nov 2014 14:51:55 +0000 Subject: [PATCH] Drop RpcProxy usage from cisco.cfg_agent Drop usage of the RpcProxy compatibility class from cisco.cfg_agent. The equivalent direct usage of oslo.messaging APIs is now used instead. Part of blueprint drop-rpc-compat. Change-Id: I3ec71b3689adf7e96cdc2fdbf501c5cc37a9e0e4 --- neutron/plugins/cisco/cfg_agent/cfg_agent.py | 24 +++++++------------ .../service_helpers/routing_svc_helper.py | 17 +++++-------- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/neutron/plugins/cisco/cfg_agent/cfg_agent.py b/neutron/plugins/cisco/cfg_agent/cfg_agent.py index 7512dee8a..051726fcf 100644 --- a/neutron/plugins/cisco/cfg_agent/cfg_agent.py +++ b/neutron/plugins/cisco/cfg_agent/cfg_agent.py @@ -19,6 +19,7 @@ import sys import time from oslo.config import cfg +from oslo import messaging from neutron.agent.common import config from neutron.agent.linux import external_process @@ -47,15 +48,13 @@ REGISTRATION_RETRY_DELAY = 2 MAX_REGISTRATION_ATTEMPTS = 30 -class CiscoDeviceManagementApi(n_rpc.RpcProxy): +class CiscoDeviceManagementApi(object): """Agent side of the device manager RPC API.""" - BASE_RPC_API_VERSION = '1.0' - def __init__(self, topic, host): - super(CiscoDeviceManagementApi, self).__init__( - topic=topic, default_version=self.BASE_RPC_API_VERSION) self.host = host + target = messaging.Target(topic=topic, version='1.0') + self.client = n_rpc.get_client(target) def report_dead_hosting_devices(self, context, hd_ids=None): """Report that a hosting device cannot be contacted (presumed dead). @@ -64,19 +63,14 @@ class CiscoDeviceManagementApi(n_rpc.RpcProxy): :param: hosting_device_ids: list of non-responding hosting devices :return: None """ - # Cast since we don't expect a return value. - self.cast(context, - self.make_msg('report_non_responding_hosting_devices', - host=self.host, - hosting_device_ids=hd_ids), - topic=self.topic) + cctxt = self.client.prepare() + cctxt.cast(context, 'report_non_responding_hosting_devices', + host=self.host, hosting_device_ids=hd_ids) def register_for_duty(self, context): """Report that a config agent is ready for duty.""" - return self.call(context, - self.make_msg('register_for_duty', - host=self.host), - topic=self.topic) + cctxt = self.client.prepare() + return cctxt.call(context, 'register_for_duty', host=self.host) class CiscoCfgAgent(manager.Manager): diff --git a/neutron/plugins/cisco/cfg_agent/service_helpers/routing_svc_helper.py b/neutron/plugins/cisco/cfg_agent/service_helpers/routing_svc_helper.py index d19a1b17c..9fe5af2fd 100644 --- a/neutron/plugins/cisco/cfg_agent/service_helpers/routing_svc_helper.py +++ b/neutron/plugins/cisco/cfg_agent/service_helpers/routing_svc_helper.py @@ -85,15 +85,13 @@ class RouterInfo(object): return N_ROUTER_PREFIX + self.router_id -class CiscoRoutingPluginApi(n_rpc.RpcProxy): +class CiscoRoutingPluginApi(object): """RoutingServiceHelper(Agent) side of the routing RPC API.""" - BASE_RPC_API_VERSION = '1.1' - def __init__(self, topic, host): - super(CiscoRoutingPluginApi, self).__init__( - topic=topic, default_version=self.BASE_RPC_API_VERSION) self.host = host + target = messaging.Target(topic=topic, version='1.0') + self.client = n_rpc.get_client(target) def get_routers(self, context, router_ids=None, hd_ids=None): """Make a remote process call to retrieve the sync data for routers. @@ -103,12 +101,9 @@ class CiscoRoutingPluginApi(n_rpc.RpcProxy): :param hd_ids : hosting device ids, only routers assigned to these hosting devices will be returned. """ - return self.call(context, - self.make_msg('cfg_sync_routers', - host=self.host, - router_ids=router_ids, - hosting_device_ids=hd_ids), - topic=self.topic) + cctxt = self.client.prepare(version='1.1') + return cctxt.call(context, 'cfg_sync_routers', host=self.host, + router_ids=router_ids, hosting_device_ids=hd_ids) class RoutingServiceHelper(): -- 2.45.2