Files
neutron-lib/neutron_lib/agent/extension.py
Brian Haley cd8df72cc6 pyupgrade changes for Python3.9+
As discussed at the Epoxy PTG meeting, run an automated
upgrade tool to make code python 3.9+ compliant.

Result of running:

$ pyupgrade --py39-plus $(git ls-files | grep ".py$")

Fixed PEP8 errors introduced by pyupgrade by running:

$ autopep8 --select=E127,E128,E501 --max-line-length 79 -r \
  --in-place neutron_lib

Also did manual updates as necessary to fix other errors
and warnings after above commands. Removed a number of
pylint 'disable' directives.

Inspired by Octavia and Nova [0].

[0] https://review.opendev.org/c/openstack/nova/+/896986

Change-Id: Ic8c95898fc00d5463aa0992e844eee60ac3dc5a0
2024-11-04 21:18:15 -05:00

46 lines
1.8 KiB
Python

# 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
class AgentExtension(metaclass=abc.ABCMeta):
"""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: 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.
"""