Consume code from neutron-lib
All of these exceptions and constants have been in neutron-lib for a while, start using them. While looking for other things to consume found an old neutron-lib TODO that did not apply anymore, so removed. TrivialFix Change-Id: I9431075a50ba05be872db422125e6af6266ccb99
This commit is contained in:
parent
5ce17647c6
commit
3ef02cc2fb
@ -14,10 +14,9 @@
|
||||
# under the License.
|
||||
|
||||
from neutron_lib.agent import l3_extension
|
||||
from neutron_lib import exceptions
|
||||
from neutron_lib.exceptions import l3 as l3_exc
|
||||
from oslo_log import log
|
||||
|
||||
from neutron._i18n import _
|
||||
from neutron.agent import agent_extensions_manager as agent_ext_manager
|
||||
from neutron.conf.agent import agent_extensions_manager as agent_ext_mgr_config
|
||||
|
||||
@ -27,13 +26,6 @@ LOG = log.getLogger(__name__)
|
||||
L3_AGENT_EXT_MANAGER_NAMESPACE = 'neutron.agent.l3.extensions'
|
||||
|
||||
|
||||
# TODO(ralonsoh): rehome to neutron_lib.
|
||||
class L3ExtensionException(exceptions.NeutronException):
|
||||
message = _('The following L3 agent extensions do not inherit from '
|
||||
'``neutron_lib.agent.l3_extension.L3AgentExtension``: '
|
||||
'%(extensions)s.')
|
||||
|
||||
|
||||
def register_opts(conf):
|
||||
agent_ext_mgr_config.register_agent_ext_manager_opts(conf)
|
||||
|
||||
@ -49,7 +41,7 @@ class L3AgentExtensionsManager(agent_ext_manager.AgentExtensionsManager):
|
||||
if not isinstance(extension.obj, (l3_extension.L3AgentExtension,)):
|
||||
extensions.append(extension.attr)
|
||||
if extensions:
|
||||
raise L3ExtensionException(extensions=extensions)
|
||||
raise l3_exc.L3ExtensionException(extensions=extensions)
|
||||
|
||||
def add_router(self, context, data):
|
||||
"""Notify all agent extensions to add router."""
|
||||
|
@ -41,7 +41,6 @@ from neutron.agent.linux import external_process
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.agent.linux import iptables_manager
|
||||
from neutron.cmd import runtime_checks as checks
|
||||
from neutron.common import _constants as common_constants
|
||||
from neutron.common.ovn import constants as ovn_constants
|
||||
from neutron.common.ovn import utils as ovn_utils
|
||||
from neutron.common import utils as common_utils
|
||||
@ -1881,7 +1880,7 @@ class DeviceManager(object):
|
||||
if self.conf.force_metadata or self.conf.enable_isolated_metadata:
|
||||
ip_cidrs.append(constants.METADATA_CIDR)
|
||||
if netutils.is_ipv6_enabled():
|
||||
ip_cidrs.append(common_constants.METADATA_V6_CIDR)
|
||||
ip_cidrs.append(constants.METADATA_V6_CIDR)
|
||||
|
||||
self.driver.init_l3(interface_name, ip_cidrs,
|
||||
namespace=network.namespace)
|
||||
|
@ -33,7 +33,6 @@ from neutron.agent.l3 import namespaces
|
||||
from neutron.agent.linux import external_process
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.agent.linux import utils as linux_utils
|
||||
from neutron.common import _constants as common_constants
|
||||
from neutron.common import coordination
|
||||
from neutron.common import metadata as comm_meta
|
||||
from neutron.common import utils as common_utils
|
||||
@ -377,6 +376,6 @@ def apply_metadata_nat_rules(router, proxy):
|
||||
if netutils.is_ipv6_enabled():
|
||||
for c, r in proxy.metadata_nat_rules(
|
||||
proxy.metadata_port,
|
||||
metadata_address=(common_constants.METADATA_V6_CIDR)):
|
||||
metadata_address=(constants.METADATA_V6_CIDR)):
|
||||
router.iptables_manager.ipv6['nat'].add_rule(c, r)
|
||||
router.iptables_manager.apply()
|
||||
|
@ -87,8 +87,5 @@ TRAIT_NETWORK_TUNNEL = 'CUSTOM_NETWORK_TUNNEL_PROVIDER'
|
||||
# The lowest binding index for L3 agents and DHCP agents.
|
||||
LOWEST_AGENT_BINDING_INDEX = 1
|
||||
|
||||
# Neutron-lib defines this with a /64 but it should be /128
|
||||
METADATA_V6_CIDR = constants.METADATA_V6_IP + '/128'
|
||||
|
||||
# TODO(haleyb): move this constant to neutron_lib.constants
|
||||
IPV4_MIN_MTU = 68
|
||||
|
@ -83,13 +83,6 @@ FIP_ASSOC_MSG = ('Floating IP %(fip_id)s %(assoc)s. External IP: %(ext_ip)s, '
|
||||
'port: %(port_id)s.')
|
||||
|
||||
|
||||
# TODO(froyo): Move this exception to neutron-lib as soon as possible, and when
|
||||
# a new release is created and pointed to in the requirements remove this code.
|
||||
class FipAssociated(n_exc.InUse):
|
||||
message = _('Unable to complete the operation on port "%(port_id)s" '
|
||||
'because the port still has an associated floating IP.')
|
||||
|
||||
|
||||
@registry.has_registry_receivers
|
||||
class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
base_services.WorkerBase,
|
||||
@ -1832,7 +1825,7 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase,
|
||||
floating_ip_objs_admin = l3_obj.FloatingIP.get_objects(
|
||||
context.elevated(), fixed_port_id=port_id)
|
||||
if floating_ip_objs_admin != floating_ip_objs:
|
||||
raise FipAssociated(port_id=port_id)
|
||||
raise l3_exc.FipAssociated(port_id=port_id)
|
||||
|
||||
router_ids = {fip.router_id for fip in floating_ip_objs}
|
||||
old_fips = {fip.id: self._make_floatingip_dict(fip)
|
||||
|
@ -1,24 +0,0 @@
|
||||
# Copyright (c) 2021 Ericsson Software Technology
|
||||
#
|
||||
# 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.
|
||||
|
||||
from neutron_lib import exceptions as e
|
||||
|
||||
from neutron._i18n import _
|
||||
|
||||
|
||||
# TODO(przszc): Move to n-lib
|
||||
class QosPlacementAllocationUpdateConflict(e.Conflict):
|
||||
message = _("Updating placement allocation with %(alloc_diff)s for "
|
||||
"consumer %(consumer)s failed. The requested resources would "
|
||||
"exceed the capacity available.")
|
@ -2474,7 +2474,6 @@ class OVNClient(object):
|
||||
'fixed_ips': fixed_ips,
|
||||
}
|
||||
}
|
||||
# TODO(boden): rehome create_port into neutron-lib
|
||||
return p_utils.create_port(self._plugin, context, port)
|
||||
|
||||
def update_metadata_port(self, context, network, subnet=None):
|
||||
|
@ -51,7 +51,6 @@ 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.exceptions import qos as neutron_qos_exc
|
||||
from neutron.extensions import qos
|
||||
from neutron.objects import base as base_obj
|
||||
from neutron.objects import network as network_object
|
||||
@ -570,7 +569,7 @@ class QoSPlugin(qos.QoSPluginBase):
|
||||
self._placement_client.update_qos_allocation(
|
||||
consumer_uuid=device_id, alloc_diff=alloc_diff)
|
||||
except ks_exc.Conflict:
|
||||
raise neutron_qos_exc.QosPlacementAllocationUpdateConflict(
|
||||
raise qos_exc.QosPlacementAllocationUpdateConflict(
|
||||
alloc_diff=alloc_diff, consumer=device_id)
|
||||
|
||||
# NOTE(przszc): Upon successful allocation update in Placement we can
|
||||
|
@ -17,6 +17,7 @@ from unittest import mock
|
||||
from neutron_lib.api.definitions import l3_conntrack_helper as apidef
|
||||
from neutron_lib import exceptions as lib_exc
|
||||
from neutron_lib.exceptions import l3 as lib_l3_exc
|
||||
from neutron_lib.plugins import constants as plugin_consts
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
@ -34,7 +35,7 @@ class ConntrackHelperTestCase(ml2_test_base.ML2TestFramework,
|
||||
def setUp(self):
|
||||
super(ConntrackHelperTestCase, self).setUp()
|
||||
self.cth_plugin = cth_plugin.Plugin()
|
||||
directory.add_plugin("CONNTRACKHELPER", self.cth_plugin)
|
||||
directory.add_plugin(plugin_consts.CONNTRACKHELPER, self.cth_plugin)
|
||||
self.router = self._create_router(distributed=True)
|
||||
self.conntack_helper = {
|
||||
apidef.RESOURCE_NAME:
|
||||
|
@ -37,7 +37,6 @@ from neutron.agent.linux import dhcp
|
||||
from neutron.agent.linux import interface
|
||||
from neutron.agent.linux import utils as linux_utils
|
||||
from neutron.agent.metadata import driver as metadata_driver
|
||||
from neutron.common import _constants as common_constants
|
||||
from neutron.common import config as common_config
|
||||
from neutron.common.ovn import constants as ovn_const
|
||||
from neutron.common import utils
|
||||
@ -2000,7 +1999,7 @@ class TestDeviceManager(base.BaseTestCase):
|
||||
expected_ips = ['172.9.9.9/24', const.METADATA_CIDR]
|
||||
|
||||
if ipv6_enabled:
|
||||
expected_ips.append(common_constants.METADATA_V6_CIDR)
|
||||
expected_ips.append(const.METADATA_V6_CIDR)
|
||||
|
||||
expected = [mock.call.get_device_name(port)]
|
||||
|
||||
|
@ -33,7 +33,6 @@ import testtools
|
||||
from neutron.agent.linux import dhcp
|
||||
from neutron.agent.linux import ip_lib
|
||||
from neutron.cmd import runtime_checks as checks
|
||||
from neutron.common import _constants as common_constants
|
||||
from neutron.common.ovn import constants as ovn_const
|
||||
from neutron.common import utils as common_utils
|
||||
from neutron.conf.agent import common as config
|
||||
@ -3378,7 +3377,7 @@ class TestDeviceManager(TestConfBase):
|
||||
if enable_isolated_metadata or force_metadata:
|
||||
expect_ips.extend([
|
||||
constants.METADATA_CIDR,
|
||||
common_constants.METADATA_V6_CIDR])
|
||||
constants.METADATA_V6_CIDR])
|
||||
mgr.driver.init_l3.assert_called_with('ns-XXX',
|
||||
expect_ips,
|
||||
namespace='qdhcp-ns')
|
||||
|
@ -27,6 +27,7 @@ from neutron_lib import context
|
||||
from neutron_lib.db import api as db_api
|
||||
from neutron_lib import exceptions as n_exc
|
||||
from neutron_lib.exceptions import extraroute as xroute_exc
|
||||
from neutron_lib.exceptions import l3 as l3_exc
|
||||
from neutron_lib.plugins import constants as plugin_constants
|
||||
from neutron_lib.plugins import directory
|
||||
from neutron_lib.plugins import utils as plugin_utils
|
||||
@ -414,7 +415,7 @@ class TestL3_NAT_dbonly_mixin(
|
||||
get_objects.side_effect = [
|
||||
[],
|
||||
[{'id': 'floating_ip1', 'port_id': 'port_id'}]]
|
||||
self.assertRaises(l3_db.FipAssociated,
|
||||
self.assertRaises(l3_exc.FipAssociated,
|
||||
self.db.disassociate_floatingips,
|
||||
context_tenant,
|
||||
'port_id')
|
||||
|
@ -17,6 +17,7 @@ from unittest import mock
|
||||
from neutron_lib import context
|
||||
from neutron_lib import exceptions as lib_exc
|
||||
from neutron_lib.objects import exceptions as obj_exc
|
||||
from neutron_lib.plugins import constants as plugin_consts
|
||||
from neutron_lib.plugins import directory
|
||||
from oslo_config import cfg
|
||||
|
||||
@ -69,9 +70,7 @@ class TestConntrackHelperPlugin(testlib_api.SqlTestCase):
|
||||
cfg.CONF.set_override("service_plugins", ["router",
|
||||
"conntrack_helper"])
|
||||
manager.init()
|
||||
# TODO(hjensas): Add CONNTRACKHELPER to neutron-lib Well-known
|
||||
# service type constants.
|
||||
self.cth_plugin = directory.get_plugin("CONNTRACKHELPER")
|
||||
self.cth_plugin = directory.get_plugin(plugin_consts.CONNTRACKHELPER)
|
||||
self.ctxt = context.Context('admin', 'fake_tenant')
|
||||
mock.patch.object(self.ctxt.session, 'refresh').start()
|
||||
mock.patch.object(self.ctxt.session, 'expunge').start()
|
||||
|
@ -35,7 +35,6 @@ from oslo_utils import uuidutils
|
||||
import webob.exc
|
||||
|
||||
from neutron.common import _constants as n_const
|
||||
from neutron.exceptions import qos as neutron_qos_exc
|
||||
from neutron.extensions import qos_pps_minimum_rule_alias
|
||||
from neutron.extensions import qos_rules_alias
|
||||
from neutron import manager
|
||||
@ -2802,7 +2801,7 @@ class TestQosPluginDB(base.BaseQosTestCase):
|
||||
response={'errors': [{'code': 'placement.concurrent_update'}]}
|
||||
)
|
||||
self.assertRaises(
|
||||
neutron_qos_exc.QosPlacementAllocationUpdateConflict,
|
||||
qos_exc.QosPlacementAllocationUpdateConflict,
|
||||
self.qos_plugin._change_placement_allocation,
|
||||
qos1, qos2, orig_port, port)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user