Merge "Consume tunnelled networks resource constants from neutron-lib"

This commit is contained in:
Zuul
2025-11-11 23:37:39 +00:00
committed by Gerrit Code Review
6 changed files with 13 additions and 19 deletions

View File

@@ -13,13 +13,12 @@
# limitations under the License.
from neutron_lib import constants as nlib_const
from neutron_lib.placement import constants as place_constants
from neutron_lib.placement import utils as place_utils
import os_resource_classes as orc
from oslo_config import cfg
from oslo_log import log as logging
from neutron.common import _constants as n_const
LOG = logging.getLogger(__name__)
@@ -121,7 +120,7 @@ class PlacementState:
def _deferred_update_tunnelled_traits(self):
return [DeferredCall(self._client.update_trait,
name=n_const.TRAIT_NETWORK_TUNNEL)]
name=place_constants.TRAIT_NETWORK_TUNNEL)]
def _deferred_update_vnic_type_traits(self):
traits = []
@@ -226,11 +225,11 @@ class PlacementState:
if device == self._rp_tun_name and device not in physical_bridges:
# That means the RP for tunnelled networks is not associated
# to a physical bridge interface.
return [n_const.TRAIT_NETWORK_TUNNEL]
return [place_constants.TRAIT_NETWORK_TUNNEL]
if device == self._rp_tun_name and device in physical_bridges:
# The physical network and the tunnelled networks share the
# same physical interface.
return [n_const.TRAIT_NETWORK_TUNNEL,
return [place_constants.TRAIT_NETWORK_TUNNEL,
physnet_trait_mappings[device]]
# Just the physical interface.
return [physnet_trait_mappings.get(device)]

View File

@@ -86,11 +86,6 @@ AUTO_DELETE_PORT_OWNERS = [constants.DEVICE_OWNER_DHCP,
constants.DEVICE_OWNER_DISTRIBUTED,
constants.DEVICE_OWNER_AGENT_GW]
# TODO(ralonsoh): move this constant to neutron_lib.placement.constants
# Tunnelled networks resource provider default name.
RP_TUNNELLED = 'rp_tunnelled'
TRAIT_NETWORK_TUNNEL = 'CUSTOM_NETWORK_TUNNEL_PROVIDER'
# The lowest binding index for L3 agents and DHCP agents.
LOWEST_AGENT_BINDING_INDEX = 1

View File

@@ -14,10 +14,10 @@
# under the License.
from neutron_lib import constants
from neutron_lib.placement import constants as place_constants
from oslo_config import cfg
from neutron._i18n import _
from neutron.common import _constants as common_const
ml2_opts = [
@@ -76,7 +76,7 @@ ml2_opts = [
help=_("IP version of all overlay (tunnel) network "
"endpoints.")),
cfg.StrOpt('tunnelled_network_rp_name',
default=common_const.RP_TUNNELLED,
default=place_constants.RP_TUNNELLED,
help=_("Resource provider name for the host with tunnelled "
"networks. This resource provider represents the "
"available bandwidth for all tunnelled networks in a "

View File

@@ -42,6 +42,7 @@ from neutron_lib.db import resource_extend
from neutron_lib import exceptions as lib_exc
from neutron_lib.exceptions import qos as qos_exc
from neutron_lib.placement import client as pl_client
from neutron_lib.placement import constants as pl_constants
from neutron_lib.placement import utils as pl_utils
from neutron_lib.services.qos import constants as qos_consts
import os_resource_classes as orc
@@ -49,7 +50,6 @@ from oslo_config import cfg
from oslo_log import log as logging
from neutron._i18n import _
from neutron.common import _constants as n_const
from neutron.db import db_base_plugin_common
from neutron.extensions import qos
from neutron.objects import base as base_obj
@@ -259,7 +259,7 @@ class QoSPlugin(qos.QoSPluginBase):
if not first_segment.physical_network:
# If there is no physical network this is because this is an
# overlay network (tunnelled network).
net_trait = n_const.TRAIT_NETWORK_TUNNEL
net_trait = pl_constants.TRAIT_NETWORK_TUNNEL
else:
net_trait = pl_utils.physnet_trait(first_segment.physical_network)

View File

@@ -15,10 +15,10 @@
from unittest import mock
import uuid
from neutron_lib.placement import constants as pl_constants
from oslo_config import cfg
from neutron.agent.common import placement_report
from neutron.common import _constants as n_const
from neutron.conf.plugins.ml2 import config as ml2_config
from neutron.tests import base
@@ -242,7 +242,7 @@ class PlacementStateTestCase(base.BaseTestCase):
self.client_mock.update_resource_provider_traits.call_args_list]
self.assertEqual(
[{'CUSTOM_PHYSNET_PHYSNET0', 'CUSTOM_VNIC_TYPE_NORMAL'},
{n_const.TRAIT_NETWORK_TUNNEL, 'CUSTOM_VNIC_TYPE_NORMAL'},
{pl_constants.TRAIT_NETWORK_TUNNEL, 'CUSTOM_VNIC_TYPE_NORMAL'},
{'CUSTOM_VNIC_TYPE_NORMAL'}],
actual_traits)
@@ -283,7 +283,7 @@ class PlacementStateTestCase(base.BaseTestCase):
set(args[1]['traits']) for args in
self.client_mock.update_resource_provider_traits.call_args_list]
self.assertEqual(
[{n_const.TRAIT_NETWORK_TUNNEL, 'CUSTOM_PHYSNET_PHYSNET0',
[{pl_constants.TRAIT_NETWORK_TUNNEL, 'CUSTOM_PHYSNET_PHYSNET0',
'CUSTOM_VNIC_TYPE_NORMAL'},
{'CUSTOM_VNIC_TYPE_NORMAL'}],
actual_traits)

View File

@@ -24,6 +24,7 @@ from neutron_lib import exceptions as lib_exc
from neutron_lib.exceptions import placement as pl_exc
from neutron_lib.exceptions import qos as qos_exc
from neutron_lib.objects import utils as obj_utils
from neutron_lib.placement import constants as pl_constants
from neutron_lib.placement import utils as pl_utils
from neutron_lib.plugins import constants as plugins_constants
from neutron_lib.plugins import directory
@@ -34,7 +35,6 @@ from oslo_config import cfg
from oslo_utils import uuidutils
import webob.exc
from neutron.common import _constants as n_const
from neutron.extensions import qos_pps_minimum_rule_alias
from neutron.extensions import qos_rules_alias
from neutron import manager
@@ -133,7 +133,7 @@ class TestQosPlugin(base.BaseQosTestCase):
self.ctxt, **self.rule_data['minimum_packet_rate_rule'])
self._rp_tun_name = cfg.CONF.ml2.tunnelled_network_rp_name
self._rp_tun_trait = n_const.TRAIT_NETWORK_TUNNEL
self._rp_tun_trait = pl_constants.TRAIT_NETWORK_TUNNEL
self.network_id = uuidutils.generate_uuid()