From e9e76ce4b75a0df04dc04b89b5959e3cbce04475 Mon Sep 17 00:00:00 2001 From: Boden R Date: Wed, 10 Apr 2019 10:21:41 -0600 Subject: [PATCH] use rpc agent topics from neutron-lib There are a few places in neutron that are not yet using the agent topics module from neutron-lib. This patch address them by: - Removing neutron.agent._topics - Switching all uses of topics over to use neutron-lib NeutronLibImpact Change-Id: Ic9699ca93cd6fe59ed575ab444c4a4f9456323b2 --- neutron/agent/_topics.py | 24 ------------------- .../agent/linuxbridge_neutron_agent.py | 5 ++-- neutron/plugins/ml2/rpc.py | 5 ++-- .../services/metering/test_metering_plugin.py | 5 ++-- 4 files changed, 7 insertions(+), 32 deletions(-) delete mode 100644 neutron/agent/_topics.py diff --git a/neutron/agent/_topics.py b/neutron/agent/_topics.py deleted file mode 100644 index 6d5f8c48811..00000000000 --- a/neutron/agent/_topics.py +++ /dev/null @@ -1,24 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -""" -TODO(mlavalle): This module should be deleted once neutron-lib containing -https://review.openstack.org/#/c/564381/ change is released. -""" - -from neutron_lib.api.definitions import portbindings_extended - - -PORT_BINDING = portbindings_extended.RESOURCE_NAME - -ACTIVATE = 'activate' -DEACTIVATE = 'deactivate' diff --git a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py index 009e779354f..c9ca9ff7326 100644 --- a/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py +++ b/neutron/plugins/ml2/drivers/linuxbridge/agent/linuxbridge_neutron_agent.py @@ -34,7 +34,6 @@ from oslo_service import service from oslo_utils import excutils from six import moves -from neutron.agent import _topics as n_topics from neutron.agent.linux import bridge_lib from neutron.agent.linux import ip_lib from neutron.api.rpc.handlers import securitygroups_rpc as sg_rpc @@ -848,8 +847,8 @@ class LinuxBridgeManager(amb.CommonAgentManagerBase): [topics.NETWORK, topics.DELETE], [topics.NETWORK, topics.UPDATE], [topics.SECURITY_GROUP, topics.UPDATE], - [n_topics.PORT_BINDING, n_topics.DEACTIVATE], - [n_topics.PORT_BINDING, n_topics.ACTIVATE]] + [topics.PORT_BINDING, topics.DEACTIVATE], + [topics.PORT_BINDING, topics.ACTIVATE]] if cfg.CONF.VXLAN.l2_population: consumers.append([topics.L2POPULATION, topics.UPDATE]) return consumers diff --git a/neutron/plugins/ml2/rpc.py b/neutron/plugins/ml2/rpc.py index 292420ff302..b2eaebbf98e 100644 --- a/neutron/plugins/ml2/rpc.py +++ b/neutron/plugins/ml2/rpc.py @@ -27,7 +27,6 @@ from oslo_log import log import oslo_messaging from sqlalchemy.orm import exc -from neutron.agent import _topics as n_topics from neutron.api.rpc.handlers import dvr_rpc from neutron.api.rpc.handlers import securitygroups_rpc as sg_rpc from neutron.db import l3_hamode_db @@ -419,9 +418,9 @@ class AgentNotifierApi(dvr_rpc.DVRAgentRpcApiMixin, topics.NETWORK, topics.UPDATE) self.topic_port_binding_deactivate = topics.get_topic_name( - topic, n_topics.PORT_BINDING, n_topics.DEACTIVATE) + topic, topics.PORT_BINDING, topics.DEACTIVATE) self.topic_port_binding_activate = topics.get_topic_name( - topic, n_topics.PORT_BINDING, n_topics.ACTIVATE) + topic, topics.PORT_BINDING, topics.ACTIVATE) target = oslo_messaging.Target(topic=topic, version='1.0') self.client = n_rpc.get_client(target) diff --git a/neutron/tests/unit/services/metering/test_metering_plugin.py b/neutron/tests/unit/services/metering/test_metering_plugin.py index e647c95627f..401df324323 100644 --- a/neutron/tests/unit/services/metering/test_metering_plugin.py +++ b/neutron/tests/unit/services/metering/test_metering_plugin.py @@ -13,6 +13,7 @@ # under the License. import mock +from neutron_lib.agent import topics from neutron_lib.api.definitions import metering as metering_apidef from neutron_lib import context from neutron_lib.db import api as db_api @@ -99,7 +100,7 @@ class TestMeteringPlugin(test_db_base_plugin_v2.NeutronDbPluginV2TestCase, return_value=self.ctx) self.mock_context = self.context_patch.start() - self.topic = 'metering_agent' + self.topic = topics.METERING_AGENT add = ('neutron.api.rpc.agentnotifiers.' + 'metering_rpc_agent_api.MeteringAgentNotifyAPI' + @@ -356,7 +357,7 @@ class TestMeteringPluginL3AgentScheduler( '.get_l3_agents_hosting_routers') self.l3routers_mock = self.l3routers_patch.start() - self.topic = 'metering_agent' + self.topic = topics.METERING_AGENT add = ('neutron.api.rpc.agentnotifiers.' + 'metering_rpc_agent_api.MeteringAgentNotifyAPI' +