Use exceptions from neutron-lib

Related-Blueprint: neutron-lib

Change-Id: Ia014468bd621c4ee6aea95bf19328c61070174c4
This commit is contained in:
Henry Gessau 2016-04-20 12:36:16 -04:00
parent f2785fc797
commit ae5bad49cc
130 changed files with 265 additions and 215 deletions

View File

@ -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

View File

@ -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

View File

@ -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__)

View File

@ -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

View File

@ -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)

View File

@ -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__)

View File

@ -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']

View File

@ -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

View File

@ -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:"

View File

@ -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',

View File

@ -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__)

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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__)

View File

@ -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)

View File

@ -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

View File

@ -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):

View File

@ -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 = []

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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.",

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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):

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 = {

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 = {

View File

@ -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

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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'

View File

@ -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):

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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.")

View File

@ -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

View File

@ -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):

View File

@ -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):

View File

@ -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:

View File

@ -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

View File

@ -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

View File

@ -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"))

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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__)

View File

@ -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__)

View File

@ -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(

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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',

Some files were not shown because too many files have changed in this diff Show More