From ad6a383e2ff3c17a489fdeb6241a5eda4d67f578 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Thu, 12 Dec 2024 18:11:57 -0600 Subject: [PATCH] feat(neutron): add no-op trunk driver for understack This adds an effectively no-op trunk driver for the understack mechanism driver. This allows the trunk plugin to load and work with the undercloud ML2 mechanism. No operations are being performed here so it's just a stub. --- .../neutron_understack_mech.py | 2 ++ .../neutron_understack/trunk.py | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 python/neutron-understack/neutron_understack/trunk.py diff --git a/python/neutron-understack/neutron_understack/neutron_understack_mech.py b/python/neutron-understack/neutron_understack/neutron_understack_mech.py index 8abb5a02..51e95810 100644 --- a/python/neutron-understack/neutron_understack/neutron_understack_mech.py +++ b/python/neutron-understack/neutron_understack/neutron_understack_mech.py @@ -14,6 +14,7 @@ from neutron_understack import config from neutron_understack.nautobot import Nautobot +from neutron_understack.trunk import UnderStackTrunkDriver from neutron_understack.undersync import Undersync LOG = logging.getLogger(__name__) @@ -110,6 +111,7 @@ def initialize(self): conf = cfg.CONF.ml2_understack self.nb = Nautobot(conf.nb_url, conf.nb_token) self.undersync = Undersync(conf.undersync_token, conf.undersync_url) + self.trunk_driver = UnderStackTrunkDriver.create(self) def create_network_precommit(self, context): log_call("create_network_precommit", context) diff --git a/python/neutron-understack/neutron_understack/trunk.py b/python/neutron-understack/neutron_understack/trunk.py new file mode 100644 index 00000000..78aebe73 --- /dev/null +++ b/python/neutron-understack/neutron_understack/trunk.py @@ -0,0 +1,28 @@ +from neutron.services.trunk.drivers import base as trunk_base +from neutron_lib.api.definitions import portbindings +from neutron_lib.services.trunk import constants as trunk_consts +from oslo_config import cfg + +SUPPORTED_INTERFACES = (portbindings.VIF_TYPE_OTHER,) + +SUPPORTED_SEGMENTATION_TYPES = (trunk_consts.SEGMENTATION_TYPE_VLAN,) + + +class UnderStackTrunkDriver(trunk_base.DriverBase): + @property + def is_loaded(self): + try: + return "understack" in cfg.CONF.ml2.mechanism_drivers + except cfg.NoSuchOptError: + return False + + @classmethod + def create(cls, plugin_driver): + cls.plugin_driver = plugin_driver + return cls( + "understack", + SUPPORTED_INTERFACES, + SUPPORTED_SEGMENTATION_TYPES, + None, + can_trunk_bound_port=True, + )