diff --git a/neutron/agent/common/ovs_lib.py b/neutron/agent/common/ovs_lib.py index e1b8020b3b3..5c698656130 100644 --- a/neutron/agent/common/ovs_lib.py +++ b/neutron/agent/common/ovs_lib.py @@ -19,6 +19,7 @@ import operator import time import uuid +from neutron_lib import exceptions from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils @@ -29,7 +30,6 @@ from neutron._i18n import _, _LE, _LI, _LW from neutron.agent.common import utils from neutron.agent.linux import ip_lib from neutron.agent.ovsdb import api as ovsdb -from neutron.common import exceptions from neutron.plugins.common import constants as p_const from neutron.plugins.ml2.drivers.openvswitch.agent.common \ import constants diff --git a/neutron/agent/dhcp/agent.py b/neutron/agent/dhcp/agent.py index 8a1c8eeee54..b3bf8544b4e 100644 --- a/neutron/agent/dhcp/agent.py +++ b/neutron/agent/dhcp/agent.py @@ -17,6 +17,7 @@ import collections import os import eventlet +from neutron_lib import exceptions from oslo_config import cfg from oslo_log import log as logging import oslo_messaging @@ -29,7 +30,6 @@ from neutron.agent.linux import external_process from neutron.agent.metadata import driver as metadata_driver from neutron.agent import rpc as agent_rpc from neutron.common import constants -from neutron.common import exceptions from neutron.common import rpc as n_rpc from neutron.common import topics from neutron.common import utils diff --git a/neutron/agent/l2/extensions/qos.py b/neutron/agent/l2/extensions/qos.py index 34521dbac55..bf0866b6ade 100644 --- a/neutron/agent/l2/extensions/qos.py +++ b/neutron/agent/l2/extensions/qos.py @@ -16,6 +16,7 @@ import abc import collections +from neutron_lib import exceptions from oslo_concurrency import lockutils from oslo_log import log as logging import six @@ -26,7 +27,6 @@ from neutron.api.rpc.callbacks.consumer import registry from neutron.api.rpc.callbacks import events from neutron.api.rpc.callbacks import resources from neutron.api.rpc.handlers import resources_rpc -from neutron.common import exceptions from neutron import manager LOG = logging.getLogger(__name__) diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py index 775f79f45c8..91a701db710 100644 --- a/neutron/agent/linux/dhcp.py +++ b/neutron/agent/linux/dhcp.py @@ -21,6 +21,7 @@ import shutil import time import netaddr +from neutron_lib import exceptions from oslo_config import cfg from oslo_log import log as logging import oslo_messaging @@ -34,7 +35,7 @@ from neutron.agent.linux import external_process from neutron.agent.linux import ip_lib from neutron.agent.linux import iptables_manager from neutron.common import constants -from neutron.common import exceptions +from neutron.common import exceptions as n_exc from neutron.common import ipv6_utils from neutron.common import utils as common_utils from neutron.extensions import extra_dhcp_opt as edo_ext @@ -1129,7 +1130,7 @@ class DeviceManager(object): port.id, {'port': {'network_id': network.id, 'device_id': device_id}}) except oslo_messaging.RemoteError as e: - if e.exc_type == exceptions.DhcpPortInUse: + if e.exc_type == n_exc.DhcpPortInUse: LOG.info(_LI("Skipping DHCP port %s as it is " "already in use"), port.id) continue diff --git a/neutron/agent/linux/ip_lib.py b/neutron/agent/linux/ip_lib.py index 5941c1b3dc8..0cb2a87405d 100644 --- a/neutron/agent/linux/ip_lib.py +++ b/neutron/agent/linux/ip_lib.py @@ -18,6 +18,7 @@ import re import eventlet import netaddr +from neutron_lib import exceptions from oslo_config import cfg from oslo_log import log as logging from oslo_utils import excutils @@ -26,7 +27,7 @@ import six from neutron._i18n import _, _LE from neutron.agent.common import utils from neutron.common import constants -from neutron.common import exceptions +from neutron.common import exceptions as n_exc LOG = logging.getLogger(__name__) @@ -239,7 +240,7 @@ class IPWrapper(SubProcessBase): if port and len(port) == 2: cmd.extend(['port', port[0], port[1]]) elif port: - raise exceptions.NetworkVxlanPortRangeError(vxlan_range=port) + raise n_exc.NetworkVxlanPortRangeError(vxlan_range=port) self._as_root([], 'link', cmd) return (IPDevice(name, namespace=self.namespace)) @@ -699,7 +700,7 @@ class IpRouteCommand(IpDeviceCommandBase): with excutils.save_and_reraise_exception() as ctx: if "Cannot find device" in str(rte): ctx.reraise = False - raise exceptions.DeviceNotFoundError(device_name=self.name) + raise n_exc.DeviceNotFoundError(device_name=self.name) def delete_gateway(self, gateway, table=None): ip_version = get_ip_version(gateway) diff --git a/neutron/agent/linux/ip_link_support.py b/neutron/agent/linux/ip_link_support.py index 1a49947530a..b633bbfb0dd 100644 --- a/neutron/agent/linux/ip_link_support.py +++ b/neutron/agent/linux/ip_link_support.py @@ -15,11 +15,11 @@ import re +from neutron_lib import exceptions as n_exc from oslo_log import log as logging from neutron._i18n import _, _LE from neutron.agent.linux import utils -from neutron.common import exceptions as n_exc LOG = logging.getLogger(__name__) diff --git a/neutron/agent/linux/keepalived.py b/neutron/agent/linux/keepalived.py index 7cfac72c59b..2368bbeea76 100644 --- a/neutron/agent/linux/keepalived.py +++ b/neutron/agent/linux/keepalived.py @@ -17,13 +17,13 @@ import itertools import os import netaddr +from neutron_lib import exceptions from oslo_config import cfg from oslo_log import log as logging from neutron._i18n import _, _LE from neutron.agent.linux import external_process from neutron.common import constants -from neutron.common import exceptions from neutron.common import utils as common_utils VALID_STATES = ['MASTER', 'BACKUP'] diff --git a/neutron/agent/linux/openvswitch_firewall/firewall.py b/neutron/agent/linux/openvswitch_firewall/firewall.py index fbdf86c9d11..f7a16fb4e0c 100644 --- a/neutron/agent/linux/openvswitch_firewall/firewall.py +++ b/neutron/agent/linux/openvswitch_firewall/firewall.py @@ -14,6 +14,7 @@ # under the License. import netaddr +from neutron_lib import exceptions from oslo_log import log as logging from neutron._i18n import _, _LE, _LW @@ -21,7 +22,6 @@ from neutron.agent import firewall from neutron.agent.linux.openvswitch_firewall import constants as ovsfw_consts from neutron.agent.linux.openvswitch_firewall import rules from neutron.common import constants -from neutron.common import exceptions from neutron.common import ipv6_utils from neutron.plugins.ml2.drivers.openvswitch.agent.common import constants \ as ovs_consts diff --git a/neutron/agent/linux/tc_lib.py b/neutron/agent/linux/tc_lib.py index 4f9e936f563..d6f5dc1dd33 100644 --- a/neutron/agent/linux/tc_lib.py +++ b/neutron/agent/linux/tc_lib.py @@ -15,9 +15,10 @@ import re +from neutron_lib import exceptions + from neutron._i18n import _ from neutron.agent.linux import ip_lib -from neutron.common import exceptions INGRESS_QDISC_ID = "ffff:" diff --git a/neutron/agent/ovsdb/native/idlutils.py b/neutron/agent/ovsdb/native/idlutils.py index b78110892d7..c5260e29435 100644 --- a/neutron/agent/ovsdb/native/idlutils.py +++ b/neutron/agent/ovsdb/native/idlutils.py @@ -17,13 +17,13 @@ import os import time import uuid +from neutron_lib import exceptions from ovs.db import idl from ovs import jsonrpc from ovs import poller from ovs import stream from neutron._i18n import _ -from neutron.common import exceptions RowLookup = collections.namedtuple('RowLookup', diff --git a/neutron/api/api_common.py b/neutron/api/api_common.py index 0252a5fb424..a16c1fd93ae 100644 --- a/neutron/api/api_common.py +++ b/neutron/api/api_common.py @@ -15,6 +15,7 @@ import functools +from neutron_lib import exceptions from oslo_config import cfg from oslo_log import log as logging from six.moves.urllib import parse @@ -22,7 +23,6 @@ from webob import exc from neutron._i18n import _, _LW from neutron.common import constants -from neutron.common import exceptions LOG = logging.getLogger(__name__) diff --git a/neutron/api/rpc/callbacks/exceptions.py b/neutron/api/rpc/callbacks/exceptions.py index 87724ae419b..f6511ac0c78 100644 --- a/neutron/api/rpc/callbacks/exceptions.py +++ b/neutron/api/rpc/callbacks/exceptions.py @@ -10,8 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions + from neutron._i18n import _ -from neutron.common import exceptions class CallbackWrongResourceType(exceptions.NeutronException): diff --git a/neutron/api/rpc/handlers/dhcp_rpc.py b/neutron/api/rpc/handlers/dhcp_rpc.py index e0b71310624..df110a04f8d 100644 --- a/neutron/api/rpc/handlers/dhcp_rpc.py +++ b/neutron/api/rpc/handlers/dhcp_rpc.py @@ -17,6 +17,7 @@ import copy import itertools import operator +from neutron_lib import exceptions from oslo_config import cfg from oslo_db import exception as db_exc from oslo_log import log as logging @@ -91,18 +92,20 @@ class DhcpRpcCallback(object): return plugin.update_port(context, port['id'], port) else: msg = _('Unrecognized action') - raise n_exc.Invalid(message=msg) - except (db_exc.DBError, n_exc.NetworkNotFound, - n_exc.SubnetNotFound, n_exc.IpAddressGenerationFailure) as e: + raise exceptions.Invalid(message=msg) + except (db_exc.DBError, + exceptions.NetworkNotFound, + exceptions.SubnetNotFound, + exceptions.IpAddressGenerationFailure) as e: with excutils.save_and_reraise_exception(reraise=False) as ctxt: - if isinstance(e, n_exc.IpAddressGenerationFailure): + if isinstance(e, exceptions.IpAddressGenerationFailure): # Check if the subnet still exists and if it does not, # this is the reason why the ip address generation failed. # In any other unlikely event re-raise try: subnet_id = port['port']['fixed_ips'][0]['subnet_id'] plugin.get_subnet(context, subnet_id) - except n_exc.SubnetNotFound: + except exceptions.SubnetNotFound: pass else: ctxt.reraise = True @@ -158,7 +161,7 @@ class DhcpRpcCallback(object): plugin = manager.NeutronManager.get_plugin() try: network = plugin.get_network(context, network_id) - except n_exc.NetworkNotFound: + except exceptions.NetworkNotFound: LOG.debug("Network %s could not be found, it might have " "been deleted concurrently.", network_id) return diff --git a/neutron/api/rpc/handlers/l3_rpc.py b/neutron/api/rpc/handlers/l3_rpc.py index 7e5bd94fbdb..18deea94f50 100644 --- a/neutron/api/rpc/handlers/l3_rpc.py +++ b/neutron/api/rpc/handlers/l3_rpc.py @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from neutron_lib import exceptions from oslo_config import cfg from oslo_log import log as logging import oslo_messaging @@ -20,7 +21,6 @@ from oslo_serialization import jsonutils import six from neutron.common import constants -from neutron.common import exceptions from neutron.common import utils from neutron import context as neutron_context from neutron.db import api as db_api diff --git a/neutron/api/rpc/handlers/resources_rpc.py b/neutron/api/rpc/handlers/resources_rpc.py index 10a796e2d50..e3f6acb4d95 100644 --- a/neutron/api/rpc/handlers/resources_rpc.py +++ b/neutron/api/rpc/handlers/resources_rpc.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions from oslo_log import helpers as log_helpers from oslo_log import log as logging import oslo_messaging @@ -23,7 +24,6 @@ from neutron.api.rpc.callbacks.producer import registry as prod_registry from neutron.api.rpc.callbacks import resources from neutron.api.rpc.callbacks import version_manager from neutron.common import constants -from neutron.common import exceptions from neutron.common import rpc as n_rpc from neutron.common import topics from neutron.objects import base as obj_base diff --git a/neutron/api/v2/attributes.py b/neutron/api/v2/attributes.py index fe021585af9..581af5bcdb9 100644 --- a/neutron/api/v2/attributes.py +++ b/neutron/api/v2/attributes.py @@ -17,6 +17,7 @@ import functools import re import netaddr +from neutron_lib import exceptions as n_exc from oslo_log import log as logging from oslo_utils import uuidutils import six @@ -24,7 +25,6 @@ import webob.exc from neutron._i18n import _ from neutron.common import constants -from neutron.common import exceptions as n_exc LOG = logging.getLogger(__name__) diff --git a/neutron/api/v2/base.py b/neutron/api/v2/base.py index ad499b644ce..6b1cd14d22b 100644 --- a/neutron/api/v2/base.py +++ b/neutron/api/v2/base.py @@ -17,6 +17,7 @@ import collections import copy import netaddr +from neutron_lib import exceptions from oslo_config import cfg from oslo_log import log as logging from oslo_policy import policy as oslo_policy @@ -30,7 +31,7 @@ from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api from neutron.api.v2 import attributes from neutron.api.v2 import resource as wsgi_resource from neutron.common import constants as const -from neutron.common import exceptions +from neutron.common import exceptions as n_exc from neutron.common import rpc as n_rpc from neutron.db import api as db_api from neutron import policy @@ -453,7 +454,7 @@ class Controller(object): {self._resource: delta}, self._plugin) reservations.append(reservation) - except exceptions.QuotaResourceUnknown as e: + except n_exc.QuotaResourceUnknown as e: # We don't want to quota this resource LOG.debug(e) diff --git a/neutron/api/v2/resource.py b/neutron/api/v2/resource.py index a7abe5fd75f..d48c8fbf71a 100644 --- a/neutron/api/v2/resource.py +++ b/neutron/api/v2/resource.py @@ -20,6 +20,7 @@ Utility methods for working with WSGI servers redux import sys import netaddr +from neutron_lib import exceptions import oslo_i18n from oslo_log import log as logging from oslo_policy import policy as oslo_policy @@ -28,7 +29,6 @@ import webob.dec import webob.exc from neutron._i18n import _, _LE, _LI -from neutron.common import exceptions from neutron import wsgi diff --git a/neutron/callbacks/exceptions.py b/neutron/callbacks/exceptions.py index be5e6d58a0e..03e994e4e5d 100644 --- a/neutron/callbacks/exceptions.py +++ b/neutron/callbacks/exceptions.py @@ -10,8 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions + from neutron._i18n import _ -from neutron.common import exceptions class Invalid(exceptions.NeutronException): diff --git a/neutron/common/rpc.py b/neutron/common/rpc.py index c0826c45a55..a8c8c73cf81 100644 --- a/neutron/common/rpc.py +++ b/neutron/common/rpc.py @@ -14,6 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as lib_exceptions from oslo_config import cfg from oslo_log import log as logging import oslo_messaging @@ -33,6 +34,7 @@ NOTIFIER = None ALLOWED_EXMODS = [ exceptions.__name__, + lib_exceptions.__name__, ] EXTRA_EXMODS = [] diff --git a/neutron/db/api.py b/neutron/db/api.py index adb5e28bdcc..90ed6a1e8f8 100644 --- a/neutron/db/api.py +++ b/neutron/db/api.py @@ -16,6 +16,7 @@ import contextlib import debtcollector +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_db import api as oslo_db_api from oslo_db import exception as db_exc @@ -23,7 +24,6 @@ from oslo_db.sqlalchemy import session from oslo_utils import excutils from oslo_utils import uuidutils -from neutron.common import exceptions as n_exc from neutron.db import common_db_mixin diff --git a/neutron/db/bgp_db.py b/neutron/db/bgp_db.py index 93cf4f537ca..fd29c1020b0 100644 --- a/neutron/db/bgp_db.py +++ b/neutron/db/bgp_db.py @@ -14,6 +14,7 @@ import itertools +from neutron_lib import exceptions as n_exc from oslo_db import exception as oslo_db_exc from oslo_log import log as logging from oslo_utils import uuidutils @@ -27,7 +28,6 @@ from neutron_lib import constants as lib_consts from neutron._i18n import _ from neutron.api.v2 import attributes as attr -from neutron.common import exceptions as n_exc from neutron.db import address_scope_db from neutron.db import common_db_mixin as common_db from neutron.db import l3_attrs_db diff --git a/neutron/db/db_base_plugin_common.py b/neutron/db/db_base_plugin_common.py index 6c63e5313b3..8f574233465 100644 --- a/neutron/db/db_base_plugin_common.py +++ b/neutron/db/db_base_plugin_common.py @@ -15,13 +15,14 @@ import functools +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_log import log as logging from sqlalchemy.orm import exc from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions as n_exc +from neutron.common import exceptions from neutron.common import utils from neutron.db import common_db_mixin from neutron.db import models_v2 @@ -207,7 +208,7 @@ class DbBasePluginCommon(common_db_mixin.CommonDbMixin): try: return self._get_by_id(context, models_v2.SubnetPool, id) except exc.NoResultFound: - raise n_exc.SubnetPoolNotFound(subnetpool_id=id) + raise exceptions.SubnetPoolNotFound(subnetpool_id=id) def _get_all_subnetpools(self, context): # NOTE(tidwellr): see note in _get_all_subnets() diff --git a/neutron/db/db_base_plugin_v2.py b/neutron/db/db_base_plugin_v2.py index a469f730c0b..285323fd59a 100644 --- a/neutron/db/db_base_plugin_v2.py +++ b/neutron/db/db_base_plugin_v2.py @@ -16,6 +16,7 @@ import functools import netaddr +from neutron_lib import exceptions as exc from oslo_config import cfg from oslo_db import exception as db_exc from oslo_log import log as logging @@ -76,7 +77,7 @@ def _check_subnet_not_used(context, subnet_id): registry.notify( resources.SUBNET, events.BEFORE_DELETE, None, **kwargs) except exceptions.CallbackFailure as e: - raise n_exc.SubnetInUse(subnet_id=subnet_id, reason=e) + raise exc.SubnetInUse(subnet_id=subnet_id, reason=e) class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, @@ -138,7 +139,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, if not context.is_admin and net['tenant_id'] != context.tenant_id: msg = _("Only admins can manipulate policies on networks " "they do not own.") - raise n_exc.InvalidInput(error_message=msg) + raise exc.InvalidInput(error_message=msg) tenant_to_check = None if event == events.BEFORE_UPDATE: @@ -196,11 +197,11 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, netaddr.IPAddress(route['nexthop']) except netaddr.core.AddrFormatError: err_msg = _("Invalid route: %s") % route - raise n_exc.InvalidInput(error_message=err_msg) + raise exc.InvalidInput(error_message=err_msg) except ValueError: # netaddr.IPAddress would raise this err_msg = _("Invalid route: %s") % route - raise n_exc.InvalidInput(error_message=err_msg) + raise exc.InvalidInput(error_message=err_msg) self._validate_ip_version(ip_version, route['nexthop'], 'nexthop') self._validate_ip_version(ip_version, route['destination'], 'destination') @@ -250,7 +251,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, msg = _('Invalid CIDR %s for IPv6 address mode. ' 'OpenStack uses the EUI-64 address format, ' 'which requires the prefix to be /64.') - raise n_exc.InvalidInput( + raise exc.InvalidInput( error_message=(msg % subnet['cidr'])) def _validate_ipv6_combination(self, ra_mode, address_mode): @@ -259,13 +260,13 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, "set to '%(addr_mode)s' is not valid. " "If both attributes are set, they must be the same value" ) % {'ra_mode': ra_mode, 'addr_mode': address_mode} - raise n_exc.InvalidInput(error_message=msg) + raise exc.InvalidInput(error_message=msg) def _validate_ipv6_dhcp(self, ra_mode_set, address_mode_set, enable_dhcp): if (ra_mode_set or address_mode_set) and not enable_dhcp: msg = _("ipv6_ra_mode or ipv6_address_mode cannot be set when " "enable_dhcp is set to False.") - raise n_exc.InvalidInput(error_message=msg) + raise exc.InvalidInput(error_message=msg) def _validate_ipv6_update_dhcp(self, subnet, cur_subnet): if ('enable_dhcp' in subnet and not subnet['enable_dhcp']): @@ -277,7 +278,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, subnet.get('ipv6_address_mode')) if ra_mode_set or address_mode_set: - raise n_exc.InvalidInput(error_message=msg) + raise exc.InvalidInput(error_message=msg) old_ra_mode_set = attributes.is_attr_set( cur_subnet.get('ipv6_ra_mode')) @@ -285,7 +286,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, cur_subnet.get('ipv6_address_mode')) if old_ra_mode_set or old_address_mode_set: - raise n_exc.InvalidInput(error_message=msg) + raise exc.InvalidInput(error_message=msg) def _create_bulk(self, resource, context, request_items): objects = [] @@ -380,7 +381,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, network_id=id).first() if port_in_use: - raise n_exc.NetworkInUse(net_id=id) + raise exc.NetworkInUse(net_id=id) # clean up subnets subnets = self._get_subnets_by_network(context, id) @@ -423,7 +424,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, 'ip_version': ip_version} msg = _("%(name)s '%(addr)s' does not match " "the ip_version '%(ip_version)s'") % data - raise n_exc.InvalidInput(error_message=msg) + raise exc.InvalidInput(error_message=msg) def _validate_subnet(self, context, s, cur_subnet=None): """Validate a subnet spec.""" @@ -452,17 +453,17 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, "incompatible with DHCP service enabled.") if ((ip_ver == 4 and subnet_prefixlen > 30) or (ip_ver == 6 and subnet_prefixlen > 126)): - raise n_exc.InvalidInput(error_message=error_message) + raise exc.InvalidInput(error_message=error_message) net = netaddr.IPNetwork(s['cidr']) if net.is_multicast(): error_message = _("Multicast IP subnet is not supported " "if enable_dhcp is True.") - raise n_exc.InvalidInput(error_message=error_message) + raise exc.InvalidInput(error_message=error_message) elif net.is_loopback(): error_message = _("Loopback IP subnet is not supported " "if enable_dhcp is True.") - raise n_exc.InvalidInput(error_message=error_message) + raise exc.InvalidInput(error_message=error_message) if attributes.is_attr_set(s.get('gateway_ip')): self._validate_ip_version(ip_ver, s['gateway_ip'], 'gateway_ip') @@ -471,7 +472,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, s['cidr'], s['gateway_ip'])) if is_gateway_not_valid: error_message = _("Gateway is not valid on subnet") - raise n_exc.InvalidInput(error_message=error_message) + raise exc.InvalidInput(error_message=error_message) # Ensure the gateway IP is not assigned to any port # skip this check in case of create (s parameter won't have id) # NOTE(salv-orlando): There is slight chance of a race, when @@ -498,7 +499,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, try: netaddr.IPAddress(dns) except Exception: - raise n_exc.InvalidInput( + raise exc.InvalidInput( error_message=(_("Error parsing dns address %s") % dns)) self._validate_ip_version(ip_ver, dns, 'dns_nameserver') @@ -514,11 +515,11 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, if ip_ver == 4: if attributes.is_attr_set(s.get('ipv6_ra_mode')): - raise n_exc.InvalidInput( + raise exc.InvalidInput( error_message=(_("ipv6_ra_mode is not valid when " "ip_version is 4"))) if attributes.is_attr_set(s.get('ipv6_address_mode')): - raise n_exc.InvalidInput( + raise exc.InvalidInput( error_message=(_("ipv6_address_mode is not valid when " "ip_version is 4"))) if ip_ver == 6: @@ -529,7 +530,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, if (subnet.get('ip_version') != constants.IP_VERSION_6): reason = _("Prefix Delegation can only be used with IPv6 " "subnets.") - raise n_exc.BadRequest(resource='subnets', msg=reason) + raise exc.BadRequest(resource='subnets', msg=reason) mode_list = [constants.IPV6_SLAAC, constants.DHCPV6_STATELESS] @@ -538,13 +539,13 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, if ra_mode not in mode_list: reason = _("IPv6 RA Mode must be SLAAC or Stateless for " "Prefix Delegation.") - raise n_exc.BadRequest(resource='subnets', msg=reason) + raise exc.BadRequest(resource='subnets', msg=reason) address_mode = subnet.get('ipv6_address_mode') if address_mode not in mode_list: reason = _("IPv6 Address Mode must be SLAAC or Stateless for " "Prefix Delegation.") - raise n_exc.BadRequest(resource='subnets', msg=reason) + raise exc.BadRequest(resource='subnets', msg=reason) def _update_router_gw_ports(self, context, network, subnet): l3plugin = manager.NeutronManager.get_service_plugins().get( @@ -615,7 +616,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, if use_default_subnetpool and subnetpool_id: msg = _('subnetpool_id and use_default_subnetpool cannot both be ' 'specified') - raise n_exc.BadRequest(resource='subnets', msg=msg) + raise exc.BadRequest(resource='subnets', msg=msg) if subnetpool_id: return subnetpool_id @@ -631,7 +632,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, if not attributes.is_attr_set(ip_version): msg = _('ip_version must be specified in the absence of ' 'cidr and subnetpool_id') - raise n_exc.BadRequest(resource='subnets', msg=msg) + raise exc.BadRequest(resource='subnets', msg=msg) if ip_version == 6 and cfg.CONF.ipv6_pd_enabled: return constants.IPV6_PD_POOL_ID @@ -649,7 +650,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, return cfg.CONF.default_ipv6_subnet_pool msg = _('No default subnetpool found for IPv%s') % ip_version - raise n_exc.BadRequest(resource='subnets', msg=msg) + raise exc.BadRequest(resource='subnets', msg=msg) def create_subnet(self, context, subnet): @@ -661,7 +662,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, if has_cidr and has_prefixlen: msg = _('cidr and prefixlen must not be supplied together') - raise n_exc.BadRequest(resource='subnets', msg=msg) + raise exc.BadRequest(resource='subnets', msg=msg) if has_cidr: # turn the CIDR into a proper subnet @@ -671,7 +672,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, subnetpool_id = self._get_subnetpool_id(context, s) if not subnetpool_id and not has_cidr: msg = _('a subnetpool must be specified in the absence of a cidr') - raise n_exc.BadRequest(resource='subnets', msg=msg) + raise exc.BadRequest(resource='subnets', msg=msg) if subnetpool_id: self.ipam.validate_pools_with_subnetpool(s) @@ -690,7 +691,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, if not has_cidr: msg = _('A cidr must be specified in the absence of a ' 'subnet pool') - raise n_exc.BadRequest(resource='subnets', msg=msg) + raise exc.BadRequest(resource='subnets', msg=msg) self._validate_subnet(context, s) return self._create_subnet(context, subnet, subnetpool_id) @@ -825,7 +826,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, if allocs: LOG.debug("Subnet %s still has internal router ports, " "cannot delete", subnet_id) - raise n_exc.SubnetInUse(subnet_id=id) + raise exc.SubnetInUse(subnet_id=id) def delete_subnet(self, context, id): with context.session.begin(subtransactions=True): @@ -869,7 +870,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, {'ip': alloc.ip_address, 'port_id': alloc.port_id, 'subnet': id}) - raise n_exc.SubnetInUse(subnet_id=id) + raise exc.SubnetInUse(subnet_id=id) context.session.delete(subnet) # Delete related ipam subnet manually, @@ -966,7 +967,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, if self.get_default_subnetpool(context, ip_version): msg = _("A default subnetpool for this IP family has already " "been set. Only one default may exist per IP family") - raise n_exc.InvalidInput(error_message=msg) + raise exc.InvalidInput(error_message=msg) def create_subnetpool(self, context, subnetpool): """Create a subnetpool""" @@ -1180,7 +1181,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, context.session.add(db_port) return db_port except db_exc.DBDuplicateEntry: - raise n_exc.MacAddressInUse(net_id=network_id, mac=mac_address) + raise exc.MacAddressInUse(net_id=network_id, mac=mac_address) def _create_port(self, context, network_id, port_data): max_retries = cfg.CONF.mac_generation_retries @@ -1189,7 +1190,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, try: return self._create_port_with_mac( context, network_id, port_data, mac) - except n_exc.MacAddressInUse: + except exc.MacAddressInUse: LOG.debug('Generated mac %(mac_address)s exists on ' 'network %(network_id)s', {'mac_address': mac, 'network_id': network_id}) @@ -1321,7 +1322,7 @@ class NeutronDbPluginV2(db_base_plugin_common.DbBasePluginCommon, for port_id in port_ids: try: self.delete_port(context, port_id) - except n_exc.PortNotFound: + except exc.PortNotFound: # Don't raise if something else concurrently deleted the port LOG.debug("Ignoring PortNotFound when deleting port '%s'. " "The port has already been deleted.", diff --git a/neutron/db/dns_db.py b/neutron/db/dns_db.py index f62bc98ee9b..66239c1ae6b 100644 --- a/neutron/db/dns_db.py +++ b/neutron/db/dns_db.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_log import log as logging import sqlalchemy as sa @@ -20,7 +21,6 @@ from sqlalchemy import orm from neutron._i18n import _, _LE from neutron.api.v2 import attributes -from neutron.common import exceptions as n_exc from neutron.common import utils from neutron.db import db_base_plugin_v2 from neutron.db import l3_db diff --git a/neutron/db/dvr_mac_db.py b/neutron/db/dvr_mac_db.py index 3087c07efeb..e7ec6161c4a 100644 --- a/neutron/db/dvr_mac_db.py +++ b/neutron/db/dvr_mac_db.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_db import exception as db_exc from oslo_log import helpers as log_helpers @@ -26,7 +27,6 @@ from neutron.callbacks import events from neutron.callbacks import registry from neutron.callbacks import resources from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron.common import utils from neutron.db import model_base from neutron.db import models_v2 diff --git a/neutron/db/external_net_db.py b/neutron/db/external_net_db.py index 2adc9f3f0b8..f9d9fa4bdfe 100644 --- a/neutron/db/external_net_db.py +++ b/neutron/db/external_net_db.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc import sqlalchemy as sa from sqlalchemy import orm from sqlalchemy.orm import exc @@ -26,7 +27,6 @@ from neutron.callbacks import exceptions as c_exc from neutron.callbacks import registry from neutron.callbacks import resources from neutron.common import constants as l3_constants -from neutron.common import exceptions as n_exc from neutron.db import db_base_plugin_v2 from neutron.db import l3_db from neutron.db import model_base diff --git a/neutron/db/ipam_backend_mixin.py b/neutron/db/ipam_backend_mixin.py index c0e60a1459e..f08ceaaa496 100644 --- a/neutron/db/ipam_backend_mixin.py +++ b/neutron/db/ipam_backend_mixin.py @@ -17,6 +17,7 @@ import collections import itertools import netaddr +from neutron_lib import exceptions as exc from oslo_config import cfg from oslo_db import exception as db_exc from oslo_log import log as logging @@ -82,7 +83,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon): if is_any_subnetpool_request and has_allocpool: reason = _("allocation_pools allowed only " "for specific subnet requests.") - raise n_exc.BadRequest(resource='subnets', msg=reason) + raise exc.BadRequest(resource='subnets', msg=reason) def _validate_ip_version_with_subnetpool(self, subnet, subnetpool): """Validates ip version for subnet_pool and requested subnet""" @@ -93,7 +94,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon): 'pool_ver': str(subnetpool.ip_version)} reason = _("Cannot allocate IPv%(req_ver)s subnet from " "IPv%(pool_ver)s subnet pool") % args - raise n_exc.BadRequest(resource='subnets', msg=reason) + raise exc.BadRequest(resource='subnets', msg=reason) def _update_db_port(self, context, db_port, new_port, network_id, new_mac): # Remove all attributes in new_port which are not in the port DB model @@ -103,7 +104,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon): models_v2.Port)) context.session.flush() except db_exc.DBDuplicateEntry: - raise n_exc.MacAddressInUse(net_id=network_id, mac=new_mac) + raise exc.MacAddressInUse(net_id=network_id, mac=new_mac) def _update_subnet_host_routes(self, context, id, s): @@ -212,7 +213,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon): for cidr in new_subnet_ipset.iter_cidrs(): if cidr.prefixlen == 0: err_msg = _("0 is not allowed as CIDR prefix length") - raise n_exc.InvalidInput(error_message=err_msg) + raise exc.InvalidInput(error_message=err_msg) if cfg.CONF.allow_overlapping_ips: subnet_list = network.subnets @@ -233,7 +234,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon): {'new_cidr': new_subnet_cidr, 'subnet_id': subnet.id, 'cidr': subnet.cidr}) - raise n_exc.InvalidInput(error_message=err_msg) + raise exc.InvalidInput(error_message=err_msg) def _validate_network_subnetpools(self, network, new_subnetpool_id, ip_version): @@ -304,7 +305,7 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon): if len(fixed_ip_list) > cfg.CONF.max_fixed_ips_per_port: msg = _('Exceeded maximum amount of fixed ips per port.') - raise n_exc.InvalidInput(error_message=msg) + raise exc.InvalidInput(error_message=msg) def _get_subnet_for_fixed_ip(self, context, fixed, subnets): # Subnets are all the subnets belonging to the same network. @@ -325,23 +326,23 @@ class IpamBackendMixin(db_base_plugin_common.DbBasePluginCommon): "%(subnet_id)s") % {'network_id': subnet['network_id'], 'subnet_id': fixed['subnet_id']}) - raise n_exc.InvalidInput(error_message=msg) + raise exc.InvalidInput(error_message=msg) # Ensure that the IP is valid on the subnet if ('ip_address' in fixed and not ipam_utils.check_subnet_ip(subnet['cidr'], fixed['ip_address'])): - raise n_exc.InvalidIpForSubnet(ip_address=fixed['ip_address']) + raise exc.InvalidIpForSubnet(ip_address=fixed['ip_address']) return subnet if 'ip_address' not in fixed: msg = _('IP allocation requires subnet_id or ip_address') - raise n_exc.InvalidInput(error_message=msg) + raise exc.InvalidInput(error_message=msg) for subnet in subnets: if ipam_utils.check_subnet_ip(subnet['cidr'], fixed['ip_address']): return subnet - raise n_exc.InvalidIpForNetwork(ip_address=fixed['ip_address']) + raise exc.InvalidIpForNetwork(ip_address=fixed['ip_address']) def generate_pools(self, cidr, gateway_ip): return ipam_utils.generate_pools(cidr, gateway_ip) diff --git a/neutron/db/ipam_non_pluggable_backend.py b/neutron/db/ipam_non_pluggable_backend.py index 5377a704695..16939901266 100644 --- a/neutron/db/ipam_non_pluggable_backend.py +++ b/neutron/db/ipam_non_pluggable_backend.py @@ -14,6 +14,7 @@ # under the License. import netaddr +from neutron_lib import exceptions as n_exc from oslo_db import exception as db_exc from oslo_log import log as logging from sqlalchemy import and_ @@ -23,7 +24,6 @@ from sqlalchemy.orm import exc from neutron._i18n import _ from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron.common import ipv6_utils from neutron.db import ipam_backend_mixin from neutron.db import models_v2 diff --git a/neutron/db/ipam_pluggable_backend.py b/neutron/db/ipam_pluggable_backend.py index ef6be0be413..b31188a6138 100644 --- a/neutron/db/ipam_pluggable_backend.py +++ b/neutron/db/ipam_pluggable_backend.py @@ -16,6 +16,7 @@ import copy import netaddr +from neutron_lib import exceptions as n_exc from oslo_db import exception as db_exc from oslo_log import log as logging from oslo_utils import excutils @@ -24,7 +25,6 @@ from sqlalchemy import and_ from neutron._i18n import _, _LE from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron.common import ipv6_utils from neutron.db import ipam_backend_mixin from neutron.db import models_v2 diff --git a/neutron/db/l3_db.py b/neutron/db/l3_db.py index cf0901b55a1..9fc17a0cf8c 100644 --- a/neutron/db/l3_db.py +++ b/neutron/db/l3_db.py @@ -15,6 +15,7 @@ import itertools import netaddr +from neutron_lib import exceptions as n_exc from oslo_log import log as logging from oslo_utils import excutils from oslo_utils import uuidutils @@ -31,7 +32,6 @@ from neutron.callbacks import exceptions from neutron.callbacks import registry from neutron.callbacks import resources from neutron.common import constants as l3_constants -from neutron.common import exceptions as n_exc from neutron.common import ipv6_utils from neutron.common import rpc as n_rpc from neutron.common import utils diff --git a/neutron/db/l3_dvr_db.py b/neutron/db/l3_dvr_db.py index d7b6a52e39d..ce1ec74664c 100644 --- a/neutron/db/l3_dvr_db.py +++ b/neutron/db/l3_dvr_db.py @@ -13,6 +13,7 @@ # under the License. import collections +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_log import helpers as log_helper from oslo_log import log as logging @@ -26,7 +27,6 @@ from neutron.callbacks import exceptions from neutron.callbacks import registry from neutron.callbacks import resources from neutron.common import constants as l3_const -from neutron.common import exceptions as n_exc from neutron.common import utils as n_utils from neutron.db import l3_agentschedulers_db as l3_sched_db from neutron.db import l3_attrs_db diff --git a/neutron/db/l3_hamode_db.py b/neutron/db/l3_hamode_db.py index ab3c1930779..383d9a8f967 100644 --- a/neutron/db/l3_hamode_db.py +++ b/neutron/db/l3_hamode_db.py @@ -16,6 +16,7 @@ import functools import netaddr +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_db import exception as db_exc from oslo_log import helpers as log_helpers @@ -29,7 +30,6 @@ from sqlalchemy import orm from neutron._i18n import _, _LI from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron.common import utils as n_utils from neutron.db import agents_db from neutron.db.availability_zone import router as router_az_db diff --git a/neutron/db/migration/alembic_migrations/versions/mitaka/expand/1df244e556f5_add_unique_ha_router_agent_port_bindings.py b/neutron/db/migration/alembic_migrations/versions/mitaka/expand/1df244e556f5_add_unique_ha_router_agent_port_bindings.py index 9c7c1a2f535..c636fcfa4de 100644 --- a/neutron/db/migration/alembic_migrations/versions/mitaka/expand/1df244e556f5_add_unique_ha_router_agent_port_bindings.py +++ b/neutron/db/migration/alembic_migrations/versions/mitaka/expand/1df244e556f5_add_unique_ha_router_agent_port_bindings.py @@ -26,11 +26,11 @@ revision = '1df244e556f5' down_revision = '659bf3d90664' from alembic import op +from neutron_lib import exceptions import sqlalchemy as sa from neutron._i18n import _ -from neutron.common import exceptions UNIQUE_NAME = 'uniq_ha_router_agent_port_bindings0port_id0l3_agent_id' TABLE_NAME = 'ha_router_agent_port_bindings' diff --git a/neutron/db/quota/driver.py b/neutron/db/quota/driver.py index 6fcf1b78809..fba93406a71 100644 --- a/neutron/db/quota/driver.py +++ b/neutron/db/quota/driver.py @@ -13,10 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions from oslo_db import api as oslo_db_api from oslo_log import log -from neutron.common import exceptions +from neutron.common import exceptions as n_exc from neutron.db import api as db_api from neutron.db import common_db_mixin as common_db from neutron.db.quota import api as quota_api @@ -69,7 +70,7 @@ class DbQuotaDriver(object): tenant_quotas = tenant_quotas.filter_by(tenant_id=tenant_id) if not tenant_quotas.delete(): # No record deleted means the quota was not found - raise exceptions.TenantQuotaNotFound(tenant_id=tenant_id) + raise n_exc.TenantQuotaNotFound(tenant_id=tenant_id) @staticmethod def get_all_quotas(context, resources): @@ -251,7 +252,7 @@ class DbQuotaDriver(object): # Ensure no value is less than zero unders = [key for key, val in values.items() if val < 0] if unders: - raise exceptions.InvalidQuotaValue(unders=sorted(unders)) + raise n_exc.InvalidQuotaValue(unders=sorted(unders)) # Get the applicable quotas quotas = self._get_quotas(context, tenant_id, resources) diff --git a/neutron/db/rbac_db_mixin.py b/neutron/db/rbac_db_mixin.py index f43414544d1..dec526d3bf7 100644 --- a/neutron/db/rbac_db_mixin.py +++ b/neutron/db/rbac_db_mixin.py @@ -13,13 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc from oslo_db import exception as db_exc from sqlalchemy.orm import exc from neutron.callbacks import events from neutron.callbacks import exceptions as c_exc from neutron.callbacks import registry -from neutron.common import exceptions as n_exc from neutron.db import common_db_mixin from neutron.db import rbac_db_models as models from neutron.extensions import rbac as ext_rbac diff --git a/neutron/db/rbac_db_models.py b/neutron/db/rbac_db_models.py index c7f176db299..f4d8a9c45ba 100644 --- a/neutron/db/rbac_db_models.py +++ b/neutron/db/rbac_db_models.py @@ -15,13 +15,13 @@ import abc +from neutron_lib import exceptions as n_exc import sqlalchemy as sa from sqlalchemy.ext import declarative from sqlalchemy.orm import validates from neutron._i18n import _ from neutron.api.v2 import attributes as attr -from neutron.common import exceptions as n_exc from neutron.db import model_base from neutron import manager diff --git a/neutron/db/sqlalchemyutils.py b/neutron/db/sqlalchemyutils.py index 92c5db2eaa5..06c54971317 100644 --- a/neutron/db/sqlalchemyutils.py +++ b/neutron/db/sqlalchemyutils.py @@ -13,12 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc from six import moves import sqlalchemy from sqlalchemy.orm import properties from neutron._i18n import _ -from neutron.common import exceptions as n_exc def paginate_query(query, model, limit, sorts, marker_obj=None): diff --git a/neutron/extensions/address_scope.py b/neutron/extensions/address_scope.py index 5898078f81e..f80cf378f9c 100644 --- a/neutron/extensions/address_scope.py +++ b/neutron/extensions/address_scope.py @@ -14,13 +14,13 @@ import abc +from neutron_lib import exceptions as nexception import six from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import base -from neutron.common import exceptions as nexception from neutron import manager ADDRESS_SCOPE = 'address_scope' diff --git a/neutron/extensions/agent.py b/neutron/extensions/agent.py index a5f1ea4e178..e30a02a07a1 100644 --- a/neutron/extensions/agent.py +++ b/neutron/extensions/agent.py @@ -15,11 +15,12 @@ import abc +from neutron_lib import exceptions + from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import base -from neutron.common import exceptions from neutron import manager diff --git a/neutron/extensions/allowedaddresspairs.py b/neutron/extensions/allowedaddresspairs.py index 371188475e2..0bbe3515fd1 100644 --- a/neutron/extensions/allowedaddresspairs.py +++ b/neutron/extensions/allowedaddresspairs.py @@ -12,13 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as nexception from oslo_config import cfg import webob.exc from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr -from neutron.common import exceptions as nexception allowed_address_pair_opts = [ #TODO(limao): use quota framework when it support quota for attributes diff --git a/neutron/extensions/availability_zone.py b/neutron/extensions/availability_zone.py index ec94dc4a2e8..eec28492168 100644 --- a/neutron/extensions/availability_zone.py +++ b/neutron/extensions/availability_zone.py @@ -14,13 +14,13 @@ import abc +from neutron_lib import exceptions from oslo_serialization import jsonutils from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import base -from neutron.common import exceptions from neutron import manager diff --git a/neutron/extensions/bgp.py b/neutron/extensions/bgp.py index e01469d582b..30c2ffd14da 100644 --- a/neutron/extensions/bgp.py +++ b/neutron/extensions/bgp.py @@ -12,13 +12,13 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. -# + +from neutron_lib import exceptions from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import resource_helper as rh -from neutron.common import exceptions from neutron.services.bgp.common import constants as bgp_consts BGP_EXT_ALIAS = 'bgp' diff --git a/neutron/extensions/bgp_dragentscheduler.py b/neutron/extensions/bgp_dragentscheduler.py index 541e087e73c..4eca18972bb 100644 --- a/neutron/extensions/bgp_dragentscheduler.py +++ b/neutron/extensions/bgp_dragentscheduler.py @@ -17,12 +17,12 @@ import abc import six import webob +from neutron_lib import exceptions from oslo_log import log as logging from neutron.api import extensions from neutron.api.v2 import base from neutron.api.v2 import resource -from neutron.common import exceptions from neutron.extensions import agent from neutron.extensions import bgp as bgp_ext from neutron._i18n import _, _LE diff --git a/neutron/extensions/dhcpagentscheduler.py b/neutron/extensions/dhcpagentscheduler.py index ea636e63b87..727aef7c7b5 100644 --- a/neutron/extensions/dhcpagentscheduler.py +++ b/neutron/extensions/dhcpagentscheduler.py @@ -15,12 +15,13 @@ import abc +from neutron_lib import exceptions + from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import base from neutron.api.v2 import resource from neutron.common import constants -from neutron.common import exceptions from neutron.common import rpc as n_rpc from neutron.extensions import agent from neutron import manager diff --git a/neutron/extensions/dns.py b/neutron/extensions/dns.py index aa55030da39..3455309378f 100644 --- a/neutron/extensions/dns.py +++ b/neutron/extensions/dns.py @@ -15,13 +15,13 @@ import re +from neutron_lib import exceptions as n_exc from oslo_config import cfg import six from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr -from neutron.common import exceptions as n_exc from neutron.extensions import l3 DNS_LABEL_MAX_LEN = 63 diff --git a/neutron/extensions/dvr.py b/neutron/extensions/dvr.py index 28b549b399b..a47a0e1f19c 100644 --- a/neutron/extensions/dvr.py +++ b/neutron/extensions/dvr.py @@ -14,13 +14,13 @@ import abc +from neutron_lib import exceptions import six from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions DISTRIBUTED = 'distributed' EXTENDED_ATTRIBUTES_2_0 = { diff --git a/neutron/extensions/external_net.py b/neutron/extensions/external_net.py index ebaab5d2229..78f4060e1ca 100644 --- a/neutron/extensions/external_net.py +++ b/neutron/extensions/external_net.py @@ -13,10 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as nexception + from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr -from neutron.common import exceptions as nexception class ExternalNetworkInUse(nexception.InUse): diff --git a/neutron/extensions/extra_dhcp_opt.py b/neutron/extensions/extra_dhcp_opt.py index 1ad943d10ab..a70fbb9c0d1 100644 --- a/neutron/extensions/extra_dhcp_opt.py +++ b/neutron/extensions/extra_dhcp_opt.py @@ -13,10 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +from neutron_lib import exceptions + from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr -from neutron.common import exceptions # ExtraDHcpOpts Exceptions diff --git a/neutron/extensions/extraroute.py b/neutron/extensions/extraroute.py index 4c2e96e4f70..903d4e0cfae 100644 --- a/neutron/extensions/extraroute.py +++ b/neutron/extensions/extraroute.py @@ -13,10 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as nexception + from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr -from neutron.common import exceptions as nexception # Extra Routes Exceptions diff --git a/neutron/extensions/flavors.py b/neutron/extensions/flavors.py index a8167b3f938..9ddf87253cc 100644 --- a/neutron/extensions/flavors.py +++ b/neutron/extensions/flavors.py @@ -12,12 +12,13 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as nexception + from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import base from neutron.api.v2 import resource_helper -from neutron.common import exceptions as nexception from neutron import manager from neutron.plugins.common import constants diff --git a/neutron/extensions/l3.py b/neutron/extensions/l3.py index 45182985c14..8bbebe6b4c5 100644 --- a/neutron/extensions/l3.py +++ b/neutron/extensions/l3.py @@ -15,13 +15,13 @@ import abc +from neutron_lib import exceptions as nexception from oslo_config import cfg from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import resource_helper -from neutron.common import exceptions as nexception from neutron.pecan_wsgi import controllers from neutron.plugins.common import constants diff --git a/neutron/extensions/l3_ext_ha_mode.py b/neutron/extensions/l3_ext_ha_mode.py index 2c9969b5c7e..62442ecc1b0 100644 --- a/neutron/extensions/l3_ext_ha_mode.py +++ b/neutron/extensions/l3_ext_ha_mode.py @@ -11,13 +11,14 @@ # 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 from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions + HA_INFO = 'ha' EXTENDED_ATTRIBUTES_2_0 = { diff --git a/neutron/extensions/l3agentscheduler.py b/neutron/extensions/l3agentscheduler.py index b7783044790..d28c134d620 100644 --- a/neutron/extensions/l3agentscheduler.py +++ b/neutron/extensions/l3agentscheduler.py @@ -15,6 +15,7 @@ import abc +from neutron_lib import exceptions from oslo_log import log as logging import webob.exc @@ -23,7 +24,6 @@ from neutron.api import extensions from neutron.api.v2 import base from neutron.api.v2 import resource from neutron.common import constants -from neutron.common import exceptions from neutron.common import rpc as n_rpc from neutron.extensions import agent from neutron import manager diff --git a/neutron/extensions/metering.py b/neutron/extensions/metering.py index 8b9f919ab0f..49d432a377a 100644 --- a/neutron/extensions/metering.py +++ b/neutron/extensions/metering.py @@ -14,13 +14,13 @@ import abc +from neutron_lib import exceptions as nexception import six from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import resource_helper -from neutron.common import exceptions as nexception from neutron.plugins.common import constants from neutron.services import service_base diff --git a/neutron/extensions/multiprovidernet.py b/neutron/extensions/multiprovidernet.py index 565179fd766..1f725478b5a 100644 --- a/neutron/extensions/multiprovidernet.py +++ b/neutron/extensions/multiprovidernet.py @@ -13,12 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as nexception import webob.exc from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr -from neutron.common import exceptions as nexception from neutron.extensions import providernet as pnet SEGMENTS = 'segments' diff --git a/neutron/extensions/portsecurity.py b/neutron/extensions/portsecurity.py index 53c6a1563e8..af15d577864 100644 --- a/neutron/extensions/portsecurity.py +++ b/neutron/extensions/portsecurity.py @@ -12,10 +12,11 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as nexception + from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes -from neutron.common import exceptions as nexception DEFAULT_PORT_SECURITY = True diff --git a/neutron/extensions/providernet.py b/neutron/extensions/providernet.py index cf3bdcea87d..9c3abe81897 100644 --- a/neutron/extensions/providernet.py +++ b/neutron/extensions/providernet.py @@ -13,10 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc + from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes -from neutron.common import exceptions as n_exc NETWORK_TYPE = 'provider:network_type' diff --git a/neutron/extensions/quotasv2.py b/neutron/extensions/quotasv2.py index fb0abb4e90d..8dd1ac79452 100644 --- a/neutron/extensions/quotasv2.py +++ b/neutron/extensions/quotasv2.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_utils import importutils import webob @@ -23,7 +24,7 @@ from neutron.api.v2 import attributes from neutron.api.v2 import base from neutron.api.v2 import resource from neutron.common import constants as const -from neutron.common import exceptions as n_exc +from neutron.common import exceptions from neutron import manager from neutron.pecan_wsgi import controllers from neutron import quota @@ -81,7 +82,7 @@ class QuotaSetsController(wsgi.Controller): """Retrieve the tenant info in context.""" context = request.context if not context.tenant_id: - raise n_exc.QuotaMissingTenant() + raise exceptions.QuotaMissingTenant() return {'tenant': {'tenant_id': context.tenant_id}} def show(self, request, id): diff --git a/neutron/extensions/rbac.py b/neutron/extensions/rbac.py index c74d794af7d..18e78c454e0 100644 --- a/neutron/extensions/rbac.py +++ b/neutron/extensions/rbac.py @@ -12,13 +12,14 @@ # 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 n_exc from oslo_config import cfg from neutron._i18n import _ from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import base -from neutron.common import exceptions as n_exc from neutron.db import rbac_db_models from neutron import manager from neutron.quota import resource_registry diff --git a/neutron/extensions/securitygroup.py b/neutron/extensions/securitygroup.py index 135498c6290..a81416bdbea 100644 --- a/neutron/extensions/securitygroup.py +++ b/neutron/extensions/securitygroup.py @@ -16,6 +16,7 @@ import abc import netaddr +from neutron_lib import exceptions as nexception from oslo_config import cfg from oslo_utils import uuidutils import six @@ -25,7 +26,7 @@ from neutron.api import extensions from neutron.api.v2 import attributes as attr from neutron.api.v2 import base from neutron.common import constants as const -from neutron.common import exceptions as nexception +from neutron.common import exceptions from neutron import manager from neutron.quota import resource_registry @@ -201,7 +202,7 @@ def convert_ip_prefix_to_cidr(ip_prefix): cidr = netaddr.IPNetwork(ip_prefix) return str(cidr) except (ValueError, TypeError, netaddr.AddrFormatError): - raise nexception.InvalidCIDR(input=ip_prefix) + raise exceptions.InvalidCIDR(input=ip_prefix) def _validate_name_not_default(data, valid_values=None): diff --git a/neutron/extensions/tag.py b/neutron/extensions/tag.py index b4f76ecdb78..66e499ba888 100644 --- a/neutron/extensions/tag.py +++ b/neutron/extensions/tag.py @@ -14,6 +14,7 @@ import abc import six +from neutron_lib import exceptions from oslo_log import log as logging import webob.exc @@ -22,7 +23,6 @@ from neutron.api import extensions from neutron.api.v2 import attributes from neutron.api.v2 import base from neutron.api.v2 import resource as api_resource -from neutron.common import exceptions from neutron import manager from neutron.services import service_base diff --git a/neutron/extensions/vlantransparent.py b/neutron/extensions/vlantransparent.py index 57a3cbb009b..92e69722745 100644 --- a/neutron/extensions/vlantransparent.py +++ b/neutron/extensions/vlantransparent.py @@ -12,18 +12,18 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions from oslo_config import cfg from oslo_log import log as logging from neutron._i18n import _, _LI from neutron.api import extensions from neutron.api.v2 import attributes -from neutron.common import exceptions as nexception LOG = logging.getLogger(__name__) -class VlanTransparencyDriverError(nexception.NeutronException): +class VlanTransparencyDriverError(exceptions.NeutronException): """Vlan Transparency not supported by all mechanism drivers.""" message = _("Backend does not support VLAN Transparency.") diff --git a/neutron/ipam/drivers/neutrondb_ipam/driver.py b/neutron/ipam/drivers/neutrondb_ipam/driver.py index 16492f72d94..f275e169704 100644 --- a/neutron/ipam/drivers/neutrondb_ipam/driver.py +++ b/neutron/ipam/drivers/neutrondb_ipam/driver.py @@ -14,12 +14,12 @@ # under the License. import netaddr +from neutron_lib import exceptions as n_exc from oslo_db import exception as db_exc from oslo_log import log from oslo_utils import uuidutils from neutron._i18n import _, _LE -from neutron.common import exceptions as n_exc from neutron.common import ipv6_utils from neutron.db import api as db_api from neutron.ipam import driver as ipam_base diff --git a/neutron/ipam/exceptions.py b/neutron/ipam/exceptions.py index 4a620fd9ae2..dcef12848c8 100644 --- a/neutron/ipam/exceptions.py +++ b/neutron/ipam/exceptions.py @@ -13,8 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions + from neutron._i18n import _ -from neutron.common import exceptions class InvalidSubnetRequestType(exceptions.BadRequest): diff --git a/neutron/ipam/subnet_alloc.py b/neutron/ipam/subnet_alloc.py index 46716b823dc..4d8c8c95176 100644 --- a/neutron/ipam/subnet_alloc.py +++ b/neutron/ipam/subnet_alloc.py @@ -17,6 +17,7 @@ import math import operator import netaddr +from neutron_lib import exceptions as lib_exc from oslo_db import exception as db_exc from oslo_utils import uuidutils @@ -64,7 +65,7 @@ class SubnetAllocator(driver.Pool): id=self._subnetpool['id'], hash=current_hash) count = query.update({'hash': new_hash}) if not count: - raise db_exc.RetryRequest(n_exc.SubnetPoolInUse( + raise db_exc.RetryRequest(lib_exc.SubnetPoolInUse( subnet_pool_id=self._subnetpool['id'])) def _get_allocated_cidrs(self): diff --git a/neutron/objects/rbac_db.py b/neutron/objects/rbac_db.py index c020def1fb5..72aa8ca01ca 100644 --- a/neutron/objects/rbac_db.py +++ b/neutron/objects/rbac_db.py @@ -15,6 +15,7 @@ import abc import itertools +from neutron_lib import exceptions as lib_exc from six import add_metaclass from sqlalchemy import and_ @@ -167,7 +168,7 @@ class RbacNeutronDbObjectMixin(rbac_db_mixin.RbacPluginMixin, db_obj['tenant_id'] != context.tenant_id): msg = _("Only admins can manipulate policies on objects " "they do not own") - raise n_exc.InvalidInput(error_message=msg) + raise lib_exc.InvalidInput(error_message=msg) callback_map = {events.BEFORE_UPDATE: cls.validate_rbac_policy_update, events.BEFORE_DELETE: cls.validate_rbac_policy_delete} if event in callback_map: diff --git a/neutron/pecan_wsgi/app.py b/neutron/pecan_wsgi/app.py index cfaf79daa1b..e5976f285c9 100644 --- a/neutron/pecan_wsgi/app.py +++ b/neutron/pecan_wsgi/app.py @@ -14,13 +14,13 @@ # under the License. from keystonemiddleware import auth_token +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_middleware import cors from oslo_middleware import request_id import pecan from neutron.api import versions -from neutron.common import exceptions as n_exc from neutron.pecan_wsgi import hooks from neutron.pecan_wsgi import startup diff --git a/neutron/pecan_wsgi/controllers/quota.py b/neutron/pecan_wsgi/controllers/quota.py index 56cee526669..0e072434e22 100644 --- a/neutron/pecan_wsgi/controllers/quota.py +++ b/neutron/pecan_wsgi/controllers/quota.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_log import log from oslo_utils import importutils @@ -23,7 +24,6 @@ from pecan import response from neutron._i18n import _ from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron.pecan_wsgi.controllers import utils from neutron.quota import resource_registry diff --git a/neutron/plugins/common/utils.py b/neutron/plugins/common/utils.py index a9efcddffe8..f96f3a0d488 100644 --- a/neutron/plugins/common/utils.py +++ b/neutron/plugins/common/utils.py @@ -18,6 +18,7 @@ Common utilities and helper functions for OpenStack Networking Plugins. import hashlib +from neutron_lib import exceptions from oslo_config import cfg from oslo_log import log as logging from oslo_utils import encodeutils @@ -68,12 +69,12 @@ def verify_tunnel_range(tunnel_range, tunnel_type): if tunnel_type in mappings: for ident in tunnel_range: if not mappings[tunnel_type](ident): - raise n_exc.NetworkTunnelRangeError( + raise exceptions.NetworkTunnelRangeError( tunnel_range=tunnel_range, error=_("%(id)s is not a valid %(type)s identifier") % {'id': ident, 'type': tunnel_type}) if tunnel_range[1] < tunnel_range[0]: - raise n_exc.NetworkTunnelRangeError( + raise exceptions.NetworkTunnelRangeError( tunnel_range=tunnel_range, error=_("End of tunnel range is less " "than start of tunnel range")) diff --git a/neutron/plugins/ml2/common/exceptions.py b/neutron/plugins/ml2/common/exceptions.py index 7f0f7525fab..019b902883b 100644 --- a/neutron/plugins/ml2/common/exceptions.py +++ b/neutron/plugins/ml2/common/exceptions.py @@ -15,8 +15,9 @@ """Exceptions used by ML2.""" +from neutron_lib import exceptions + from neutron._i18n import _ -from neutron.common import exceptions class MechanismDriverError(exceptions.NeutronException): diff --git a/neutron/plugins/ml2/drivers/l2pop/db.py b/neutron/plugins/ml2/drivers/l2pop/db.py index 257b4af59e4..88858db6f34 100644 --- a/neutron/plugins/ml2/drivers/l2pop/db.py +++ b/neutron/plugins/ml2/drivers/l2pop/db.py @@ -13,10 +13,10 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import constants as const from oslo_serialization import jsonutils from oslo_utils import timeutils -from neutron.common import constants as const from neutron.db import agents_db from neutron.db import models_v2 from neutron.plugins.ml2 import models as ml2_models diff --git a/neutron/plugins/ml2/drivers/mech_sriov/agent/common/exceptions.py b/neutron/plugins/ml2/drivers/mech_sriov/agent/common/exceptions.py index 2c960748f46..37b9935b64f 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/agent/common/exceptions.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/agent/common/exceptions.py @@ -13,11 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +from neutron_lib import exceptions + from neutron._i18n import _ -from neutron.common import exceptions as n_exc -class SriovNicError(n_exc.NeutronException): +class SriovNicError(exceptions.NeutronException): pass diff --git a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/exceptions.py b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/exceptions.py index fd6ec90e97a..a47ad3b747f 100644 --- a/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/exceptions.py +++ b/neutron/plugins/ml2/drivers/mech_sriov/mech_driver/exceptions.py @@ -15,8 +15,9 @@ """Exceptions used by SRIOV Mechanism Driver.""" +from neutron_lib import exceptions + from neutron._i18n import _ -from neutron.common import exceptions class SriovUnsupportedNetworkType(exceptions.NeutronException): diff --git a/neutron/plugins/ml2/drivers/type_flat.py b/neutron/plugins/ml2/drivers/type_flat.py index c47d9c76c1d..d39d4e38d48 100644 --- a/neutron/plugins/ml2/drivers/type_flat.py +++ b/neutron/plugins/ml2/drivers/type_flat.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as exc from oslo_config import cfg from oslo_db import exception as db_exc from oslo_log import log @@ -20,7 +21,7 @@ import six import sqlalchemy as sa from neutron._i18n import _, _LI, _LW -from neutron.common import exceptions as exc +from neutron.common import exceptions as n_exc from neutron.db import model_base from neutron.plugins.common import constants as p_const from neutron.plugins.ml2 import driver_api as api @@ -116,7 +117,7 @@ class FlatTypeDriver(helpers.BaseTypeDriver): alloc = FlatAllocation(physical_network=physical_network) alloc.save(session) except db_exc.DBDuplicateEntry: - raise exc.FlatNetworkInUse( + raise n_exc.FlatNetworkInUse( physical_network=physical_network) segment[api.MTU] = self.get_mtu(alloc.physical_network) return segment diff --git a/neutron/plugins/ml2/drivers/type_geneve.py b/neutron/plugins/ml2/drivers/type_geneve.py index 17f44b42d5a..72588b012af 100644 --- a/neutron/plugins/ml2/drivers/type_geneve.py +++ b/neutron/plugins/ml2/drivers/type_geneve.py @@ -13,13 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_log import log import sqlalchemy as sa from sqlalchemy import sql from neutron._i18n import _, _LE -from neutron.common import exceptions as n_exc from neutron.db import model_base from neutron.plugins.common import constants as p_const from neutron.plugins.ml2.drivers import type_tunnel diff --git a/neutron/plugins/ml2/drivers/type_gre.py b/neutron/plugins/ml2/drivers/type_gre.py index bec904b874e..82ade4e9ff2 100644 --- a/neutron/plugins/ml2/drivers/type_gre.py +++ b/neutron/plugins/ml2/drivers/type_gre.py @@ -13,13 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_log import log import sqlalchemy as sa from sqlalchemy import sql from neutron._i18n import _, _LE -from neutron.common import exceptions as n_exc from neutron.db import model_base from neutron.plugins.common import constants as p_const from neutron.plugins.ml2.drivers import type_tunnel diff --git a/neutron/plugins/ml2/drivers/type_local.py b/neutron/plugins/ml2/drivers/type_local.py index 610878e76c0..12f3f9e4883 100644 --- a/neutron/plugins/ml2/drivers/type_local.py +++ b/neutron/plugins/ml2/drivers/type_local.py @@ -13,11 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as exc from oslo_log import log import six from neutron._i18n import _, _LI -from neutron.common import exceptions as exc from neutron.plugins.common import constants as p_const from neutron.plugins.ml2 import driver_api as api diff --git a/neutron/plugins/ml2/drivers/type_tunnel.py b/neutron/plugins/ml2/drivers/type_tunnel.py index 5e9e2df19fc..2f877e13729 100644 --- a/neutron/plugins/ml2/drivers/type_tunnel.py +++ b/neutron/plugins/ml2/drivers/type_tunnel.py @@ -16,6 +16,7 @@ import abc import itertools import operator +from neutron_lib import exceptions as exc from oslo_config import cfg from oslo_db import api as oslo_db_api from oslo_db import exception as db_exc @@ -24,7 +25,6 @@ from six import moves from sqlalchemy import or_ from neutron._i18n import _, _LI, _LW -from neutron.common import exceptions as exc from neutron.common import topics from neutron.db import api as db_api from neutron.plugins.common import utils as plugin_utils diff --git a/neutron/plugins/ml2/drivers/type_vlan.py b/neutron/plugins/ml2/drivers/type_vlan.py index 6d22670f699..6960e0e4a85 100644 --- a/neutron/plugins/ml2/drivers/type_vlan.py +++ b/neutron/plugins/ml2/drivers/type_vlan.py @@ -15,13 +15,13 @@ import sys +from neutron_lib import exceptions as exc from oslo_config import cfg from oslo_log import log from six import moves import sqlalchemy as sa from neutron._i18n import _, _LE, _LI, _LW -from neutron.common import exceptions as exc from neutron.db import api as db_api from neutron.db import model_base from neutron.plugins.common import constants as p_const diff --git a/neutron/plugins/ml2/drivers/type_vxlan.py b/neutron/plugins/ml2/drivers/type_vxlan.py index d258d9d61d6..8a69094cb40 100644 --- a/neutron/plugins/ml2/drivers/type_vxlan.py +++ b/neutron/plugins/ml2/drivers/type_vxlan.py @@ -13,13 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_log import log import sqlalchemy as sa from sqlalchemy import sql from neutron._i18n import _, _LE -from neutron.common import exceptions as n_exc from neutron.db import model_base from neutron.plugins.common import constants as p_const from neutron.plugins.ml2.drivers import type_tunnel diff --git a/neutron/plugins/ml2/managers.py b/neutron/plugins/ml2/managers.py index ecbcf870177..d5a8538d9d6 100644 --- a/neutron/plugins/ml2/managers.py +++ b/neutron/plugins/ml2/managers.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as exc from oslo_config import cfg from oslo_log import log from oslo_utils import excutils @@ -21,7 +22,6 @@ import stevedore from neutron._i18n import _, _LE, _LI, _LW from neutron.api.v2 import attributes -from neutron.common import exceptions as exc from neutron.extensions import external_net from neutron.extensions import multiprovidernet as mpnet from neutron.extensions import portbindings diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index f3c1337efe1..dd36dbab78b 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -14,6 +14,7 @@ # under the License. from eventlet import greenthread +from neutron_lib import exceptions as exc from oslo_concurrency import lockutils from oslo_config import cfg from oslo_db import api as oslo_db_api @@ -41,7 +42,6 @@ from neutron.callbacks import exceptions from neutron.callbacks import registry from neutron.callbacks import resources from neutron.common import constants as const -from neutron.common import exceptions as exc from neutron.common import ipv6_utils from neutron.common import rpc as n_rpc from neutron.common import topics diff --git a/neutron/plugins/ml2/rpc.py b/neutron/plugins/ml2/rpc.py index b963131c8d3..0ed1f968c93 100644 --- a/neutron/plugins/ml2/rpc.py +++ b/neutron/plugins/ml2/rpc.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions from oslo_log import log import oslo_messaging from sqlalchemy.orm import exc @@ -24,7 +25,6 @@ from neutron.callbacks import events from neutron.callbacks import registry from neutron.callbacks import resources from neutron.common import constants as n_const -from neutron.common import exceptions from neutron.common import rpc as n_rpc from neutron.common import topics from neutron.extensions import portbindings diff --git a/neutron/policy.py b/neutron/policy.py index 325177d8adc..f79787f03ec 100644 --- a/neutron/policy.py +++ b/neutron/policy.py @@ -16,6 +16,7 @@ import collections import re +from neutron_lib import exceptions as lib_exc from oslo_config import cfg from oslo_db import exception as db_exc from oslo_log import log as logging @@ -262,7 +263,7 @@ class OwnerCheck(policy.Check): target[parent_foreign_key], fields=[parent_field]) target[self.target_field] = data[parent_field] - except exceptions.NotFound as e: + except lib_exc.NotFound as e: # NOTE(kevinbenton): a NotFound exception can occur if a # list operation is happening at the same time as one of # the parents and its children being deleted. So we issue diff --git a/neutron/quota/__init__.py b/neutron/quota/__init__.py index 5f72c3cb013..b0f263f580c 100644 --- a/neutron/quota/__init__.py +++ b/neutron/quota/__init__.py @@ -16,6 +16,7 @@ import sys +from neutron_lib import exceptions as lib_exc from oslo_config import cfg from oslo_log import log as logging from oslo_log import versionutils @@ -128,8 +129,8 @@ class ConfDriver(object): overs = [key for key, val in values.items() if quotas[key] >= 0 and quotas[key] < val] if overs: - raise exceptions.OverQuota(overs=sorted(overs), quotas=quotas, - usages={}) + raise lib_exc.OverQuota(overs=sorted(overs), quotas=quotas, + usages={}) @staticmethod def get_tenant_quotas(context, resources, tenant_id): diff --git a/neutron/services/auto_allocate/db.py b/neutron/services/auto_allocate/db.py index 4b9a0752790..563cf9862b4 100644 --- a/neutron/services/auto_allocate/db.py +++ b/neutron/services/auto_allocate/db.py @@ -14,17 +14,16 @@ # License for the specific language governing permissions and limitations # under the License. -from sqlalchemy import sql - +from neutron_lib import exceptions as n_exc from oslo_db import exception as db_exc from oslo_log import log as logging +from sqlalchemy import sql from neutron._i18n import _, _LE from neutron.api.v2 import attributes from neutron.callbacks import events from neutron.callbacks import registry from neutron.callbacks import resources -from neutron.common import exceptions as n_exc from neutron.db import common_db_mixin from neutron.db import db_base_plugin_v2 from neutron.db import external_net_db diff --git a/neutron/services/auto_allocate/exceptions.py b/neutron/services/auto_allocate/exceptions.py index 467422d9485..86651bc46b7 100644 --- a/neutron/services/auto_allocate/exceptions.py +++ b/neutron/services/auto_allocate/exceptions.py @@ -14,8 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc + from neutron._i18n import _ -from neutron.common import exceptions as n_exc class AutoAllocationFailure(n_exc.Conflict): diff --git a/neutron/services/bgp/driver/exceptions.py b/neutron/services/bgp/driver/exceptions.py index 36c49a04080..d8e746c2a5d 100644 --- a/neutron/services/bgp/driver/exceptions.py +++ b/neutron/services/bgp/driver/exceptions.py @@ -13,8 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from neutron_lib import exceptions as n_exc + from neutron._i18n import _ -from neutron.common import exceptions as n_exc # BGP Driver Exceptions diff --git a/neutron/services/provider_configuration.py b/neutron/services/provider_configuration.py index 722dddb08aa..9420660d611 100644 --- a/neutron/services/provider_configuration.py +++ b/neutron/services/provider_configuration.py @@ -16,13 +16,13 @@ import importlib import os +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_log import log as logging import stevedore from neutron._i18n import _, _LW from neutron.api.v2 import attributes as attr -from neutron.common import exceptions as n_exc LOG = logging.getLogger(__name__) diff --git a/neutron/services/timestamp/timestamp_db.py b/neutron/services/timestamp/timestamp_db.py index cdc3c18f457..3f28a928eba 100644 --- a/neutron/services/timestamp/timestamp_db.py +++ b/neutron/services/timestamp/timestamp_db.py @@ -15,6 +15,7 @@ import datetime import time +from neutron_lib import exceptions as n_exc from oslo_log import log from oslo_utils import timeutils from sqlalchemy import event @@ -22,7 +23,6 @@ from sqlalchemy import exc as sql_exc from sqlalchemy.orm import session as se from neutron._i18n import _LW -from neutron.common import exceptions as n_exc from neutron.db import model_base LOG = log.getLogger(__name__) diff --git a/neutron/tests/base.py b/neutron/tests/base.py index 31d3065f8f3..8f8bae21338 100644 --- a/neutron/tests/base.py +++ b/neutron/tests/base.py @@ -289,7 +289,7 @@ class BaseTestCase(DietTestCase): self.useFixture(ProcessMonitorFixture()) self.useFixture(fixtures.MonkeyPatch( - 'neutron.common.exceptions.NeutronException.use_fatal_exceptions', + 'neutron_lib.exceptions.NeutronException.use_fatal_exceptions', fake_use_fatal_exceptions)) self.useFixture(fixtures.MonkeyPatch( diff --git a/neutron/tests/functional/db/test_ipam.py b/neutron/tests/functional/db/test_ipam.py index a1dd8468f05..5ea2ea7e9e8 100644 --- a/neutron/tests/functional/db/test_ipam.py +++ b/neutron/tests/functional/db/test_ipam.py @@ -13,13 +13,13 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_db.sqlalchemy import session import testtools from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron import context from neutron.db import db_base_plugin_v2 as base_plugin from neutron.db import model_base diff --git a/neutron/tests/functional/pecan_wsgi/test_functional.py b/neutron/tests/functional/pecan_wsgi/test_functional.py index 71c62513e1f..bf35cec1bb8 100644 --- a/neutron/tests/functional/pecan_wsgi/test_functional.py +++ b/neutron/tests/functional/pecan_wsgi/test_functional.py @@ -16,6 +16,7 @@ import os import mock +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_utils import uuidutils from pecan import set_config @@ -23,7 +24,6 @@ from pecan.testing import load_test_app import testtools from neutron.api import extensions -from neutron.common import exceptions as n_exc from neutron.tests.unit import testlib_api diff --git a/neutron/tests/retargetable/client_fixtures.py b/neutron/tests/retargetable/client_fixtures.py index 4c4e9a2a795..8703f43807a 100644 --- a/neutron/tests/retargetable/client_fixtures.py +++ b/neutron/tests/retargetable/client_fixtures.py @@ -18,9 +18,9 @@ Neutron API via different methods. import abc import fixtures +from neutron_lib import exceptions as n_exc import six -from neutron.common import exceptions as n_exc from neutron import context from neutron import manager from neutron.tests import base diff --git a/neutron/tests/unit/agent/common/test_ovs_lib.py b/neutron/tests/unit/agent/common/test_ovs_lib.py index 3d0c6139c5f..34cd4aca8c5 100644 --- a/neutron/tests/unit/agent/common/test_ovs_lib.py +++ b/neutron/tests/unit/agent/common/test_ovs_lib.py @@ -15,13 +15,13 @@ import collections import mock +from neutron_lib import exceptions from oslo_serialization import jsonutils from oslo_utils import uuidutils import testtools from neutron.agent.common import ovs_lib from neutron.agent.common import utils -from neutron.common import exceptions from neutron.plugins.common import constants from neutron.plugins.ml2.drivers.openvswitch.agent.common \ import constants as p_const diff --git a/neutron/tests/unit/agent/dhcp/test_agent.py b/neutron/tests/unit/agent/dhcp/test_agent.py index 2ece8d1e88d..6a91862b497 100644 --- a/neutron/tests/unit/agent/dhcp/test_agent.py +++ b/neutron/tests/unit/agent/dhcp/test_agent.py @@ -20,6 +20,7 @@ import uuid import eventlet import mock +from neutron_lib import exceptions from oslo_config import cfg import oslo_messaging import testtools @@ -32,7 +33,6 @@ from neutron.agent.linux import dhcp from neutron.agent.linux import interface from neutron.common import config as common_config from neutron.common import constants as const -from neutron.common import exceptions from neutron.common import utils from neutron import context from neutron.tests import base diff --git a/neutron/tests/unit/agent/l2/extensions/test_qos.py b/neutron/tests/unit/agent/l2/extensions/test_qos.py index 16e2f6e248a..5d81a4d10be 100644 --- a/neutron/tests/unit/agent/l2/extensions/test_qos.py +++ b/neutron/tests/unit/agent/l2/extensions/test_qos.py @@ -14,6 +14,7 @@ # under the License. import mock +from neutron_lib import exceptions from oslo_utils import uuidutils from neutron.agent.l2.extensions import qos @@ -21,7 +22,6 @@ from neutron.api.rpc.callbacks.consumer import registry from neutron.api.rpc.callbacks import events from neutron.api.rpc.callbacks import resources from neutron.api.rpc.handlers import resources_rpc -from neutron.common import exceptions from neutron import context from neutron.objects.qos import policy from neutron.objects.qos import rule diff --git a/neutron/tests/unit/agent/l3/test_agent.py b/neutron/tests/unit/agent/l3/test_agent.py index feb25a157c7..9efa0b4142c 100644 --- a/neutron/tests/unit/agent/l3/test_agent.py +++ b/neutron/tests/unit/agent/l3/test_agent.py @@ -20,6 +20,7 @@ from itertools import combinations as iter_combinations import eventlet import mock import netaddr +from neutron_lib import exceptions as exc from oslo_log import log import oslo_messaging from oslo_utils import timeutils @@ -2051,8 +2052,8 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework): agent.router_info = {} self.plugin_api.get_external_network_id.side_effect = ( - n_exc.TooManyExternalNetworks()) - self.assertRaises(n_exc.TooManyExternalNetworks, + exc.TooManyExternalNetworks()) + self.assertRaises(exc.TooManyExternalNetworks, agent._process_router_if_compatible, router) self.assertNotIn(router['id'], agent.router_info) diff --git a/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py b/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py index 1786b732cbc..a9e3de0668f 100644 --- a/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py +++ b/neutron/tests/unit/api/rpc/handlers/test_dhcp_rpc.py @@ -14,11 +14,12 @@ # limitations under the License. import mock +from neutron_lib import exceptions as n_exc from oslo_db import exception as db_exc from neutron.api.rpc.handlers import dhcp_rpc from neutron.common import constants -from neutron.common import exceptions as n_exc +from neutron.common import exceptions from neutron.common import utils from neutron.extensions import portbindings from neutron.tests import base @@ -212,7 +213,7 @@ class TestDhcpRpcCallback(base.BaseTestCase): self.plugin.get_port.return_value = { 'device_id': 'other_id'} - self.assertRaises(n_exc.DhcpPortInUse, + self.assertRaises(exceptions.DhcpPortInUse, self.callbacks.update_dhcp_port, mock.Mock(), host='foo_host', diff --git a/neutron/tests/unit/api/v2/test_attributes.py b/neutron/tests/unit/api/v2/test_attributes.py index 8980114166a..17947527e8c 100644 --- a/neutron/tests/unit/api/v2/test_attributes.py +++ b/neutron/tests/unit/api/v2/test_attributes.py @@ -17,6 +17,7 @@ import string import mock import netaddr +from neutron_lib import exceptions as n_exc from oslo_utils import uuidutils import testtools import webob.exc @@ -24,7 +25,6 @@ import webob.exc from neutron._i18n import _ from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron import context from neutron.tests import base from neutron.tests import tools diff --git a/neutron/tests/unit/api/v2/test_base.py b/neutron/tests/unit/api/v2/test_base.py index bb0fac7400b..0bf54bd4c3c 100644 --- a/neutron/tests/unit/api/v2/test_base.py +++ b/neutron/tests/unit/api/v2/test_base.py @@ -16,6 +16,7 @@ import os import mock +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_db import exception as db_exc from oslo_policy import policy as oslo_policy @@ -33,7 +34,6 @@ from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api from neutron.api.v2 import attributes from neutron.api.v2 import base as v2_base from neutron.api.v2 import router -from neutron.common import exceptions as n_exc from neutron import context from neutron import manager from neutron import policy diff --git a/neutron/tests/unit/api/v2/test_resource.py b/neutron/tests/unit/api/v2/test_resource.py index b900c5bd651..58b5f4bc117 100644 --- a/neutron/tests/unit/api/v2/test_resource.py +++ b/neutron/tests/unit/api/v2/test_resource.py @@ -14,13 +14,13 @@ # under the License. import mock +from neutron_lib import exceptions as n_exc import oslo_i18n from webob import exc import webtest from neutron._i18n import _ from neutron.api.v2 import resource as wsgi_resource -from neutron.common import exceptions as n_exc from neutron import context from neutron.tests import base from neutron import wsgi diff --git a/neutron/tests/unit/common/test_utils.py b/neutron/tests/unit/common/test_utils.py index 6e0024a1f11..9f532787da4 100644 --- a/neutron/tests/unit/common/test_utils.py +++ b/neutron/tests/unit/common/test_utils.py @@ -18,6 +18,7 @@ import re import eventlet import mock import netaddr +from neutron_lib import exceptions as exc from oslo_log import log as logging import six import testtools @@ -103,12 +104,12 @@ class TestParseTunnelRangesMixin(object): def _check_range_invalid_ranges(self, bad_range, which): expected_msg = self._build_invalid_tunnel_range_msg(bad_range, which) - err = self.assertRaises(n_exc.NetworkTunnelRangeError, + err = self.assertRaises(exc.NetworkTunnelRangeError, self._verify_range, bad_range) self.assertEqual(expected_msg, str(err)) def _check_range_reversed(self, bad_range): - err = self.assertRaises(n_exc.NetworkTunnelRangeError, + err = self.assertRaises(exc.NetworkTunnelRangeError, self._verify_range, bad_range) expected_msg = self._build_range_reversed_msg(bad_range) self.assertEqual(expected_msg, str(err)) diff --git a/neutron/tests/unit/db/quota/test_driver.py b/neutron/tests/unit/db/quota/test_driver.py index c505331178a..030f1b19ff8 100644 --- a/neutron/tests/unit/db/quota/test_driver.py +++ b/neutron/tests/unit/db/quota/test_driver.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +from neutron_lib import exceptions as lib_exc + from neutron.common import exceptions from neutron import context from neutron.db import db_base_plugin_v2 as base_plugin @@ -134,7 +136,7 @@ class TestDbQuotaDriver(testlib_api.SqlTestCase): self.plugin.update_quota_limit(self.context, PROJECT, RESOURCE, 2) - self.assertRaises(exceptions.OverQuota, self.plugin.limit_check, + self.assertRaises(lib_exc.OverQuota, self.plugin.limit_check, context.get_admin_context(), PROJECT, resources, values) @@ -206,7 +208,7 @@ class TestDbQuotaDriver(testlib_api.SqlTestCase): fake_count=2)} deltas = {RESOURCE: 1} self.plugin.update_quota_limit(self.context, PROJECT, RESOURCE, 2) - self.assertRaises(exceptions.OverQuota, + self.assertRaises(lib_exc.OverQuota, quota_driver.make_reservation, self.context, self.context.tenant_id, diff --git a/neutron/tests/unit/db/test_agents_db.py b/neutron/tests/unit/db/test_agents_db.py index f6f3cba99d5..fe0ac5febe6 100644 --- a/neutron/tests/unit/db/test_agents_db.py +++ b/neutron/tests/unit/db/test_agents_db.py @@ -18,13 +18,13 @@ import copy import datetime import mock +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_db import exception as exc from oslo_utils import timeutils import testscenarios from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron import context from neutron.db import agents_db from neutron.db import db_base_plugin_v2 as base_plugin diff --git a/neutron/tests/unit/db/test_bgp_db.py b/neutron/tests/unit/db/test_bgp_db.py index 6f4258f5bd5..ff1a76ae622 100644 --- a/neutron/tests/unit/db/test_bgp_db.py +++ b/neutron/tests/unit/db/test_bgp_db.py @@ -14,10 +14,10 @@ import contextlib import netaddr +from neutron_lib import exceptions as n_exc from oslo_utils import uuidutils from neutron.api.v2 import attributes as attrs -from neutron.common import exceptions as n_exc from neutron.extensions import bgp from neutron.extensions import external_net from neutron.extensions import portbindings diff --git a/neutron/tests/unit/db/test_db_base_plugin_v2.py b/neutron/tests/unit/db/test_db_base_plugin_v2.py index 5ba4e689cbf..abf5289d35f 100644 --- a/neutron/tests/unit/db/test_db_base_plugin_v2.py +++ b/neutron/tests/unit/db/test_db_base_plugin_v2.py @@ -19,6 +19,7 @@ import itertools import mock import netaddr +from neutron_lib import exceptions as lib_exc from oslo_config import cfg from oslo_utils import importutils import six @@ -546,7 +547,7 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase): def _fail_second_call(self, patched_plugin, orig, *args, **kwargs): """Invoked by test cases for injecting failures in plugin.""" def second_call(*args, **kwargs): - raise n_exc.NeutronException() + raise lib_exc.NeutronException() patched_plugin.side_effect = second_call return orig(*args, **kwargs) @@ -955,7 +956,7 @@ class TestPortsV2(NeutronDbPluginV2TestCase): fixed_ips=ips, set_context=True) data = self.deserialize(self.fmt, res) - msg = str(n_exc.InvalidIpForNetwork(ip_address='1.1.1.1')) + msg = str(lib_exc.InvalidIpForNetwork(ip_address='1.1.1.1')) self.assertEqual(expected_error, data['NeutronError']['type']) self.assertEqual(msg, data['NeutronError']['message']) @@ -971,7 +972,7 @@ class TestPortsV2(NeutronDbPluginV2TestCase): fixed_ips=ips, set_context=True) data = self.deserialize(self.fmt, res) - msg = str(n_exc.InvalidIpForSubnet(ip_address='1.1.1.1')) + msg = str(lib_exc.InvalidIpForSubnet(ip_address='1.1.1.1')) self.assertEqual(expected_error, data['NeutronError']['type']) self.assertEqual(msg, data['NeutronError']['message']) @@ -1480,7 +1481,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s id = subnet['subnet']['network_id'] res = self._create_port(self.fmt, id) data = self.deserialize(self.fmt, res) - msg = str(n_exc.IpAddressGenerationFailure(net_id=id)) + msg = str(lib_exc.IpAddressGenerationFailure(net_id=id)) self.assertEqual(data['NeutronError']['message'], msg) self.assertEqual(webob.exc.HTTPConflict.code, res.status_int) @@ -1661,7 +1662,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s network = self.deserialize(self.fmt, res) net_id = network['network']['id'] - error = n_exc.MacAddressInUse(net_id=net_id, mac='00:11:22:33:44:55') + error = lib_exc.MacAddressInUse(net_id=net_id, mac='00:11:22:33:44:55') with mock.patch.object( neutron.db.db_base_plugin_v2.NeutronDbPluginV2, '_create_port_with_mac', side_effect=error) as create_mock: @@ -2337,7 +2338,7 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s del_port.side_effect = side_effect network_id = subnet['subnet']['network_id'] - self.assertRaises(n_exc.NeutronException, + self.assertRaises(lib_exc.NeutronException, plugin.delete_ports_by_device_id, ctx, 'owner1', network_id) statuses = { @@ -2357,14 +2358,14 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s with self.subnet() as subnet: with self.port(subnet=subnet, device_id='owner1') as p,\ mock.patch.object(plugin, 'delete_port') as del_port: - del_port.side_effect = n_exc.PortNotFound( + del_port.side_effect = lib_exc.PortNotFound( port_id=p['port']['id'] ) network_id = subnet['subnet']['network_id'] try: plugin.delete_ports_by_device_id(ctx, 'owner1', network_id) - except n_exc.PortNotFound: + except lib_exc.PortNotFound: self.fail("delete_ports_by_device_id unexpectedly raised " "a PortNotFound exception. It should ignore " "this exception because it is often called at " @@ -3225,7 +3226,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): res = req.get_response(self.api) data = self.deserialize(self.fmt, res) self.assertEqual(webob.exc.HTTPConflict.code, res.status_int) - msg = str(n_exc.SubnetInUse(subnet_id=id)) + msg = str(lib_exc.SubnetInUse(subnet_id=id)) self.assertEqual(data['NeutronError']['message'], msg) def test_delete_subnet_with_other_subnet_on_network_still_in_use(self): @@ -3919,7 +3920,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): if expect_success: plugin._validate_subnet(ctx, new_subnet, cur_subnet) else: - self.assertRaises(n_exc.InvalidInput, plugin._validate_subnet, + self.assertRaises(lib_exc.InvalidInput, plugin._validate_subnet, ctx, new_subnet, cur_subnet) def _test_validate_subnet_ipv6_pd_modes(self, cur_subnet=None, @@ -3936,7 +3937,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): if expect_success: plugin._validate_subnet(ctx, new_subnet, cur_subnet) else: - self.assertRaises(n_exc.InvalidInput, plugin._validate_subnet, + self.assertRaises(lib_exc.InvalidInput, plugin._validate_subnet, ctx, new_subnet, cur_subnet) def test_create_subnet_ipv6_ra_modes(self): @@ -4723,7 +4724,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): 'tenant_id': network['network']['tenant_id']} plugin = manager.NeutronManager.get_plugin() if hasattr(plugin, '_validate_subnet'): - self.assertRaises(n_exc.InvalidInput, + self.assertRaises(lib_exc.InvalidInput, plugin._validate_subnet, context.get_admin_context(), subnet) @@ -5017,7 +5018,7 @@ class TestSubnetsV2(NeutronDbPluginV2TestCase): errors = [ exceptions.NotificationError( - 'fake_id', n_exc.NeutronException()), + 'fake_id', lib_exc.NeutronException()), ] notify.side_effect = [ exceptions.CallbackFailure(errors=errors), None diff --git a/neutron/tests/unit/db/test_ipam_non_pluggable_backend.py b/neutron/tests/unit/db/test_ipam_non_pluggable_backend.py index 3678e7978ec..5f08c2a6e38 100644 --- a/neutron/tests/unit/db/test_ipam_non_pluggable_backend.py +++ b/neutron/tests/unit/db/test_ipam_non_pluggable_backend.py @@ -14,11 +14,11 @@ # under the License. import mock +from neutron_lib import exceptions as n_exc from oslo_config import cfg from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron.common import ipv6_utils from neutron.db import db_base_plugin_common from neutron.db import db_base_plugin_v2 diff --git a/neutron/tests/unit/db/test_ipam_pluggable_backend.py b/neutron/tests/unit/db/test_ipam_pluggable_backend.py index ba329d6a1b0..798f01d001d 100644 --- a/neutron/tests/unit/db/test_ipam_pluggable_backend.py +++ b/neutron/tests/unit/db/test_ipam_pluggable_backend.py @@ -15,12 +15,12 @@ import mock import netaddr +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_utils import uuidutils import webob.exc from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron.common import ipv6_utils from neutron.db import ipam_backend_mixin from neutron.db import ipam_pluggable_backend diff --git a/neutron/tests/unit/db/test_l3_db.py b/neutron/tests/unit/db/test_l3_db.py index dc8b3c924f9..d710efc15b8 100644 --- a/neutron/tests/unit/db/test_l3_db.py +++ b/neutron/tests/unit/db/test_l3_db.py @@ -14,12 +14,12 @@ # limitations under the License. import mock +from neutron_lib import exceptions as n_exc import testtools from neutron.callbacks import events from neutron.callbacks import registry from neutron.callbacks import resources -from neutron.common import exceptions as n_exc from neutron.db import l3_db from neutron.extensions import l3 from neutron import manager diff --git a/neutron/tests/unit/db/test_l3_dvr_db.py b/neutron/tests/unit/db/test_l3_dvr_db.py index 38ffb4d9a4d..5e933913729 100644 --- a/neutron/tests/unit/db/test_l3_dvr_db.py +++ b/neutron/tests/unit/db/test_l3_dvr_db.py @@ -14,10 +14,10 @@ # limitations under the License. import mock +from neutron_lib import exceptions from oslo_utils import uuidutils from neutron.common import constants as l3_const -from neutron.common import exceptions from neutron import context from neutron.db import agents_db from neutron.db import common_db_mixin diff --git a/neutron/tests/unit/db/test_l3_hamode_db.py b/neutron/tests/unit/db/test_l3_hamode_db.py index 7fe425c5716..171fda00ad6 100644 --- a/neutron/tests/unit/db/test_l3_hamode_db.py +++ b/neutron/tests/unit/db/test_l3_hamode_db.py @@ -13,6 +13,7 @@ # under the License. import mock +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_db import exception as db_exc from oslo_utils import uuidutils @@ -23,7 +24,6 @@ import testtools from neutron.api.rpc.handlers import l3_rpc from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron import context from neutron.db import agents_db from neutron.db import common_db_mixin diff --git a/neutron/tests/unit/dummy_plugin.py b/neutron/tests/unit/dummy_plugin.py index f050a81a48f..01ec47ecdfd 100644 --- a/neutron/tests/unit/dummy_plugin.py +++ b/neutron/tests/unit/dummy_plugin.py @@ -13,11 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from neutron_lib import exceptions from oslo_utils import uuidutils from neutron.api import extensions from neutron.api.v2 import base -from neutron.common import exceptions from neutron.db import servicetype_db from neutron.extensions import servicetype from neutron import manager diff --git a/neutron/tests/unit/extensions/test_l3.py b/neutron/tests/unit/extensions/test_l3.py index 2a2e8cc0eea..8438fcc96c9 100644 --- a/neutron/tests/unit/extensions/test_l3.py +++ b/neutron/tests/unit/extensions/test_l3.py @@ -19,6 +19,7 @@ import copy import mock import netaddr +from neutron_lib import exceptions as n_exc from oslo_config import cfg from oslo_utils import importutils from oslo_utils import uuidutils @@ -32,7 +33,6 @@ from neutron.callbacks import exceptions from neutron.callbacks import registry from neutron.callbacks import resources from neutron.common import constants as l3_constants -from neutron.common import exceptions as n_exc from neutron import context from neutron.db import common_db_mixin from neutron.db import db_base_plugin_v2 diff --git a/neutron/tests/unit/extensions/test_servicetype.py b/neutron/tests/unit/extensions/test_servicetype.py index 56b89bd6c97..8b11a74bd92 100644 --- a/neutron/tests/unit/extensions/test_servicetype.py +++ b/neutron/tests/unit/extensions/test_servicetype.py @@ -14,12 +14,12 @@ # under the License. import mock +from neutron_lib import exceptions as n_exc from oslo_config import cfg import webob.exc as webexc import webtest from neutron.api import extensions -from neutron.common import exceptions as n_exc from neutron import context from neutron.db import servicetype_db as st_db from neutron.extensions import servicetype diff --git a/neutron/tests/unit/ipam/drivers/neutrondb_ipam/test_driver.py b/neutron/tests/unit/ipam/drivers/neutrondb_ipam/test_driver.py index cf0dc1a1c26..8c0351bfbce 100644 --- a/neutron/tests/unit/ipam/drivers/neutrondb_ipam/test_driver.py +++ b/neutron/tests/unit/ipam/drivers/neutrondb_ipam/test_driver.py @@ -15,10 +15,10 @@ import mock import netaddr +from neutron_lib import exceptions as n_exc from neutron.api.v2 import attributes from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron import context from neutron.db import api as ndb_api from neutron.ipam.drivers.neutrondb_ipam import driver diff --git a/neutron/tests/unit/objects/test_base.py b/neutron/tests/unit/objects/test_base.py index d3ccb2894da..faa1058df59 100644 --- a/neutron/tests/unit/objects/test_base.py +++ b/neutron/tests/unit/objects/test_base.py @@ -15,6 +15,7 @@ import copy import random import mock +from neutron_lib import exceptions as n_exc from oslo_db import exception as obj_exc from oslo_utils import timeutils from oslo_utils import uuidutils @@ -23,7 +24,6 @@ from oslo_versionedobjects import fields as obj_fields from oslo_versionedobjects import fixture from neutron.common import constants -from neutron.common import exceptions as n_exc from neutron.common import utils as common_utils from neutron import context from neutron.db import models_v2 diff --git a/neutron/tests/unit/objects/test_rbac_db.py b/neutron/tests/unit/objects/test_rbac_db.py index 17b502a3f24..bc2ef098f57 100644 --- a/neutron/tests/unit/objects/test_rbac_db.py +++ b/neutron/tests/unit/objects/test_rbac_db.py @@ -12,13 +12,13 @@ import mock +from neutron_lib import exceptions as n_exc from oslo_versionedobjects import base as obj_base from oslo_versionedobjects import fields as obj_fields from six import add_metaclass import sqlalchemy as sa from neutron.callbacks import events -from neutron.common import exceptions as n_exc from neutron.db import model_base from neutron.db import rbac_db_models from neutron.extensions import rbac as ext_rbac diff --git a/neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py b/neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py index d5619fdcf4c..4b1b3164358 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py +++ b/neutron/tests/unit/plugins/ml2/drivers/base_type_tunnel.py @@ -14,11 +14,11 @@ # limitations under the License. import mock +from neutron_lib import exceptions as exc from six import moves import testtools from testtools import matchers -from neutron.common import exceptions as exc from neutron.db import api as db from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import type_tunnel diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py index 302953a5dc2..a51fd6e2f88 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_flat.py @@ -13,7 +13,9 @@ # License for the specific language governing permissions and limitations # under the License. -from neutron.common import exceptions as exc +from neutron_lib import exceptions as exc + +from neutron.common import exceptions as n_exc import neutron.db.api as db from neutron.plugins.common import constants as p_const from neutron.plugins.ml2 import config @@ -113,7 +115,7 @@ class FlatTypeTest(testlib_api.SqlTestCase): segment = {api.NETWORK_TYPE: p_const.TYPE_FLAT, api.PHYSICAL_NETWORK: 'flat_net1'} self.driver.reserve_provider_segment(self.session, segment) - self.assertRaises(exc.FlatNetworkInUse, + self.assertRaises(n_exc.FlatNetworkInUse, self.driver.reserve_provider_segment, self.session, segment) diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_local.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_local.py index 441886ced0f..1f10187b6c3 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_local.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_local.py @@ -13,7 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. -from neutron.common import exceptions as exc +from neutron_lib import exceptions as exc + from neutron.plugins.common import constants as p_const from neutron.plugins.ml2 import driver_api as api from neutron.plugins.ml2.drivers import type_local diff --git a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py index 9735bd95f85..43f563fb5d0 100644 --- a/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py +++ b/neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py @@ -14,9 +14,9 @@ # under the License. import mock +from neutron_lib import exceptions as exc from testtools import matchers -from neutron.common import exceptions as exc import neutron.db.api as db from neutron.plugins.common import constants as p_const from neutron.plugins.common import utils as plugin_utils diff --git a/neutron/tests/unit/plugins/ml2/test_plugin.py b/neutron/tests/unit/plugins/ml2/test_plugin.py index e03f5c14f64..e4216ba1b53 100644 --- a/neutron/tests/unit/plugins/ml2/test_plugin.py +++ b/neutron/tests/unit/plugins/ml2/test_plugin.py @@ -22,6 +22,7 @@ import six import testtools import webob +from neutron_lib import exceptions as exc from oslo_db import exception as db_exc from oslo_utils import uuidutils from sqlalchemy.orm import exc as sqla_exc @@ -31,7 +32,6 @@ from neutron.callbacks import events from neutron.callbacks import registry from neutron.callbacks import resources from neutron.common import constants -from neutron.common import exceptions as exc from neutron.common import utils from neutron import context from neutron.db import agents_db diff --git a/neutron/tests/unit/plugins/ml2/test_rpc.py b/neutron/tests/unit/plugins/ml2/test_rpc.py index 7a54b39af9c..83931f017d5 100644 --- a/neutron/tests/unit/plugins/ml2/test_rpc.py +++ b/neutron/tests/unit/plugins/ml2/test_rpc.py @@ -20,6 +20,7 @@ Unit Tests for ml2 rpc import collections import mock +from neutron_lib import exceptions from oslo_config import cfg from oslo_context import context as oslo_context import oslo_messaging @@ -27,7 +28,6 @@ from sqlalchemy.orm import exc from neutron.agent import rpc as agent_rpc from neutron.common import constants -from neutron.common import exceptions from neutron.common import topics from neutron.plugins.ml2.drivers import type_tunnel from neutron.plugins.ml2 import managers diff --git a/neutron/tests/unit/services/auto_allocate/test_db.py b/neutron/tests/unit/services/auto_allocate/test_db.py index 07d5b3b35ad..561c7071fc8 100644 --- a/neutron/tests/unit/services/auto_allocate/test_db.py +++ b/neutron/tests/unit/services/auto_allocate/test_db.py @@ -12,8 +12,8 @@ # limitations under the License. import mock +from neutron_lib import exceptions as n_exc -from neutron.common import exceptions as n_exc from neutron import context from neutron.services.auto_allocate import db from neutron.services.auto_allocate import exceptions diff --git a/neutron/tests/unit/services/test_provider_configuration.py b/neutron/tests/unit/services/test_provider_configuration.py index 690e36a0b13..bb076fcbef2 100644 --- a/neutron/tests/unit/services/test_provider_configuration.py +++ b/neutron/tests/unit/services/test_provider_configuration.py @@ -13,9 +13,9 @@ # under the License. import mock +from neutron_lib import exceptions as n_exc from oslo_config import cfg -from neutron.common import exceptions as n_exc from neutron import manager from neutron.plugins.common import constants from neutron.services import provider_configuration as provconf diff --git a/neutron/tests/unit/test_policy.py b/neutron/tests/unit/test_policy.py index 88bf6e2d66c..c87084f8b5a 100644 --- a/neutron/tests/unit/test_policy.py +++ b/neutron/tests/unit/test_policy.py @@ -16,6 +16,7 @@ """Test of Policy Engine For Neutron""" import mock +from neutron_lib import exceptions from oslo_db import exception as db_exc from oslo_policy import fixture as op_fixture from oslo_policy import policy as oslo_policy @@ -25,7 +26,7 @@ from oslo_utils import importutils import neutron from neutron.api.v2 import attributes from neutron.common import constants as const -from neutron.common import exceptions +from neutron.common import exceptions as n_exc from neutron import context from neutron import manager from neutron import policy @@ -568,7 +569,7 @@ class NeutronPolicyTestCase(base.BaseTestCase): def test_tenant_id_check_no_target_field_raises(self): # Try and add a bad rule self.assertRaises( - exceptions.PolicyInitError, + n_exc.PolicyInitError, oslo_policy.Rules.from_dict, {'test_policy': 'tenant_id:(wrong_stuff)'}) @@ -578,7 +579,7 @@ class NeutronPolicyTestCase(base.BaseTestCase): action = "create_network" target = {'tenant_id': 'fake'} self.fakepolicyinit() - self.assertRaises(exceptions.PolicyCheckError, + self.assertRaises(n_exc.PolicyCheckError, policy.enforce, self.context, action, target) diff --git a/neutron/tests/unit/test_wsgi.py b/neutron/tests/unit/test_wsgi.py index 7d07aa18b42..a824b729a4f 100644 --- a/neutron/tests/unit/test_wsgi.py +++ b/neutron/tests/unit/test_wsgi.py @@ -18,13 +18,14 @@ import socket import ssl import mock +from neutron_lib import exceptions as exception from oslo_config import cfg import six.moves.urllib.request as urlrequest import testtools import webob import webob.exc -from neutron.common import exceptions as exception +from neutron.common import exceptions as n_exc from neutron.db import api from neutron.tests import base from neutron.tests.common import helpers @@ -576,7 +577,7 @@ class JSONDeserializerTest(base.BaseTestCase): deserializer = wsgi.JSONDeserializer() self.assertRaises( - exception.MalformedRequestBody, deserializer.default, data_string) + n_exc.MalformedRequestBody, deserializer.default, data_string) def test_json_with_utf8(self): data = b'{"a": "\xe7\xbd\x91\xe7\xbb\x9c"}' diff --git a/neutron/wsgi.py b/neutron/wsgi.py index 291d7d70790..684fb69cb87 100644 --- a/neutron/wsgi.py +++ b/neutron/wsgi.py @@ -24,6 +24,7 @@ import sys import time import eventlet.wsgi +from neutron_lib import exceptions as exception from oslo_config import cfg import oslo_i18n from oslo_log import log as logging @@ -40,7 +41,7 @@ import webob.exc from neutron._i18n import _, _LE, _LI from neutron.common import config -from neutron.common import exceptions as exception +from neutron.common import exceptions as n_exc from neutron import context from neutron.db import api from neutron import worker @@ -388,7 +389,7 @@ class JSONDeserializer(TextDeserializer): return jsonutils.loads(datastring) except ValueError: msg = _("Cannot understand JSON") - raise exception.MalformedRequestBody(reason=msg) + raise n_exc.MalformedRequestBody(reason=msg) def default(self, datastring): return {'body': self._from_json(datastring)} @@ -601,7 +602,7 @@ class Resource(Application): msg = _("Unsupported Content-Type") LOG.exception(_LE("InvalidContentType: %s"), msg) return Fault(webob.exc.HTTPBadRequest(explanation=msg)) - except exception.MalformedRequestBody: + except n_exc.MalformedRequestBody: msg = _("Malformed request body") LOG.exception(_LE("MalformedRequestBody: %s"), msg) return Fault(webob.exc.HTTPBadRequest(explanation=msg))