diff --git a/doc/source/contributor/internals/agent_extensions.rst b/doc/source/contributor/internals/agent_extensions.rst index 3cb14af171f..56339655e9e 100644 --- a/doc/source/contributor/internals/agent_extensions.rst +++ b/doc/source/contributor/internals/agent_extensions.rst @@ -63,14 +63,14 @@ neutron.agent.l2.extensions namespace. The relevant modules are: -* neutron.agent.agent_extension: +* neutron_lib.agent.extension: This module defines an abstract extension interface for all agent extensions across L2 and L3. -* neutron.agent.l2.l2_agent_extension: -* neutron.agent.l3.l3_agent_extension: +* neutron_lib.agent.l2_extension: +* neutron_lib.agent.l3_extension: These modules subclass - neutron.agent.agent_extension.AgentExtension and define a + neutron_lib.agent.extension.AgentExtension and define a layer-specific abstract extension interface. * neutron.agent.agent_extensions_manager: @@ -99,9 +99,9 @@ For L3, see :doc:`L3 agent extensions `. The relevant modules are: -* neutron.agent.agent_extension +* neutron_lib.agent.extension +* neutron_lib.agent.l2_extension +* neutron_lib.agent.l3_extension * neutron.agent.agent_extensions_manager -* neutron.agent.l2.l2_agent_extension_api * neutron.agent.l2.l2_agent_extensions_manager -* neutron.agent.l3.l3_agent_extension_api * neutron.agent.l3.l3_agent_extensions_manager diff --git a/neutron/agent/agent_extension.py b/neutron/agent/agent_extension.py deleted file mode 100644 index 27f556ee92c..00000000000 --- a/neutron/agent/agent_extension.py +++ /dev/null @@ -1,48 +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. - -import abc - -import six - - -@six.add_metaclass(abc.ABCMeta) -class AgentExtension(object): - """Define stable abstract interface for agent extensions. - - An agent extension extends the agent core functionality. - """ - - @abc.abstractmethod - def initialize(self, connection, driver_type): - """Perform agent core resource extension initialization. - - :param connection: RPC connection that can be reused by the extension - to define its RPC endpoints - :param driver_type: a string that defines the agent type to the - extension. Can be used to choose the right backend - implementation. - - Called after all extensions have been loaded. - No resource (port, policy, router, etc.) handling will be called before - this method. - """ - - def consume_api(self, agent_api): - """Consume the AgentAPI instance from the AgentExtensionsManager. - - Allows an extension to gain access to resources internal to the - neutron agent and otherwise unavailable to the extension. Examples of - such resources include bridges, ports, and routers. - - :param agent_api: An instance of an agent-specific API. - """ diff --git a/neutron/agent/l2/agent_extension.py b/neutron/agent/l2/agent_extension.py deleted file mode 100644 index e895d760f45..00000000000 --- a/neutron/agent/l2/agent_extension.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2015 Mellanox Technologies, Ltd -# All Rights Reserved. -# -# 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. - -import abc - -import six - -from neutron.agent.l2 import l2_agent_extension - - -@six.add_metaclass(abc.ABCMeta) -class AgentCoreResourceExtension(l2_agent_extension.L2AgentExtension): - """This is a shim around L2AgentExtension class. It is intended for use by - out of tree extensions that were inheriting AgentCoreResourceExtension. - """ diff --git a/neutron/agent/l2/extensions/fdb_population.py b/neutron/agent/l2/extensions/fdb_population.py index 2c2f5253210..2619a653edc 100644 --- a/neutron/agent/l2/extensions/fdb_population.py +++ b/neutron/agent/l2/extensions/fdb_population.py @@ -15,12 +15,12 @@ import sys +from neutron_lib.agent import l2_extension from neutron_lib import constants from neutron_lib.utils import helpers from oslo_config import cfg from oslo_log import log as logging -from neutron.agent.l2 import l2_agent_extension from neutron.agent.linux import bridge_lib from neutron.conf.agent import l2_ext_fdb_population from neutron.plugins.ml2.drivers.linuxbridge.agent.common import ( @@ -34,7 +34,7 @@ LOG = logging.getLogger(__name__) class FdbPopulationAgentExtension( - l2_agent_extension.L2AgentExtension): + l2_extension.L2AgentExtension): """The FDB population is an agent extension to OVS or linux bridge who's objective is to update the FDB table for existing instance using normal port, thus enabling communication between SR-IOV instances diff --git a/neutron/agent/l2/extensions/qos.py b/neutron/agent/l2/extensions/qos.py index 5387372eb8d..4e4b83ebb33 100644 --- a/neutron/agent/l2/extensions/qos.py +++ b/neutron/agent/l2/extensions/qos.py @@ -16,13 +16,13 @@ import abc import collections +from neutron_lib.agent import l2_extension from neutron_lib import constants from neutron_lib.services.qos import constants as qos_consts from oslo_concurrency import lockutils from oslo_log import log as logging import six -from neutron.agent.l2 import l2_agent_extension from neutron.api.rpc.callbacks.consumer import registry from neutron.api.rpc.callbacks import events from neutron.api.rpc.callbacks import resources @@ -194,7 +194,7 @@ class PortPolicyMap(object): del self.known_policies[qos_policy_id] -class QosAgentExtension(l2_agent_extension.L2AgentExtension): +class QosAgentExtension(l2_extension.L2AgentExtension): SUPPORTED_RESOURCE_TYPES = [resources.QOS_POLICY] def initialize(self, connection, driver_type): diff --git a/neutron/agent/l2/l2_agent_extension.py b/neutron/agent/l2/l2_agent_extension.py deleted file mode 100644 index 7ab72cea0dd..00000000000 --- a/neutron/agent/l2/l2_agent_extension.py +++ /dev/null @@ -1,48 +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. - -import abc - -import six - -from neutron.agent import agent_extension - - -@six.add_metaclass(abc.ABCMeta) -class L2AgentExtension(agent_extension.AgentExtension): - """Define stable abstract interface for l2 agent extensions. - - An agent extension extends the agent core functionality. - """ - - def initialize(self, connection, driver_type): - """Initialize agent extension.""" - - @abc.abstractmethod - def handle_port(self, context, data): - """Handle agent extension for port. - - This can be called on either create or update, depending on the - code flow. Thus, it's this function's responsibility to check what - actually changed. - - :param context: rpc context - :param data: port data - """ - - @abc.abstractmethod - def delete_port(self, context, data): - """Delete port from agent extension. - - :param context: rpc context - :param data: port data - """ diff --git a/neutron/agent/l3/l3_agent_extension.py b/neutron/agent/l3/l3_agent_extension.py deleted file mode 100644 index d00e918a7e7..00000000000 --- a/neutron/agent/l3/l3_agent_extension.py +++ /dev/null @@ -1,65 +0,0 @@ -# All Rights Reserved. -# -# 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. - -import abc - -import six - -from neutron.agent import agent_extension - - -@six.add_metaclass(abc.ABCMeta) -class L3AgentCoreResourceExtension(agent_extension.AgentExtension): - """Define stable abstract interface for l3 agent extensions. - - An agent extension extends the agent core functionality. - """ - - @abc.abstractmethod - def add_router(self, context, data): - """add agent extension for router. - - Called on router create. - - :param context: rpc context - :param data: router data - """ - - @abc.abstractmethod - def update_router(self, context, data): - """Handle agent extension for update. - - Called on router update. - - :param context: rpc context - :param data: router data - """ - - @abc.abstractmethod - def delete_router(self, context, data): - """Delete router from agent extension. - - :param context: rpc context - :param data: router data - """ - - @abc.abstractmethod - def ha_state_change(self, context, data): - """Change router state from agent extension. - - Called on HA router state change. - - :param context: rpc context - :param data: dict of router_id and new state - """ diff --git a/neutron/services/logapi/agent/log_extension.py b/neutron/services/logapi/agent/log_extension.py index 384dac89db9..3c8f28afe63 100644 --- a/neutron/services/logapi/agent/log_extension.py +++ b/neutron/services/logapi/agent/log_extension.py @@ -16,11 +16,11 @@ import abc import contextlib +from neutron_lib.agent import extension from neutron_lib import constants from oslo_concurrency import lockutils import six -from neutron.agent import agent_extension from neutron.api.rpc.callbacks.consumer import registry from neutron.api.rpc.callbacks import events from neutron.api.rpc.callbacks import resources @@ -80,7 +80,7 @@ class LoggingDriver(object): self.defer_apply_off() -class LoggingExtension(agent_extension.AgentExtension): +class LoggingExtension(extension.AgentExtension): SUPPORTED_RESOURCE_TYPES = [resources.LOGGING_RESOURCE] def initialize(self, connection, driver_type):