import re
from neutron.common import constants
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils
def _validate_boolean(data, valid_values=None):
try:
convert_to_boolean(data)
- except q_exc.InvalidInput:
+ except n_exc.InvalidInput:
msg = _("'%s' is not a valid boolean value") % data
LOG.debug(msg)
return msg
if len(data.split()) > 1:
msg = _("'%s' contains whitespace") % data
LOG.debug(msg)
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
return data
elif data == 1:
return True
msg = _("'%s' cannot be converted to boolean") % data
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
def convert_to_int(data):
return int(data)
except (ValueError, TypeError):
msg = _("'%s' is not a integer") % data
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
def convert_kvp_str_to_list(data):
"""Convert a value of the form 'key=value' to ['key', 'value'].
- :raises: q_exc.InvalidInput if any of the strings are malformed
+ :raises: n_exc.InvalidInput if any of the strings are malformed
(e.g. do not contain a key).
"""
kvp = [x.strip() for x in data.split('=', 1)]
if len(kvp) == 2 and kvp[0]:
return kvp
msg = _("'%s' is not of the form <key>=[value]") % data
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
def convert_kvp_list_to_dict(kvp_list):
"""Convert a list of 'key=value' strings to a dict.
- :raises: q_exc.InvalidInput if any of the strings are malformed
+ :raises: n_exc.InvalidInput if any of the strings are malformed
(e.g. do not contain a key) or if any
of the keys appear more than once.
"""
from neutron.api.v2 import attributes
from neutron.common import constants
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.db import api as db
from neutron.db import models_v2
from neutron.db import sqlalchemyutils
elif ('tenant_id' in resource and
resource['tenant_id'] != context.tenant_id):
reason = _('Cannot create resource for another tenant')
- raise q_exc.AdminRequired(reason=reason)
+ raise n_exc.AdminRequired(reason=reason)
else:
tenant_id = context.tenant_id
return tenant_id
try:
network = self._get_by_id(context, models_v2.Network, id)
except exc.NoResultFound:
- raise q_exc.NetworkNotFound(net_id=id)
+ raise n_exc.NetworkNotFound(net_id=id)
return network
def _get_subnet(self, context, id):
try:
subnet = self._get_by_id(context, models_v2.Subnet, id)
except exc.NoResultFound:
- raise q_exc.SubnetNotFound(subnet_id=id)
+ raise n_exc.SubnetNotFound(subnet_id=id)
return subnet
def _get_port(self, context, id):
try:
port = self._get_by_id(context, models_v2.Port, id)
except exc.NoResultFound:
- raise q_exc.PortNotFound(port_id=id)
+ raise n_exc.PortNotFound(port_id=id)
return port
def _get_dns_by_subnet(self, context, subnet_id):
'max_retries': max_retries - (i + 1)})
LOG.error(_("Unable to generate mac address after %s attempts"),
max_retries)
- raise q_exc.MacAddressGenerationFailure(net_id=network_id)
+ raise n_exc.MacAddressGenerationFailure(net_id=network_id)
@staticmethod
def _check_unique_mac(context, network_id, mac_address):
def _generate_ip(context, subnets):
try:
return NeutronDbPluginV2._try_generate_ip(context, subnets)
- except q_exc.IpAddressGenerationFailure:
+ except n_exc.IpAddressGenerationFailure:
NeutronDbPluginV2._rebuild_availability_ranges(context, subnets)
return NeutronDbPluginV2._try_generate_ip(context, subnets)
# increment the first free
range['first_ip'] = str(netaddr.IPAddress(ip_address) + 1)
return {'ip_address': ip_address, 'subnet_id': subnet['id']}
- raise q_exc.IpAddressGenerationFailure(net_id=subnets[0]['network_id'])
+ raise n_exc.IpAddressGenerationFailure(net_id=subnets[0]['network_id'])
@staticmethod
def _rebuild_availability_ranges(context, subnets):
if 'subnet_id' not in fixed:
if 'ip_address' not in fixed:
msg = _('IP allocation requires subnet_id or ip_address')
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
filter = {'network_id': [network_id]}
subnets = self.get_subnets(context, filters=filter)
if not found:
msg = _('IP address %s is not a valid IP for the defined '
'networks subnets') % fixed['ip_address']
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
subnet = self._get_subnet(context, fixed['subnet_id'])
if subnet['network_id'] != network_id:
"%(subnet_id)s") %
{'network_id': network_id,
'subnet_id': fixed['subnet_id']})
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
subnet_id = subnet['id']
if 'ip_address' in fixed:
if not NeutronDbPluginV2._check_unique_ip(context, network_id,
subnet_id,
fixed['ip_address']):
- raise q_exc.IpAddressInUse(net_id=network_id,
+ raise n_exc.IpAddressInUse(net_id=network_id,
ip_address=fixed['ip_address'])
# Ensure that the IP is valid on the subnet
subnet['cidr'], fixed['ip_address'])):
msg = _('IP address %s is not a valid IP for the defined '
'subnet') % fixed['ip_address']
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
fixed_ip_set.append({'subnet_id': subnet_id,
'ip_address': fixed['ip_address']})
fixed_ip_set.append({'subnet_id': subnet_id})
if len(fixed_ip_set) > cfg.CONF.max_fixed_ips_per_port:
msg = _('Exceeded maximim amount of fixed ips per port')
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
return fixed_ip_set
def _allocate_fixed_ips(self, context, network, fixed_ips):
# the new_ips contain all of the fixed_ips that are to be updated
if len(new_ips) > cfg.CONF.max_fixed_ips_per_port:
msg = _('Exceeded maximim amount of fixed ips per port')
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
# Remove all of the intersecting elements
for original_ip in original_ips[:]:
{'new_cidr': new_subnet_cidr,
'subnet_id': subnet.id,
'cidr': subnet.cidr})
- raise q_exc.InvalidInput(error_message=err_msg)
+ raise n_exc.InvalidInput(error_message=err_msg)
def _validate_allocation_pools(self, ip_pools, subnet_cidr):
"""Validate IP allocation pools.
"%(start)s - %(end)s:"),
{'start': ip_pool['start'],
'end': ip_pool['end']})
- raise q_exc.InvalidAllocationPool(pool=ip_pool)
+ raise n_exc.InvalidAllocationPool(pool=ip_pool)
if (start_ip.version != subnet.version or
end_ip.version != subnet.version):
LOG.info(_("Specified IP addresses do not match "
"the subnet IP version"))
- raise q_exc.InvalidAllocationPool(pool=ip_pool)
+ raise n_exc.InvalidAllocationPool(pool=ip_pool)
if end_ip < start_ip:
LOG.info(_("Start IP (%(start)s) is greater than end IP "
"(%(end)s)"),
{'start': ip_pool['start'], 'end': ip_pool['end']})
- raise q_exc.InvalidAllocationPool(pool=ip_pool)
+ raise n_exc.InvalidAllocationPool(pool=ip_pool)
if start_ip < subnet_first_ip or end_ip > subnet_last_ip:
LOG.info(_("Found pool larger than subnet "
"CIDR:%(start)s - %(end)s"),
{'start': ip_pool['start'],
'end': ip_pool['end']})
- raise q_exc.OutOfBoundsAllocationPool(
+ raise n_exc.OutOfBoundsAllocationPool(
pool=ip_pool,
subnet_cidr=subnet_cidr)
# Valid allocation pool
LOG.info(_("Found overlapping ranges: %(l_range)s and "
"%(r_range)s"),
{'l_range': l_range, 'r_range': r_range})
- raise q_exc.OverlappingAllocationPools(
+ raise n_exc.OverlappingAllocationPools(
pool_1=l_range,
pool_2=r_range,
subnet_cidr=subnet_cidr)
netaddr.IPAddress(route['nexthop'])
except netaddr.core.AddrFormatError:
err_msg = _("Invalid route: %s") % route
- raise q_exc.InvalidInput(error_message=err_msg)
+ raise n_exc.InvalidInput(error_message=err_msg)
except ValueError:
# netaddr.IPAddress would raise this
err_msg = _("Invalid route: %s") % route
- raise q_exc.InvalidInput(error_message=err_msg)
+ raise n_exc.InvalidInput(error_message=err_msg)
self._validate_ip_version(ip_version, route['nexthop'], 'nexthop')
self._validate_ip_version(ip_version, route['destination'],
'destination')
# is not the owner of the network
if (len(tenant_ids) > 1 or len(tenant_ids) == 1 and
tenant_ids.pop() != original.tenant_id):
- raise q_exc.InvalidSharedSetting(network=original.name)
+ raise n_exc.InvalidSharedSetting(network=original.name)
def _make_network_dict(self, network, fields=None,
process_extensions=True):
for p in ports)
if not only_auto_del:
- raise q_exc.NetworkInUse(net_id=id)
+ raise n_exc.NetworkInUse(net_id=id)
# clean up network owned ports
for port in ports:
'ip_version': ip_version}
msg = _("%(name)s '%(addr)s' does not match "
"the ip_version '%(ip_version)s'") % data
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
def _validate_subnet(self, context, s, cur_subnet=None):
"""Validate a subnet spec."""
not NeutronDbPluginV2._check_subnet_ip(s['cidr'],
s['gateway_ip'])):
error_message = _("Gateway is not valid on subnet")
- raise q_exc.InvalidInput(error_message=error_message)
+ raise n_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
ip_address=cur_subnet['gateway_ip'],
subnet_id=cur_subnet['id']).first()
if allocated and allocated['port_id']:
- raise q_exc.GatewayIpInUse(
+ raise n_exc.GatewayIpInUse(
ip_address=cur_subnet['gateway_ip'],
port_id=allocated['port_id'])
if attributes.is_attr_set(s.get('dns_nameservers')):
if len(s['dns_nameservers']) > cfg.CONF.max_dns_nameservers:
- raise q_exc.DNSNameServersExhausted(
+ raise n_exc.DNSNameServersExhausted(
subnet_id=s.get('id', _('new subnet')),
quota=cfg.CONF.max_dns_nameservers)
for dns in s['dns_nameservers']:
try:
netaddr.IPAddress(dns)
except Exception:
- raise q_exc.InvalidInput(
+ raise n_exc.InvalidInput(
error_message=(_("Error parsing dns address %s") %
dns))
self._validate_ip_version(ip_ver, dns, 'dns_nameserver')
if attributes.is_attr_set(s.get('host_routes')):
if len(s['host_routes']) > cfg.CONF.max_subnet_host_routes:
- raise q_exc.HostRoutesExhausted(
+ raise n_exc.HostRoutesExhausted(
subnet_id=s.get('id', _('new subnet')),
quota=cfg.CONF.max_subnet_host_routes)
# check if the routes are all valid
allocation_pool['start'],
allocation_pool['end'])
if netaddr.IPAddress(gateway_ip) in pool_range:
- raise q_exc.GatewayConflictWithAllocationPools(
+ raise n_exc.GatewayConflictWithAllocationPools(
pool=pool_range,
ip_address=gateway_ip)
NeutronDbPluginV2._delete_ip_allocation(
context, subnet.network_id, id, a.ip_address)
else:
- raise q_exc.SubnetInUse(subnet_id=id)
+ raise n_exc.SubnetInUse(subnet_id=id)
context.session.delete(subnet)
if not NeutronDbPluginV2._check_unique_mac(context,
network_id,
mac_address):
- raise q_exc.MacAddressInUse(net_id=network_id,
+ raise n_exc.MacAddressInUse(net_id=network_id,
mac=mac_address)
# Returns the IP's for the port
from neutron.api.v2 import attributes
from neutron.common import constants as l3_constants
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.db import db_base_plugin_v2
from neutron.db import model_base
from neutron.db import models_v2
def get_external_network_id(self, context):
nets = self.get_networks(context, {external_net.EXTERNAL: [True]})
if len(nets) > 1:
- raise q_exc.TooManyExternalNetworks()
+ raise n_exc.TooManyExternalNetworks()
else:
return nets[0]['id'] if nets else None
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
from neutron.api.v2 import attributes
from neutron.common import constants as l3_constants
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.db import model_base
from neutron.db import models_v2
from neutron.extensions import l3
l3_port_check=False)
msg = (_('No IPs available for external network %s') %
network_id)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
with context.session.begin(subtransactions=True):
router.gw_port = self._core_plugin._get_port(context.elevated(),
if not network_db.external:
msg = _("Network %s is not a valid external "
"network") % network_id
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
# figure out if we need to delete existing port
if gw_port and gw_port['network_id'] != network_id:
if ip['subnet_id'] == subnet_id:
msg = (_("Router already has a port on subnet %s")
% subnet_id)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
sub_id = ip['subnet_id']
cidr = self._core_plugin._get_subnet(context.elevated(),
sub_id)['cidr']
msg = (_("Cidr %(subnet_cidr)s of subnet "
"%(subnet_id)s overlaps with cidr %(cidr)s "
"of subnet %(sub_id)s") % data)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
except exc.NoResultFound:
pass
def add_router_interface(self, context, router_id, interface_info):
if not interface_info:
msg = _("Either subnet_id or port_id must be specified")
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
if 'port_id' in interface_info:
# make sure port update is committed
with context.session.begin(subtransactions=True):
if 'subnet_id' in interface_info:
msg = _("Cannot specify both subnet-id and port-id")
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
port = self._core_plugin._get_port(context,
interface_info['port_id'])
if port['device_id']:
- raise q_exc.PortInUse(net_id=port['network_id'],
+ raise n_exc.PortInUse(net_id=port['network_id'],
port_id=port['id'],
device_id=port['device_id'])
fixed_ips = [ip for ip in port['fixed_ips']]
if len(fixed_ips) != 1:
msg = _('Router port must have exactly one fixed IP')
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
subnet_id = fixed_ips[0]['subnet_id']
subnet = self._core_plugin._get_subnet(context, subnet_id)
self._check_for_dup_router_subnet(context, router_id,
# Ensure the subnet has a gateway
if not subnet['gateway_ip']:
msg = _('Subnet for router interface must have a gateway IP')
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
self._check_for_dup_router_subnet(context, router_id,
subnet['network_id'],
subnet_id,
def remove_router_interface(self, context, router_id, interface_info):
if not interface_info:
msg = _("Either subnet_id or port_id must be specified")
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
if 'port_id' in interface_info:
port_id = interface_info['port_id']
port_db = self._core_plugin._get_port(context, port_id)
if 'subnet_id' in interface_info:
port_subnet_id = port_db['fixed_ips'][0]['subnet_id']
if port_subnet_id != interface_info['subnet_id']:
- raise q_exc.SubnetMismatchForPort(
+ raise n_exc.SubnetMismatchForPort(
port_id=port_id,
subnet_id=interface_info['subnet_id'])
subnet_id = port_db['fixed_ips'][0]['subnet_id']
if not subnet_db['gateway_ip']:
msg = (_('Cannot add floating IP to port on subnet %s '
'which has no gateway_ip') % internal_subnet_id)
- raise q_exc.BadRequest(resource='floatingip', msg=msg)
+ raise n_exc.BadRequest(resource='floatingip', msg=msg)
# find router interface ports on this network
router_intf_qry = context.session.query(models_v2.Port)
msg = (_('Cannot create floating IP and bind it to '
'Port %s, since that port is owned by a '
'different tenant.') % port_id)
- raise q_exc.BadRequest(resource='floatingip', msg=msg)
+ raise n_exc.BadRequest(resource='floatingip', msg=msg)
internal_subnet_id = None
if 'fixed_ip_address' in fip and fip['fixed_ip_address']:
msg = (_('Port %(id)s does not have fixed ip %(address)s') %
{'id': internal_port['id'],
'address': internal_ip_address})
- raise q_exc.BadRequest(resource='floatingip', msg=msg)
+ raise n_exc.BadRequest(resource='floatingip', msg=msg)
else:
ips = [ip['ip_address'] for ip in internal_port['fixed_ips']]
if not ips:
msg = (_('Cannot add floating IP to port %s that has'
'no fixed IP addresses') % internal_port['id'])
- raise q_exc.BadRequest(resource='floatingip', msg=msg)
+ raise n_exc.BadRequest(resource='floatingip', msg=msg)
if len(ips) > 1:
msg = (_('Port %s has multiple fixed IPs. Must provide'
' a specific IP when assigning a floating IP') %
internal_port['id'])
- raise q_exc.BadRequest(resource='floatingip', msg=msg)
+ raise n_exc.BadRequest(resource='floatingip', msg=msg)
internal_ip_address = internal_port['fixed_ips'][0]['ip_address']
internal_subnet_id = internal_port['fixed_ips'][0]['subnet_id']
return internal_port, internal_subnet_id, internal_ip_address
if (('fixed_ip_address' in fip and fip['fixed_ip_address']) and
not ('port_id' in fip and fip['port_id'])):
msg = _("fixed_ip_address cannot be specified without a port_id")
- raise q_exc.BadRequest(resource='floatingip', msg=msg)
+ raise n_exc.BadRequest(resource='floatingip', msg=msg)
if 'port_id' in fip and fip['port_id']:
port_id, internal_ip_address, router_id = self.get_assoc_data(
context,
f_net_id = fip['floating_network_id']
if not self._core_plugin._network_is_external(context, f_net_id):
msg = _("Network %s is not a valid external network") % f_net_id
- raise q_exc.BadRequest(resource='floatingip', msg=msg)
+ raise n_exc.BadRequest(resource='floatingip', msg=msg)
with context.session.begin(subtransactions=True):
# This external port is never exposed to the tenant.
'name': ''}})
# Ensure IP addresses are allocated on external port
if not external_port['fixed_ips']:
- raise q_exc.ExternalIpAddressExhausted(net_id=f_net_id)
+ raise n_exc.ExternalIpAddressExhausted(net_id=f_net_id)
floating_fixed_ip = external_port['fixed_ips'][0]
floating_ip_address = floating_fixed_ip['ip_address']
from sqlalchemy.orm import validates
from neutron.api.v2 import attributes
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.db import db_base_plugin_v2 as base_db
from neutron.db import model_base
from neutron.db import models_v2
pool = self._get_resource(context, Pool, v['pool_id'])
# validate that the pool has same tenant
if pool['tenant_id'] != tenant_id:
- raise q_exc.NotAuthorized()
+ raise n_exc.NotAuthorized()
# validate that the pool has same protocol
if pool['protocol'] != v['protocol']:
raise loadbalancer.ProtocolMismatch(
# check that the pool matches the tenant_id
if new_pool['tenant_id'] != vip_db['tenant_id']:
- raise q_exc.NotAuthorized()
+ raise n_exc.NotAuthorized()
# validate that the pool has same protocol
if new_pool['protocol'] != vip_db['protocol']:
raise loadbalancer.ProtocolMismatch(
import sqlalchemy
from sqlalchemy.orm.properties import RelationshipProperty
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.openstack.common import log as logging
# Extension attribute doesn't support for sorting. Because it
# existed in attr_info, it will be catched at here
msg = _("%s is invalid attribute for sort_key") % sort_key
- raise q_exc.BadRequest(resource=model.__tablename__, msg=msg)
+ raise n_exc.BadRequest(resource=model.__tablename__, msg=msg)
if isinstance(sort_key_attr.property, RelationshipProperty):
msg = _("The attribute '%(attr)s' is reference to other "
"resource, can't used by sort "
"'%(resource)s'") % {'attr': sort_key,
'resource': model.__tablename__}
- raise q_exc.BadRequest(resource=model.__tablename__, msg=msg)
+ raise n_exc.BadRequest(resource=model.__tablename__, msg=msg)
query = query.order_by(sort_dir_func(sort_key_attr))
# Add pagination
from neutron.api import extensions
from neutron.api.v2 import attributes
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
NETWORK_TYPE = 'provider:network_type'
immutable = (NETWORK_TYPE, PHYSICAL_NETWORK, SEGMENTATION_ID)
if any(attributes.is_attr_set(attrs.get(a)) for a in immutable):
msg = _("Plugin does not support updating provider attributes")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
class Providernet(extensions.ExtensionDescriptor):
from neutron.api.v2.attributes import convert_to_int
from neutron.api.v2 import base
from neutron.api.v2 import resource
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.manager import NeutronManager
from neutron.openstack.common import importutils
from neutron import quota
"""Retrieve the tenant info in context."""
context = request.context
if not context.tenant_id:
- raise q_exc.QuotaMissingTenant()
+ raise n_exc.QuotaMissingTenant()
return {'tenant': {'tenant_id': context.tenant_id}}
def show(self, request, id):
def _check_admin(self, context,
reason=_("Only admin can view or configure quota")):
if not context.is_admin:
- raise q_exc.AdminRequired(reason=reason)
+ raise n_exc.AdminRequired(reason=reason)
def delete(self, request, id):
self._check_admin(request.context)
from sqlalchemy.orm import exc
from sqlalchemy.sql import and_
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
import neutron.db.api as db
from neutron.db import models_v2
from neutron.openstack.common import log as logging
segment_id, get_multicast_ip(network_profile))
else:
return (physical_network, segment_type, segment_id, "0.0.0.0")
- raise q_exc.NoNetworkAvailable()
+ raise n_exc.NoNetworkAvailable()
def alloc_network(db_session, network_profile_id):
one())
if alloc.allocated:
if vlan_id == c_const.FLAT_VLAN_ID:
- raise q_exc.FlatNetworkInUse(
+ raise n_exc.FlatNetworkInUse(
physical_network=physical_network)
else:
- raise q_exc.VlanIdInUse(vlan_id=vlan_id,
+ raise n_exc.VlanIdInUse(vlan_id=vlan_id,
physical_network=physical_network)
LOG.debug(_("Reserving specific vlan %(vlan)s on physical "
"network %(network)s from pool"),
port = db_session.query(models_v2.Port).filter_by(id=port_id).one()
port.status = status
except exc.NoResultFound:
- raise q_exc.PortNotFound(port_id=port_id)
+ raise n_exc.PortNotFound(port_id=port_id)
def get_vm_network(db_session, policy_profile_id, network_id):
"""Create Network/Policy Profile association with a tenant."""
db_session = db_session or db.get_session()
if profile_type not in ["network", "policy"]:
- raise q_exc.NeutronException(_("Invalid profile type"))
+ raise n_exc.NeutronException(_("Invalid profile type"))
if _profile_binding_exists(db_session,
tenant_id,
"""
if not re.match(r"(\d+)\-(\d+)", network_profile["segment_range"]):
msg = _("Invalid segment range. example range: 500-550")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
def _validate_network_profile(self, net_p):
"""
msg = _("Arguments segment_type missing"
" for network profile")
LOG.exception(msg)
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
segment_type = net_p["segment_type"].lower()
if segment_type not in [c_const.NETWORK_TYPE_VLAN,
c_const.NETWORK_TYPE_OVERLAY,
msg = _("segment_type should either be vlan, overlay, "
"multi-segment or trunk")
LOG.exception(msg)
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if segment_type == c_const.NETWORK_TYPE_VLAN:
if "physical_network" not in net_p:
msg = _("Argument physical_network missing "
"for network profile")
LOG.exception(msg)
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if segment_type in [c_const.NETWORK_TYPE_TRUNK,
c_const.NETWORK_TYPE_OVERLAY]:
if "sub_type" not in net_p:
msg = _("Argument sub_type missing "
"for network profile")
LOG.exception(msg)
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if segment_type in [c_const.NETWORK_TYPE_VLAN,
c_const.NETWORK_TYPE_OVERLAY]:
if "segment_range" not in net_p:
msg = _("Argument segment_range missing "
"for network profile")
LOG.exception(msg)
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
self._validate_segment_range(net_p)
if segment_type == c_const.NETWORK_TYPE_OVERLAY:
if net_p['sub_type'] != c_const.NETWORK_SUBTYPE_NATIVE_VXLAN:
msg = (_("NetworkProfile name %s already exists"),
net_p["name"])
LOG.exception(msg)
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if (c_const.NETWORK_TYPE_MULTI_SEGMENT in
[profile.segment_type, net_p["segment_type"]] or
c_const.NETWORK_TYPE_TRUNK in
(seg_max >= profile_seg_max))):
msg = _("Segment range overlaps with another profile")
LOG.exception(msg)
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
def _get_network_profile_by_name(self, db_session, name):
"""
import httplib2
import netaddr
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.extensions import providernet
from neutron.openstack.common import log as logging
from neutron.plugins.cisco.common import cisco_constants as c_const
network_address = str(ip.network)
except netaddr.AddrFormatError:
msg = _("Invalid input for CIDR")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
netmask = network_address = ""
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
from neutron.api.v2 import attributes
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import rpc as q_rpc
from neutron.common import topics
from neutron.common import utils
if not network_type_set:
msg = _("provider:network_type required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif network_type == c_const.NETWORK_TYPE_VLAN:
if not segmentation_id_set:
msg = _("provider:segmentation_id required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if segmentation_id < 1 or segmentation_id > 4094:
msg = _("provider:segmentation_id out of range "
"(1 through 4094)")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif network_type == c_const.NETWORK_TYPE_OVERLAY:
if physical_network_set:
msg = _("provider:physical_network specified for Overlay "
"network")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
physical_network = None
if not segmentation_id_set:
msg = _("provider:segmentation_id required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if segmentation_id < 5000:
msg = _("provider:segmentation_id out of range "
"(5000+)")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
msg = _("provider:network_type %s not supported"), network_type
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if network_type == c_const.NETWORK_TYPE_VLAN:
if physical_network_set:
if physical_network not in self.network_vlan_ranges:
msg = (_("Unknown provider:physical_network %s") %
physical_network)
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif 'default' in self.network_vlan_ranges:
physical_network = 'default'
else:
msg = _("provider:physical_network required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
return (network_type, physical_network, segmentation_id)
# TBD : Need to handle provider network updates
msg = _("Plugin does not support updating provider attributes")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
def _get_cluster(self, segment1, segment2, clusters):
"""
binding2.network_type not in valid_seg_types or
binding1.network_type == binding2.network_type):
msg = _("Invalid pairing supplied")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
pair_list.append((segment1, segment2))
else:
LOG.debug(_('Invalid UUID supplied in %s'), pair)
msg = _("Invalid UUID supplied")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
return pair_list
def _parse_trunk_segments(self, context, attrs, param, physical_network,
if binding.network_type == c_const.NETWORK_TYPE_TRUNK:
msg = _("Cannot add a trunk segment '%s' as a member of "
"another trunk segment") % segment
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif binding.network_type == c_const.NETWORK_TYPE_VLAN:
if sub_type == c_const.NETWORK_TYPE_OVERLAY:
msg = _("Cannot add vlan segment '%s' as a member of "
"a vxlan trunk segment") % segment
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if not physical_network:
physical_network = binding.physical_network
elif physical_network != binding.physical_network:
msg = _("Network UUID '%s' belongs to a different "
"physical network") % segment
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif binding.network_type == c_const.NETWORK_TYPE_OVERLAY:
if sub_type == c_const.NETWORK_TYPE_VLAN:
msg = _("Cannot add vxlan segment '%s' as a member of "
"a vlan trunk segment") % segment
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
try:
if not utils.is_valid_vlan_tag(int(dot1qtag)):
msg = _("Vlan tag '%s' is out of range") % dot1qtag
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
except ValueError:
msg = _("Vlan tag '%s' is not an integer "
"value") % dot1qtag
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
pair_list.append((segment, dot1qtag))
else:
LOG.debug(_('%s is not a valid uuid'), segment)
msg = _("'%s' is not a valid UUID") % segment
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
return pair_list
def _extend_network_dict_member_segments(self, context, network):
profile_id_set = attributes.is_attr_set(profile_id)
if not profile_id_set:
msg = _("n1kv:profile_id does not exist")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if not self._policy_profile_exists(profile_id):
msg = _("n1kv:profile_id does not exist")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
return profile_id
LOG.debug(_('Seg list %s '), segment_pairs)
else:
if not segmentation_id:
- raise q_exc.TenantNetworksDisabled()
+ raise n_exc.TenantNetworksDisabled()
else:
# provider network
if network_type == c_const.NETWORK_TYPE_VLAN:
if n1kv_db_v2.is_trunk_member(session, id):
msg = _("Cannot delete network '%s' "
"that is member of a trunk segment") % network['name']
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if n1kv_db_v2.is_multi_segment_member(session, id):
msg = _("Cannot delete network '%s' that is a member of a "
"multi-segment network") % network['name']
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if self.agent_vsm:
try:
self._send_delete_network_request(context, network)
Common utilities and helper functions for Openstack Networking Plugins.
"""
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import utils
from neutron.plugins.common import constants
"""Raise an exception for invalid tags or malformed range."""
for vlan_tag in vlan_range:
if not utils.is_valid_vlan_tag(vlan_tag):
- raise q_exc.NetworkVlanRangeError(
+ raise n_exc.NetworkVlanRangeError(
vlan_range=vlan_range,
error=_("%s is not a valid VLAN tag") % vlan_tag)
if vlan_range[1] < vlan_range[0]:
- raise q_exc.NetworkVlanRangeError(
+ raise n_exc.NetworkVlanRangeError(
vlan_range=vlan_range,
error=_("End of VLAN range is less than start of VLAN range"))
network, vlan_min, vlan_max = entry.split(':')
vlan_range = (int(vlan_min), int(vlan_max))
except ValueError as ex:
- raise q_exc.NetworkVlanRangeError(vlan_range=entry, error=ex)
+ raise n_exc.NetworkVlanRangeError(vlan_range=entry, error=ex)
verify_vlan_range(vlan_range)
return network, vlan_range
else:
from oslo.config import cfg
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.openstack.common import log as logging
# Check needed for unit testing on Unix
LOG = logging.getLogger(__name__)
-class HyperVException(q_exc.NeutronException):
+class HyperVException(n_exc.NeutronException):
message = _('HyperVException: %(msg)s')
WMI_JOB_STATE_STARTED = 4096
from sqlalchemy.orm import exc
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
import neutron.db.api as db_api
from neutron.db import models_v2
from neutron.openstack.common import log as logging
'physical_network': alloc.physical_network})
alloc.allocated = True
return (alloc.physical_network, alloc.vlan_id)
- raise q_exc.NoNetworkAvailable()
+ raise n_exc.NoNetworkAvailable()
def reserve_flat_net(self, session):
with session.begin(subtransactions=True):
{'physical_network': alloc.physical_network})
alloc.allocated = True
return alloc.physical_network
- raise q_exc.NoNetworkAvailable()
+ raise n_exc.NoNetworkAvailable()
def reserve_specific_vlan(self, session, physical_network, vlan_id):
with session.begin(subtransactions=True):
alloc = alloc_q.one()
if alloc.allocated:
if vlan_id == constants.FLAT_VLAN_ID:
- raise q_exc.FlatNetworkInUse(
+ raise n_exc.FlatNetworkInUse(
physical_network=physical_network)
else:
- raise q_exc.VlanIdInUse(
+ raise n_exc.VlanIdInUse(
vlan_id=vlan_id,
physical_network=physical_network)
LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
'physical_network': physical_network})
alloc.allocated = True
except exc.NoResultFound:
- raise q_exc.NoNetworkAvailable()
+ raise n_exc.NoNetworkAvailable()
def reserve_specific_flat_net(self, session, physical_network):
return self.reserve_specific_vlan(session, physical_network,
session.merge(port)
session.flush()
except exc.NoResultFound:
- raise q_exc.PortNotFound(port_id=port_id)
+ raise n_exc.PortNotFound(port_id=port_id)
def release_vlan(self, session, physical_network, vlan_id):
with session.begin(subtransactions=True):
from oslo.config import cfg
from neutron.api.v2 import attributes
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import topics
from neutron.db import agents_db
from neutron.db import db_base_plugin_v2
if attributes.is_attr_set(segmentation_id):
msg = _("segmentation_id specified "
"for %s network") % network_type
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
attrs[provider.SEGMENTATION_ID] = None
physical_network = attrs.get(provider.PHYSICAL_NETWORK)
if attributes.is_attr_set(physical_network):
msg = _("physical_network specified "
"for %s network") % network_type
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
attrs[provider.PHYSICAL_NETWORK] = None
def extend_network_dict(self, network, binding):
if attributes.is_attr_set(segmentation_id):
msg = _("segmentation_id specified "
"for %s network") % network_type
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
segmentation_id = constants.FLAT_VLAN_ID
attrs[provider.SEGMENTATION_ID] = segmentation_id
physical_network = attrs.get(provider.PHYSICAL_NETWORK)
if not attributes.is_attr_set(physical_network):
msg = _("physical_network not provided")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
self._db.reserve_specific_vlan(session, physical_network,
segmentation_id)
else:
msg = _(
"Invalid tenant_network_type: %s. "
"Agent terminated!") % tenant_network_type
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
self._tenant_network_type = tenant_network_type
def _setup_rpc(self):
network_type_set = attributes.is_attr_set(network_type)
if not network_type_set:
if self._tenant_network_type == svc_constants.TYPE_NONE:
- raise q_exc.TenantNetworksDisabled()
+ raise n_exc.TenantNetworksDisabled()
network_type = self._tenant_network_type
attrs[provider.NETWORK_TYPE] = network_type
if network_type not in self._network_providers_map:
msg = _("Network type %s not supported") % network_type
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
p = self._network_providers_map[network_type]
# Provider specific network creation
p.create_network(session, attrs)
from oslo.config import cfg
from neutron.common import constants as q_const
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import rpc as q_rpc
from neutron.common import topics
from neutron.db import agents_db
processed_request = {}
if not router['router'].get('admin_state_up', True):
- raise q_exc.NotImplementedError(_('admin_state_up=False '
+ raise n_exc.NotImplementedError(_('admin_state_up=False '
'routers are not '
'supported.'))
from sqlalchemy.orm import exc
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
import neutron.db.api as db
from neutron.db import models_v2
from neutron.db import securitygroups_db as sg_db
with_lockmode('update').
first())
if not state:
- raise q_exc.NoNetworkAvailable()
+ raise n_exc.NoNetworkAvailable()
LOG.debug(_("Reserving vlan %(vlan_id)s on physical network "
"%(physical_network)s from pool"),
{'vlan_id': state.vlan_id,
one())
if state.allocated:
if vlan_id == constants.FLAT_VLAN_ID:
- raise q_exc.FlatNetworkInUse(
+ raise n_exc.FlatNetworkInUse(
physical_network=physical_network)
else:
- raise q_exc.VlanIdInUse(vlan_id=vlan_id,
+ raise n_exc.VlanIdInUse(vlan_id=vlan_id,
physical_network=physical_network)
LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
"network %(physical_network)s from pool"),
session.merge(port)
session.flush()
except exc.NoResultFound:
- raise q_exc.PortNotFound(port_id=port_id)
+ raise n_exc.PortNotFound(port_id=port_id)
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
from neutron.api.v2 import attributes
from neutron.common import constants as q_const
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import rpc as q_rpc
from neutron.common import topics
from neutron.common import utils
if not network_type_set:
msg = _("provider:network_type required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif network_type == svc_constants.TYPE_FLAT:
if segmentation_id_set:
msg = _("provider:segmentation_id specified for flat network")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
segmentation_id = constants.FLAT_VLAN_ID
elif network_type == svc_constants.TYPE_VLAN:
if not segmentation_id_set:
msg = _("provider:segmentation_id required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if not utils.is_valid_vlan_tag(segmentation_id):
msg = (_("provider:segmentation_id out of range "
"(%(min_id)s through %(max_id)s)") %
{'min_id': q_const.MIN_VLAN_TAG,
'max_id': q_const.MAX_VLAN_TAG})
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif network_type == svc_constants.TYPE_LOCAL:
if physical_network_set:
msg = _("provider:physical_network specified for local "
"network")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
physical_network = None
if segmentation_id_set:
msg = _("provider:segmentation_id specified for local "
"network")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
segmentation_id = constants.LOCAL_VLAN_ID
else:
msg = _("provider:network_type %s not supported") % network_type
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if network_type in [svc_constants.TYPE_VLAN, svc_constants.TYPE_FLAT]:
if physical_network_set:
if physical_network not in self.network_vlan_ranges:
msg = (_("Unknown provider:physical_network %s") %
physical_network)
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif 'default' in self.network_vlan_ranges:
physical_network = 'default'
else:
msg = _("provider:physical_network required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
return (network_type, physical_network, segmentation_id)
# tenant network
network_type = self.tenant_network_type
if network_type == svc_constants.TYPE_NONE:
- raise q_exc.TenantNetworksDisabled()
+ raise n_exc.TenantNetworksDisabled()
elif network_type == svc_constants.TYPE_VLAN:
physical_network, vlan_id = db.reserve_network(session)
else: # TYPE_LOCAL
from sqlalchemy.orm import exc
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
import neutron.db.api as db
from neutron.db import models_v2
from neutron.db import securitygroups_db as sg_db
with_lockmode('update').
first())
if not entry:
- raise q_exc.NoNetworkAvailable()
+ raise n_exc.NoNetworkAvailable()
LOG.debug(_("Reserving vlan %(seg_id)s on physical network "
"%(net)s from pool"),
{'seg_id': entry.segmentation_id,
segmentation_id=segmentation_id).
with_lockmode('update').one())
if entry.allocated:
- raise q_exc.VlanIdInUse(vlan_id=segmentation_id,
+ raise n_exc.VlanIdInUse(vlan_id=segmentation_id,
physical_network=physical_network)
LOG.debug(_("Reserving specific vlan %(seg_id)s "
"on physical network %(phy_net)s from pool"),
session.merge(port)
session.flush()
except exc.NoResultFound:
- raise q_exc.PortNotFound(port_id=port_id)
+ raise n_exc.PortNotFound(port_id=port_id)
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
from neutron.api.v2 import attributes
from neutron.common import constants as q_const
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import topics
from neutron.common import utils
from neutron.db import agentschedulers_db
if not network_type_set:
msg = _("provider:network_type required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif network_type == svc_constants.TYPE_FLAT:
self._process_flat_net(segmentation_id_set)
segmentation_id = constants.FLAT_VLAN_ID
else:
msg = _("provider:network_type %s not supported") % network_type
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
physical_network = self._process_net_type(network_type,
physical_network,
physical_network_set)
def _process_flat_net(self, segmentation_id_set):
if segmentation_id_set:
msg = _("provider:segmentation_id specified for flat network")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
def _process_vlan_net(self, segmentation_id, segmentation_id_set):
if not segmentation_id_set:
msg = _("provider:segmentation_id required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if not utils.is_valid_vlan_tag(segmentation_id):
msg = (_("provider:segmentation_id out of range "
"(%(min_id)s through %(max_id)s)") %
{'min_id': q_const.MIN_VLAN_TAG,
'max_id': q_const.MAX_VLAN_TAG})
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
def _process_local_net(self, physical_network_set, segmentation_id_set):
if physical_network_set:
msg = _("provider:physical_network specified for local "
"network")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if segmentation_id_set:
msg = _("provider:segmentation_id specified for local "
"network")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
def _process_net_type(self, network_type,
physical_network,
if physical_network not in self.network_vlan_ranges:
msg = _("Unknown provider:physical_network "
"%s") % physical_network
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif 'default' in self.network_vlan_ranges:
physical_network = 'default'
else:
msg = _("provider:physical_network required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
return physical_network
def _check_port_binding_for_net_type(self, vnic_type, net_type):
msg = _("Invalid vnic_type on port_create")
else:
msg = _("vnic_type is not defined in port profile")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
def create_network(self, context, network):
(network_type, physical_network,
# tenant network
network_type = self.tenant_network_type
if network_type == svc_constants.TYPE_NONE:
- raise q_exc.TenantNetworksDisabled()
+ raise n_exc.TenantNetworksDisabled()
elif network_type == svc_constants.TYPE_VLAN:
physical_network, vlan_id = db.reserve_network(session)
else: # TYPE_LOCAL
from neutron.api.rpc.agentnotifiers import dhcp_rpc_agent_api
from neutron.api.v2 import attributes as attrs
from neutron.common import constants as const
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import rpc as q_rpc
from neutron.common import topics
from neutron.db import agents_db
db_base_plugin_v2.AUTO_DELETE_PORT_OWNERS
for p in ports)
if not only_auto_del:
- raise q_exc.NetworkInUse(net_id=id)
+ raise n_exc.NetworkInUse(net_id=id)
# Make sure auto-delete ports on OFC are deleted.
_error_ports = []
}
msg = attrs._validate_dict_or_empty(profile, key_specs=key_specs)
if msg:
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
datapath_id = profile.get('portinfo:datapath_id')
port_no = profile.get('portinfo:port_no')
def _get_port(self, context, port_id):
try:
return self.plugin.get_port(context, port_id)
- except q_exc.PortNotFound:
+ except n_exc.PortNotFound:
return None
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
from neutron.api.v2 import attributes as attr
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.db import db_base_plugin_v2
from neutron.db import extraroute_db
from neutron.db import l3_agentschedulers_db
if not subnet_db['gateway_ip']:
msg = (_('Cannot add floating IP to port on subnet %s '
'which has no gateway_ip') % internal_subnet_id)
- raise q_exc.BadRequest(resource='floatingip', msg=msg)
+ raise n_exc.BadRequest(resource='floatingip', msg=msg)
# find router interface ports on this network
router_intf_qry = context.session.query(models_v2.Port)
from neutron.api import extensions as neutron_extensions
from neutron.api.v2 import attributes
from neutron.common import constants as os_constants
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.db import api as db
from neutron.db import db_base_plugin_v2
from neutron.db import external_net_db
msg = (_("%(resource)s with id %(resource_id)s does not "
"exist") % {'resource': resource,
'resource_id': user_req[resource]})
- raise q_exc.BadRequest(resource=for_resource, msg=msg)
+ raise n_exc.BadRequest(resource=for_resource, msg=msg)
else:
filter = {'name': [user_req[resource]]}
obj_lister = getattr(self, "get_%ss" % resource)
"or you dont have credential to access it")
% {'resource': resource,
'req_resource': user_req[resource]})
- raise q_exc.BadRequest(resource=for_resource, msg=msg)
+ raise n_exc.BadRequest(resource=for_resource, msg=msg)
if len(found_resource) > 1:
msg = (_("More than one entry found for %(resource)s "
"%(req_resource)s. Use id instead")
% {'resource': resource,
'req_resource': user_req[resource]})
- raise q_exc.BadRequest(resource=for_resource, msg=msg)
+ raise n_exc.BadRequest(resource=for_resource, msg=msg)
found_resource = found_resource[0]
return found_resource
subnet_id)
if not subnet_mapping:
msg = (_("Subnet %s not found on VSD") % subnet_id)
- raise q_exc.BadRequest(resource='port', msg=msg)
+ raise n_exc.BadRequest(resource='port', msg=msg)
port_mapping = nuagedb.get_port_mapping_by_id(session,
id)
if not port_mapping:
msg = (_("Port-Mapping for port %s not "
" found on VSD") % id)
- raise q_exc.BadRequest(resource='port', msg=msg)
+ raise n_exc.BadRequest(resource='port', msg=msg)
if not port_mapping['nuage_vport_id']:
self._create_update_port(context, port,
port_mapping, subnet_mapping)
if not net_partition:
msg = _('Either net_partition is not provided with subnet OR '
'default net_partition is not created at the start')
- raise q_exc.BadRequest(resource='subnet', msg=msg)
+ raise n_exc.BadRequest(resource='subnet', msg=msg)
return net_partition
def _validate_create_subnet(self, subnet):
msg = (_('Unable to complete operation on subnet %s.'
'One or more ports have an IP allocation '
'from this subnet.') % id)
- raise q_exc.BadRequest(resource='subnet', msg=msg)
+ raise n_exc.BadRequest(resource='subnet', msg=msg)
super(NuagePlugin, self).delete_subnet(context, id)
if subnet_l2dom and not self._check_router_subnet_for_tenant(context):
self.nuageclient.delete_user(subnet_l2dom['nuage_user_id'])
msg = (_("Router %s does not hold default zone OR "
"net_partition mapping. Router-IF add failed")
% router_id)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
if not subnet_l2dom:
super(NuagePlugin,
interface_info)
msg = (_("Subnet %s does not hold Nuage VSD reference. "
"Router-IF add failed") % subnet_id)
- raise q_exc.BadRequest(resource='subnet', msg=msg)
+ raise n_exc.BadRequest(resource='subnet', msg=msg)
if (subnet_l2dom['net_partition_id'] !=
ent_rtr_mapping['net_partition_id']):
"different net_partition Router-IF add "
"not permitted") % {'subnet': subnet_id,
'router': router_id})
- raise q_exc.BadRequest(resource='subnet', msg=msg)
+ raise n_exc.BadRequest(resource='subnet', msg=msg)
nuage_subnet_id = subnet_l2dom['nuage_subnet_id']
nuage_l2dom_tmplt_id = subnet_l2dom['nuage_l2dom_tmplt_id']
if self.nuageclient.vms_on_l2domain(nuage_subnet_id):
interface_info)
msg = (_("Subnet %s has one or more active VMs "
"Router-IF add not permitted") % subnet_id)
- raise q_exc.BadRequest(resource='subnet', msg=msg)
+ raise n_exc.BadRequest(resource='subnet', msg=msg)
self.nuageclient.delete_subnet(nuage_subnet_id,
nuage_l2dom_tmplt_id)
net = netaddr.IPNetwork(subn['cidr'])
except exc.NoResultFound:
msg = (_("No router interface found for Router %s. "
"Router-IF delete failed") % router_id)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
if not found:
msg = (_("No router interface found for Router %s. "
"Router-IF delete failed") % router_id)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
elif 'port_id' in interface_info:
port_db = self._get_port(context, interface_info['port_id'])
if not port_db:
msg = (_("No router interface found for Router %s. "
"Router-IF delete failed") % router_id)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
subnet_id = port_db['fixed_ips'][0]['subnet_id']
session = context.session
if self.nuageclient.vms_on_l2domain(nuage_subn_id):
msg = (_("Subnet %s has one or more active VMs "
"Router-IF delete not permitted") % subnet_id)
- raise q_exc.BadRequest(resource='subnet', msg=msg)
+ raise n_exc.BadRequest(resource='subnet', msg=msg)
neutron_subnet = self.get_subnet(context, subnet_id)
ent_rtr_mapping = nuagedb.get_ent_rtr_mapping_by_rtrid(
msg = (_("Router %s does not hold net_partition "
"assoc on Nuage VSD. Router-IF delete failed")
% router_id)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
net = netaddr.IPNetwork(neutron_subnet['cidr'])
net_part_id = ent_rtr_mapping['net_partition_id']
net_partition = self.get_net_partition(context,
if not net_partition:
msg = _("Either net_partition is not provided with router OR "
"default net_partition is not created at the start")
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
return net_partition
def create_router(self, context, router):
if ent_rtr_mapping:
msg = (_("One or more router still attached to "
"net_partition %s.") % id)
- raise q_exc.BadRequest(resource='net_partition', msg=msg)
+ raise n_exc.BadRequest(resource='net_partition', msg=msg)
net_partition = nuagedb.get_net_partition_by_id(context.session, id)
if not net_partition:
msg = (_("NetPartition with %s does not exist") % id)
- raise q_exc.BadRequest(resource='net_partition', msg=msg)
+ raise n_exc.BadRequest(resource='net_partition', msg=msg)
l3dom_tmplt_id = net_partition['l3dom_tmplt_id']
l2dom_tmplt_id = net_partition['l2dom_tmplt_id']
self.nuageclient.delete_net_partition(net_partition['id'],
from sqlalchemy import func
from sqlalchemy.orm import exc
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
import neutron.db.api as db
from neutron.db import models_v2
from neutron.db import securitygroups_db as sg_db
'physical_network': alloc.physical_network})
alloc.allocated = True
return (alloc.physical_network, alloc.vlan_id)
- raise q_exc.NoNetworkAvailable()
+ raise n_exc.NoNetworkAvailable()
def reserve_specific_vlan(session, physical_network, vlan_id):
one())
if alloc.allocated:
if vlan_id == constants.FLAT_VLAN_ID:
- raise q_exc.FlatNetworkInUse(
+ raise n_exc.FlatNetworkInUse(
physical_network=physical_network)
else:
- raise q_exc.VlanIdInUse(vlan_id=vlan_id,
+ raise n_exc.VlanIdInUse(vlan_id=vlan_id,
physical_network=physical_network)
LOG.debug(_("Reserving specific vlan %(vlan_id)s on physical "
"network %(physical_network)s from pool"),
LOG.debug(_("Reserving tunnel %s from pool"), alloc.tunnel_id)
alloc.allocated = True
return alloc.tunnel_id
- raise q_exc.NoNetworkAvailable()
+ raise n_exc.NoNetworkAvailable()
def reserve_specific_tunnel(session, tunnel_id):
with_lockmode('update').
one())
if alloc.allocated:
- raise q_exc.TunnelIdInUse(tunnel_id=tunnel_id)
+ raise n_exc.TunnelIdInUse(tunnel_id=tunnel_id)
LOG.debug(_("Reserving specific tunnel %s from pool"), tunnel_id)
alloc.allocated = True
except exc.NoResultFound:
session.merge(port)
session.flush()
except exc.NoResultFound:
- raise q_exc.PortNotFound(port_id=port_id)
+ raise n_exc.PortNotFound(port_id=port_id)
def get_tunnel_endpoints():
'transaction had been committed (%s attempts left)'),
max_retries - (i + 1))
- raise q_exc.NeutronException(
+ raise n_exc.NeutronException(
message=_('Unable to generate a new tunnel id'))
from neutron.api.rpc.agentnotifiers import l3_rpc_agent_api
from neutron.api.v2 import attributes
from neutron.common import constants as q_const
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import rpc as q_rpc
from neutron.common import topics
from neutron.common import utils
if not network_type_set:
msg = _("provider:network_type required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif network_type == svc_constants.TYPE_FLAT:
if segmentation_id_set:
msg = _("provider:segmentation_id specified for flat network")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
segmentation_id = constants.FLAT_VLAN_ID
elif network_type == svc_constants.TYPE_VLAN:
if not segmentation_id_set:
msg = _("provider:segmentation_id required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if not utils.is_valid_vlan_tag(segmentation_id):
msg = (_("provider:segmentation_id out of range "
"(%(min_id)s through %(max_id)s)") %
{'min_id': q_const.MIN_VLAN_TAG,
'max_id': q_const.MAX_VLAN_TAG})
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif network_type in constants.TUNNEL_NETWORK_TYPES:
if not self.enable_tunneling:
msg = _("%s networks are not enabled") % network_type
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if physical_network_set:
msg = _("provider:physical_network specified for %s "
"network") % network_type
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
physical_network = None
if not segmentation_id_set:
msg = _("provider:segmentation_id required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif network_type == svc_constants.TYPE_LOCAL:
if physical_network_set:
msg = _("provider:physical_network specified for local "
"network")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
physical_network = None
if segmentation_id_set:
msg = _("provider:segmentation_id specified for local "
"network")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
else:
segmentation_id = None
else:
msg = _("provider:network_type %s not supported") % network_type
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
if network_type in [svc_constants.TYPE_VLAN, svc_constants.TYPE_FLAT]:
if physical_network_set:
if physical_network not in self.network_vlan_ranges:
msg = _("Unknown provider:physical_network "
"%s") % physical_network
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
elif 'default' in self.network_vlan_ranges:
physical_network = 'default'
else:
msg = _("provider:physical_network required")
- raise q_exc.InvalidInput(error_message=msg)
+ raise n_exc.InvalidInput(error_message=msg)
return (network_type, physical_network, segmentation_id)
# tenant network
network_type = self.tenant_network_type
if network_type == svc_constants.TYPE_NONE:
- raise q_exc.TenantNetworksDisabled()
+ raise n_exc.TenantNetworksDisabled()
elif network_type == svc_constants.TYPE_VLAN:
(physical_network,
segmentation_id) = ovs_db_v2.reserve_vlan(session)
from neutron.agent import rpc as agent_rpc
from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.common import config as logging_config
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import topics
from neutron import context as q_context
from neutron.extensions import securitygroup as ext_sg
rest_api_addr = self.plugin_rpc.get_ofp_rest_api_addr(self.context)
if not rest_api_addr:
- raise q_exc.Invalid(_("Ryu rest API port isn't specified"))
+ raise n_exc.Invalid(_("Ryu rest API port isn't specified"))
LOG.debug(_("Going to ofp controller mode %s"), rest_api_addr)
ryu_rest_client = client.OFPClient(rest_api_addr)
from sqlalchemy import func
from sqlalchemy.orm import exc as orm_exc
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
import neutron.db.api as db
from neutron.db import models_v2
from neutron.db import securitygroups_db as sg_db
# if this happens too often, increase _TRANSACTION_RETRY_MAX
LOG.warn(_("Transaction retry exhausted (%d). "
"Abandoned tunnel key allocation."), count)
- raise q_exc.ResourceExhausted()
+ raise n_exc.ResourceExhausted()
return new_key
session.merge(port)
session.flush()
except orm_exc.NoResultFound:
- raise q_exc.PortNotFound(port_id=port_id)
+ raise n_exc.PortNotFound(port_id=port_id)
from neutron.agent import securitygroups_rpc as sg_rpc
from neutron.common import constants as q_const
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import rpc as q_rpc
from neutron.common import topics
from neutron.db import api as db
cfg.CONF.OVS.tunnel_key_min, cfg.CONF.OVS.tunnel_key_max)
self.ofp_api_host = cfg.CONF.OVS.openflow_rest_api
if not self.ofp_api_host:
- raise q_exc.Invalid(_('Invalid configuration. check ryu.ini'))
+ raise n_exc.Invalid(_('Invalid configuration. check ryu.ini'))
self.client = client.OFPClient(self.ofp_api_host)
self.tun_client = client.TunnelClient(self.ofp_api_host)
from neutron.api.v2 import attributes as attr
from neutron.api.v2 import base
from neutron.common import constants
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import utils
from neutron import context as q_context
from neutron.db import agentschedulers_db
LOG.debug(_("_nsx_create_port completed for port %(name)s "
"on network %(network_id)s. The new port id is "
"%(id)s."), port_data)
- except (api_exc.NsxApiException, q_exc.NeutronException):
+ except (api_exc.NsxApiException, n_exc.NeutronException):
self._handle_create_port_exception(
context, port_data['id'],
selected_lswitch and selected_lswitch['uuid'],
switchlib.delete_port(self.cluster,
selected_lswitch['uuid'],
lport['uuid'])
- except q_exc.NotFound:
+ except n_exc.NotFound:
LOG.debug(_("NSX Port %s already gone"), lport['uuid'])
def _nsx_delete_port(self, context, port_data):
"on network %(net_id)s"),
{'port_id': port_data['id'],
'net_id': port_data['network_id']})
- except q_exc.NotFound:
+ except n_exc.NotFound:
LOG.warning(_("Port %s not found in NSX"), port_data['id'])
def _nsx_delete_router_port(self, context, port_data):
"%(name)s on network %(network_id)s. The new "
"port id is %(id)s."),
port_data)
- except (api_exc.NsxApiException, q_exc.NeutronException):
+ except (api_exc.NsxApiException, n_exc.NeutronException):
self._handle_create_port_exception(
context, port_data['id'],
selected_lswitch and selected_lswitch['uuid'],
def _find_router_gw_port(self, context, port_data):
router_id = port_data['device_id']
if not router_id:
- raise q_exc.BadRequest(_("device_id field must be populated in "
+ raise n_exc.BadRequest(_("device_id field must be populated in "
"order to create an external gateway "
"port for network %s"),
port_data['network_id'])
bindings = nsx_db.get_network_bindings_by_vlanid(
context.session, segmentation_id)
if bindings:
- raise q_exc.VlanIdInUse(
+ raise n_exc.VlanIdInUse(
vlan_id=segmentation_id,
physical_network=physical_network)
elif network_type == NetworkTypes.L3_EXT:
{'net_type_param': pnet.NETWORK_TYPE,
'net_type_value': network_type})
if err_msg:
- raise q_exc.InvalidInput(error_message=err_msg)
+ raise n_exc.InvalidInput(error_message=err_msg)
# TODO(salvatore-orlando): Validate tranport zone uuid
# which should be specified in physical_network
switchlib.delete_networks(self.cluster, id, lswitch_ids)
LOG.debug(_("delete_network completed for tenant: %s"),
context.tenant_id)
- except q_exc.NotFound:
+ except n_exc.NotFound:
LOG.warning(_("Did not found lswitch %s in NSX"), id)
self.handle_network_dhcp_access(context, id, action='delete_network')
port_data['device_owner'],
self._port_drivers['create']['default'])
port_create_func(context, port_data)
- except q_exc.NotFound:
+ except n_exc.NotFound:
LOG.warning(_("Logical switch for network %s was not "
"found in NSX."), port_data['network_id'])
# Put port in error on quantum DB
"platform currently in execution. Please, try "
"without specifying the 'distributed' attribute.")
LOG.exception(msg)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
except api_exc.NsxApiException:
err_msg = _("Unable to create logical router on NSX Platform")
LOG.exception(err_msg)
if not ext_net.external:
msg = (_("Network '%s' is not a valid external "
"network") % network_id)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
if ext_net.subnets:
ext_subnet = ext_net.subnets[0]
nexthop = ext_subnet.gateway_ip
# Set external gateway and remove router in case of failure
try:
self._update_router_gw_info(context, router_db['id'], gw_info)
- except (q_exc.NeutronException, api_exc.NsxApiException):
+ except (n_exc.NeutronException, api_exc.NsxApiException):
with excutils.save_and_reraise_exception():
# As setting gateway failed, the router must be deleted
# in order to ensure atomicity
if not ext_net.external:
msg = (_("Network '%s' is not a valid external "
"network") % network_id)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
if ext_net.subnets:
ext_subnet = ext_net.subnets[0]
nexthop = ext_subnet.gateway_ip
msg = _("'routes' cannot contain route '0.0.0.0/0', "
"this must be updated through the default "
"gateway attribute")
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
previous_routes = self._update_lrouter(
context, router_id, r.get('name'),
nexthop, routes=r.get('routes'))
# NOTE(salv-orlando): The exception handling below is not correct, but
# unfortunately nsxlib raises a neutron notfound exception when an
# object is not found in the underlying backend
- except q_exc.NotFound:
+ except n_exc.NotFound:
# Put the router in ERROR status
with context.session.begin(subtransactions=True):
router_db = self._get_router(context, router_id)
"platform currently in execution. Please, try "
"without specifying the static routes.")
LOG.exception(msg)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
try:
return super(NsxPluginV2, self).update_router(context,
router_id, router)
# from the backend
try:
self._delete_lrouter(context, router_id, nsx_router_id)
- except q_exc.NotFound:
+ except n_exc.NotFound:
# This is not a fatal error, but needs to be logged
LOG.warning(_("Logical router '%s' not found "
"on NSX Platform"), router_id)
if (('fixed_ip_address' in fip and fip['fixed_ip_address']) and
not ('port_id' in fip and fip['port_id'])):
msg = _("fixed_ip_address cannot be specified without a port_id")
- raise q_exc.BadRequest(resource='floatingip', msg=msg)
+ raise n_exc.BadRequest(resource='floatingip', msg=msg)
port_id = internal_ip = router_id = None
if 'port_id' in fip and fip['port_id']:
fip_qry = context.session.query(l3_db.FloatingIP)
except sa_exc.NoResultFound:
LOG.debug(_("The port '%s' is not associated with floating IPs"),
port_id)
- except q_exc.NotFound:
+ except n_exc.NotFound:
LOG.warning(_("Nat rules not found in nsx for port: %s"), id)
super(NsxPluginV2, self).disassociate_floatingips(context, port_id)
try:
secgrouplib.delete_security_profile(
self.cluster, nsx_sec_profile_id)
- except q_exc.NotFound:
+ except n_exc.NotFound:
# The security profile was not found on the backend
# do not fail in this case.
LOG.warning(_("The NSX security profile %(sec_profile_id)s, "
r['port_range_max'] is not None)):
msg = (_("Port values not valid for "
"protocol: %s") % r['protocol'])
- raise q_exc.BadRequest(resource='security_group_rule',
+ raise n_exc.BadRequest(resource='security_group_rule',
msg=msg)
return super(NsxPluginV2, self)._validate_security_group_rules(context,
rules)
import netaddr
from oslo.config import cfg
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.db.firewall import firewall_db
from neutron.db import l3_db
from neutron.db.loadbalancer import loadbalancer_db
if not ext_net.external:
msg = (_("Network '%s' is not a valid external "
"network") % network_id)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
if ext_net.subnets:
ext_subnet = ext_net.subnets[0]
netmask = str(netaddr.IPNetwork(ext_subnet.cidr).netmask)
msg = (_("An exception occurred while creating a port "
"on lswitch %s") % lswitch['uuid'])
LOG.exception(msg)
- raise q_exc.NeutronException(message=msg)
+ raise n_exc.NeutronException(message=msg)
# create logic router port
try:
LOG.exception(msg)
switchlib.delete_port(
self.cluster, lswitch['uuid'], ls_port['uuid'])
- raise q_exc.NeutronException(message=msg)
+ raise n_exc.NeutronException(message=msg)
# attach logic router port to switch port
try:
"for router %s") % name
LOG.exception(msg)
routerlib.delete_lrouter(self.cluster, lrouter['uuid'])
- raise q_exc.NeutronException(message=msg)
+ raise n_exc.NeutronException(message=msg)
try:
self._add_router_integration_interface(tenant_id, name,
"for router %s") % name
LOG.exception(msg)
routerlib.delete_lrouter(self.cluster, lrouter['uuid'])
- raise q_exc.NeutronException(message=msg)
+ raise n_exc.NeutronException(message=msg)
try:
self._create_advanced_service_router(
LOG.exception(msg)
self.vcns_driver.delete_lswitch(lswitch('uuid'))
routerlib.delete_lrouter(self.cluster, lrouter['uuid'])
- raise q_exc.NeutronException(message=msg)
+ raise n_exc.NeutronException(message=msg)
lrouter['status'] = service_constants.PENDING_CREATE
return lrouter
nsx_status = RouterStatus.ROUTER_STATUS_ACTIVE
else:
nsx_status = RouterStatus.ROUTER_STATUS_DOWN
- except q_exc.NotFound:
+ except n_exc.NotFound:
nsx_status = RouterStatus.ROUTER_STATUS_ERROR
return nsx_status
if not router_id:
msg = _("router_id is not provided!")
LOG.error(msg)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
if not self._is_advanced_service_router(context, router_id):
msg = _("router_id:%s is not an advanced router!") % router_id
LOG.error(msg)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
if self._get_resource_router_id_binding(
context, firewall_db.Firewall, router_id=router_id):
msg = _("A firewall is already associated with the router")
if not router_id:
msg = _("router_id is not provided!")
LOG.error(msg)
- raise q_exc.BadRequest(resource='router', msg=msg)
+ raise n_exc.BadRequest(resource='router', msg=msg)
if not self._is_advanced_service_router(context, router_id):
msg = _("router_id: %s is not an advanced router!") % router_id
from oslo.config import cfg
from neutron.common import constants as q_const
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import rpc as q_rpc
from neutron.common import topics
from neutron.db import agents_db
cfg.CONF.register_opts(AGENT_SCHEDULER_OPTS)
-class DriverNotSpecified(q_exc.NeutronException):
+class DriverNotSpecified(n_exc.NeutronException):
message = _("Device driver for agent should be specified "
"in plugin driver.")
pool = qry.one()
if pool.status != constants.ACTIVE:
- raise q_exc.Invalid(_('Expected active pool'))
+ raise n_exc.Invalid(_('Expected active pool'))
retval = {}
retval['pool'] = self.plugin._make_pool_dict(pool)
'health_monitor': loadbalancer_db.PoolMonitorAssociation
}
if obj_type not in model_mapping:
- raise q_exc.Invalid(_('Unknown object type: %s') % obj_type)
+ raise n_exc.Invalid(_('Unknown object type: %s') % obj_type)
try:
if obj_type == 'health_monitor':
self.plugin.update_pool_health_monitor(
else:
self.plugin.update_status(
context, model_mapping[obj_type], obj_id, status)
- except q_exc.NotFound:
+ except n_exc.NotFound:
# update_status may come from agent on an object which was
# already deleted from db with other request
LOG.warning(_('Cannot update status: %(obj_type)s %(obj_id)s '
context,
port_id
)
- except q_exc.PortNotFound:
+ except n_exc.PortNotFound:
msg = _('Unable to find port %s to plug.')
LOG.debug(msg, port_id)
return
context,
port_id
)
- except q_exc.PortNotFound:
+ except n_exc.PortNotFound:
msg = _('Unable to find port %s to unplug. This can occur when '
'the Vip has been deleted first.')
LOG.debug(msg, port_id)
{'port': port}
)
- except q_exc.PortNotFound:
+ except n_exc.PortNotFound:
msg = _('Unable to find port %s to unplug. This can occur when '
'the Vip has been deleted first.')
LOG.debug(msg, port_id)
from sqlalchemy.orm import exc as s_exc
from testtools import matchers
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron import context
from neutron.db import api as db
from neutron.db import db_base_plugin_v2
self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
vlan_ids.add(vlan_id)
- self.assertRaises(q_exc.NoNetworkAvailable,
+ self.assertRaises(n_exc.NoNetworkAvailable,
n1kv_db_v2.reserve_vlan,
self.session,
p)
PHYS_NET,
vlan_id).allocated)
- self.assertRaises(q_exc.VlanIdInUse,
+ self.assertRaises(n_exc.VlanIdInUse,
n1kv_db_v2.reserve_specific_vlan,
self.session,
PHYS_NET,
self.assertTrue(n1kv_db_v2.get_vlan_allocation(self.session, PHYS_NET,
vlan_id).allocated)
- self.assertRaises(q_exc.VlanIdInUse,
+ self.assertRaises(n_exc.VlanIdInUse,
n1kv_db_v2.reserve_specific_vlan,
self.session,
PHYS_NET,
self.assertThat(vxlan_id, matchers.LessThan(VXLAN_MAX + 1))
vxlan_ids.add(vxlan_id)
- self.assertRaises(q_exc.NoNetworkAvailable,
+ self.assertRaises(n_exc.NoNetworkAvailable,
n1kv_db_v2.reserve_vxlan,
self.session,
profile)
TEST_NETWORK_PROFILE_2['name'] = 'net-profile-min-overlap'
TEST_NETWORK_PROFILE_2['segment_range'] = SEGMENT_RANGE_MIN_OVERLAP
test_net_profile = {'network_profile': TEST_NETWORK_PROFILE_2}
- self.assertRaises(q_exc.InvalidInput,
+ self.assertRaises(n_exc.InvalidInput,
self.create_network_profile,
ctx,
test_net_profile)
TEST_NETWORK_PROFILE_2['name'] = 'net-profile-max-overlap'
TEST_NETWORK_PROFILE_2['segment_range'] = SEGMENT_RANGE_MAX_OVERLAP
test_net_profile = {'network_profile': TEST_NETWORK_PROFILE_2}
- self.assertRaises(q_exc.InvalidInput,
+ self.assertRaises(n_exc.InvalidInput,
self.create_network_profile,
ctx,
test_net_profile)
TEST_NETWORK_PROFILE_2['name'] = 'net-profile-overlap'
TEST_NETWORK_PROFILE_2['segment_range'] = SEGMENT_RANGE_OVERLAP
test_net_profile = {'network_profile': TEST_NETWORK_PROFILE_2}
- self.assertRaises(q_exc.InvalidInput,
+ self.assertRaises(n_exc.InvalidInput,
self.create_network_profile,
ctx,
test_net_profile)
from neutron.api import extensions
from neutron.api.v2 import attributes
from neutron.api.v2 import base
-from neutron.common import exceptions as q_exc
+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 l3_db
# Inject an exception in the OVS plugin delete_port
# processing, and attempt a port deletion.
- inserted_exc = q_exc.Conflict
+ inserted_exc = n_exc.Conflict
expected_http = base.FAULT_MAP[inserted_exc].code
with mock.patch.object(l3_db.L3_NAT_db_mixin,
'disassociate_floatingips',
import testtools
from testtools import matchers
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.db import api as db
from neutron.plugins.linuxbridge.db import l2network_db_v2 as lb_db
from neutron.tests import base
self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
vlan_ids.add(vlan_id)
- with testtools.ExpectedException(q_exc.NoNetworkAvailable):
+ with testtools.ExpectedException(n_exc.NoNetworkAvailable):
physical_network, vlan_id = lb_db.reserve_network(self.session)
for vlan_id in vlan_ids:
self.assertTrue(lb_db.get_network_state(PHYS_NET,
vlan_id).allocated)
- with testtools.ExpectedException(q_exc.VlanIdInUse):
+ with testtools.ExpectedException(n_exc.VlanIdInUse):
lb_db.reserve_specific_network(self.session, PHYS_NET, vlan_id)
lb_db.release_network(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
self.assertTrue(lb_db.get_network_state(PHYS_NET,
vlan_id).allocated)
- with testtools.ExpectedException(q_exc.VlanIdInUse):
+ with testtools.ExpectedException(n_exc.VlanIdInUse):
lb_db.reserve_specific_network(self.session, PHYS_NET, vlan_id)
lb_db.release_network(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
from testtools import matchers
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.db import api as db
from neutron.plugins.mlnx.db import mlnx_db_v2 as mlnx_db
from neutron.tests import base
self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
vlan_ids.add(vlan_id)
- self.assertRaises(q_exc.NoNetworkAvailable,
+ self.assertRaises(n_exc.NoNetworkAvailable,
mlnx_db.reserve_network,
self.session)
for vlan_id in vlan_ids:
self.assertTrue(mlnx_db.get_network_state(PHYS_NET,
vlan_id).allocated)
- self.assertRaises(q_exc.VlanIdInUse,
+ self.assertRaises(n_exc.VlanIdInUse,
mlnx_db.reserve_specific_network,
self.session,
PHYS_NET,
self.assertTrue(mlnx_db.get_network_state(PHYS_NET,
vlan_id).allocated)
- self.assertRaises(q_exc.VlanIdInUse,
+ self.assertRaises(n_exc.VlanIdInUse,
mlnx_db.reserve_specific_network,
self.session,
PHYS_NET,
from testtools import matchers
from webob import exc
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron import context
from neutron.extensions import portbindings
from neutron.tests.unit import _test_extension_portbindings as test_bindings
self.assertEqual(portinfo['port_no'], 123)
def _test_validate_exception(self, profile, expected_msg):
- e = self.assertRaises(q_exc.InvalidInput,
+ e = self.assertRaises(n_exc.InvalidInput,
self.plugin._validate_portinfo, profile)
self.assertThat(str(e), matchers.StartsWith(expected_msg))
import testtools
from testtools import matchers
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.db import api as db
from neutron.openstack.common.db import exception as db_exc
from neutron.openstack.common.db.sqlalchemy import session
self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
vlan_ids.add(vlan_id)
- with testtools.ExpectedException(q_exc.NoNetworkAvailable):
+ with testtools.ExpectedException(n_exc.NoNetworkAvailable):
physical_network, vlan_id = ovs_db_v2.reserve_vlan(self.session)
ovs_db_v2.release_vlan(self.session, PHYS_NET, vlan_ids.pop(),
self.assertTrue(ovs_db_v2.get_vlan_allocation(PHYS_NET,
vlan_id).allocated)
- with testtools.ExpectedException(q_exc.VlanIdInUse):
+ with testtools.ExpectedException(n_exc.VlanIdInUse):
ovs_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id)
ovs_db_v2.release_vlan(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
self.assertTrue(ovs_db_v2.get_vlan_allocation(PHYS_NET,
vlan_id).allocated)
- with testtools.ExpectedException(q_exc.VlanIdInUse):
+ with testtools.ExpectedException(n_exc.VlanIdInUse):
ovs_db_v2.reserve_specific_vlan(self.session, PHYS_NET, vlan_id)
ovs_db_v2.release_vlan(self.session, PHYS_NET, vlan_id, VLAN_RANGES)
self.assertThat(tunnel_id, matchers.LessThan(TUN_MAX + 1))
tunnel_ids.add(tunnel_id)
- with testtools.ExpectedException(q_exc.NoNetworkAvailable):
+ with testtools.ExpectedException(n_exc.NoNetworkAvailable):
tunnel_id = ovs_db_v2.reserve_tunnel(self.session)
ovs_db_v2.release_tunnel(self.session, tunnel_ids.pop(), TUNNEL_RANGES)
ovs_db_v2.reserve_specific_tunnel(self.session, tunnel_id)
self.assertTrue(ovs_db_v2.get_tunnel_allocation(tunnel_id).allocated)
- with testtools.ExpectedException(q_exc.TunnelIdInUse):
+ with testtools.ExpectedException(n_exc.TunnelIdInUse):
ovs_db_v2.reserve_specific_tunnel(self.session, tunnel_id)
ovs_db_v2.release_tunnel(self.session, tunnel_id, TUNNEL_RANGES)
ovs_db_v2.reserve_specific_tunnel(self.session, tunnel_id)
self.assertTrue(ovs_db_v2.get_tunnel_allocation(tunnel_id).allocated)
- with testtools.ExpectedException(q_exc.TunnelIdInUse):
+ with testtools.ExpectedException(n_exc.TunnelIdInUse):
ovs_db_v2.reserve_specific_tunnel(self.session, tunnel_id)
ovs_db_v2.release_tunnel(self.session, tunnel_id, TUNNEL_RANGES)
error = db_exc.DBDuplicateEntry(['id'])
query_mock.side_effect = error
- with testtools.ExpectedException(q_exc.NeutronException):
+ with testtools.ExpectedException(n_exc.NeutronException):
ovs_db_v2.add_tunnel_endpoint('10.0.0.1', 5)
self.assertEqual(query_mock.call_count, 5)
])
def test_invalid_rest_addr(self):
- self.assertRaises(self.mod_agent.q_exc.Invalid,
+ self.assertRaises(self.mod_agent.n_exc.Invalid,
self.mock_rest_addr, (''))
def mock_port_update(self, **kwargs):
from neutron.api.v2 import base as v2_base
from neutron.api.v2 import router
from neutron.common import config
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron import context
from neutron.manager import NeutronManager
from neutron.openstack.common.notifier import api as notifer_api
def test_native_pagination_without_native_sorting(self):
instance = self.plugin.return_value
instance._NeutronPluginBaseV2__native_sorting_support = False
- self.assertRaises(q_exc.Invalid, router.APIRouter)
+ self.assertRaises(n_exc.Invalid, router.APIRouter)
def test_native_pagination_without_allow_sorting(self):
cfg.CONF.set_override('allow_sorting', False)
import webtest
from neutron.api.v2 import resource as wsgi_resource
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron import context
from neutron.openstack.common import gettextutils
from neutron.tests import base
def test_unmapped_neutron_error_with_json(self):
msg = u'\u7f51\u7edc'
- class TestException(q_exc.NeutronException):
+ class TestException(n_exc.NeutronException):
message = msg
expected_res = {'body': {
'NeutronError': {
def test_unmapped_neutron_error_with_xml(self):
msg = u'\u7f51\u7edc'
- class TestException(q_exc.NeutronException):
+ class TestException(n_exc.NeutronException):
message = msg
expected_res = {'body': {
'NeutronError': {
mock_translation.return_value = msg_translation
msg = _('Unmapped error')
- class TestException(q_exc.NeutronException):
+ class TestException(n_exc.NeutronException):
message = msg
controller = mock.MagicMock()
def test_mapped_neutron_error_with_json(self):
msg = u'\u7f51\u7edc'
- class TestException(q_exc.NeutronException):
+ class TestException(n_exc.NeutronException):
message = msg
expected_res = {'body': {
'NeutronError': {
def test_mapped_neutron_error_with_xml(self):
msg = u'\u7f51\u7edc'
- class TestException(q_exc.NeutronException):
+ class TestException(n_exc.NeutronException):
message = msg
expected_res = {'body': {
'NeutronError': {
mock_translation.return_value = msg_translation
msg = _('Unmapped error')
- class TestException(q_exc.NeutronException):
+ class TestException(n_exc.NeutronException):
message = msg
controller = mock.MagicMock()
def _test_error_log_level(self, map_webob_exc, expect_log_info=False,
use_fault_map=True):
- class TestException(q_exc.NeutronException):
+ class TestException(n_exc.NeutronException):
message = 'Test Exception'
controller = mock.MagicMock()
import testtools
from neutron.api.v2 import attributes
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.tests import base
result = attributes._validate_no_whitespace(data)
self.assertEqual(result, data)
- self.assertRaises(q_exc.InvalidInput,
+ self.assertRaises(n_exc.InvalidInput,
attributes._validate_no_whitespace,
'i have whitespace')
- self.assertRaises(q_exc.InvalidInput,
+ self.assertRaises(n_exc.InvalidInput,
attributes._validate_no_whitespace,
'i\thave\twhitespace')
def test_convert_to_boolean_int(self):
self.assertIs(attributes.convert_to_boolean(0), False)
self.assertIs(attributes.convert_to_boolean(1), True)
- self.assertRaises(q_exc.InvalidInput,
+ self.assertRaises(n_exc.InvalidInput,
attributes.convert_to_boolean,
7)
self.assertIs(attributes.convert_to_boolean('false'), False)
self.assertIs(attributes.convert_to_boolean('0'), False)
self.assertIs(attributes.convert_to_boolean('1'), True)
- self.assertRaises(q_exc.InvalidInput,
+ self.assertRaises(n_exc.InvalidInput,
attributes.convert_to_boolean,
'7')
def test_convert_to_int_str(self):
self.assertEqual(attributes.convert_to_int('4'), 4)
self.assertEqual(attributes.convert_to_int('6'), 6)
- self.assertRaises(q_exc.InvalidInput,
+ self.assertRaises(n_exc.InvalidInput,
attributes.convert_to_int,
'garbage')
def test_convert_to_int_none(self):
- self.assertRaises(q_exc.InvalidInput,
+ self.assertRaises(n_exc.InvalidInput,
attributes.convert_to_int,
None)
self.assertEqual({'a': ['b'], 'c': ['d']}, result)
def test_convert_kvp_str_to_list_fails_for_missing_key(self):
- with testtools.ExpectedException(q_exc.InvalidInput):
+ with testtools.ExpectedException(n_exc.InvalidInput):
attributes.convert_kvp_str_to_list('=a')
def test_convert_kvp_str_to_list_fails_for_missing_equals(self):
- with testtools.ExpectedException(q_exc.InvalidInput):
+ with testtools.ExpectedException(n_exc.InvalidInput):
attributes.convert_kvp_str_to_list('a')
def test_convert_kvp_str_to_list_succeeds_for_one_equals(self):
import testtools
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common import utils
from neutron.plugins.common import utils as plugin_utils
from neutron.tests import base
def check_one_vlan_invalid(self, bad_range, which):
expected_msg = self._vrange_invalid_vlan(bad_range, which)
- err = self.assertRaises(q_exc.NetworkVlanRangeError,
+ err = self.assertRaises(n_exc.NetworkVlanRangeError,
self.verify_range, bad_range)
self.assertEqual(str(err), expected_msg)
def test_range_reversed(self):
bad_range = (95, 10)
expected_msg = self._vrange_invalid(bad_range)
- err = self.assertRaises(q_exc.NetworkVlanRangeError,
+ err = self.assertRaises(n_exc.NetworkVlanRangeError,
self.verify_range, bad_range)
self.assertEqual(str(err), expected_msg)
def test_parse_one_net_incomplete_range(self):
config_str = "net1:100"
expected_msg = self._range_too_few_err(config_str)
- err = self.assertRaises(q_exc.NetworkVlanRangeError,
+ err = self.assertRaises(n_exc.NetworkVlanRangeError,
self.parse_one, config_str)
self.assertEqual(str(err), expected_msg)
def test_parse_one_net_range_too_many(self):
config_str = "net1:100:150:200"
expected_msg = self._range_too_many_err(config_str)
- err = self.assertRaises(q_exc.NetworkVlanRangeError,
+ err = self.assertRaises(n_exc.NetworkVlanRangeError,
self.parse_one, config_str)
self.assertEqual(str(err), expected_msg)
def test_parse_one_net_vlan1_not_int(self):
config_str = "net1:foo:199"
expected_msg = self._vlan_not_int_err(config_str, 'foo')
- err = self.assertRaises(q_exc.NetworkVlanRangeError,
+ err = self.assertRaises(n_exc.NetworkVlanRangeError,
self.parse_one, config_str)
self.assertEqual(str(err), expected_msg)
def test_parse_one_net_vlan2_not_int(self):
config_str = "net1:100:bar"
expected_msg = self._vlan_not_int_err(config_str, 'bar')
- err = self.assertRaises(q_exc.NetworkVlanRangeError,
+ err = self.assertRaises(n_exc.NetworkVlanRangeError,
self.parse_one, config_str)
self.assertEqual(str(err), expected_msg)
def test_parse_one_net_range_bad_vlan1(self):
config_str = "net1:9000:150"
expected_msg = self._nrange_invalid_vlan(config_str, 1)
- err = self.assertRaises(q_exc.NetworkVlanRangeError,
+ err = self.assertRaises(n_exc.NetworkVlanRangeError,
self.parse_one, config_str)
self.assertEqual(str(err), expected_msg)
def test_parse_one_net_range_bad_vlan2(self):
config_str = "net1:4000:4999"
expected_msg = self._nrange_invalid_vlan(config_str, 2)
- err = self.assertRaises(q_exc.NetworkVlanRangeError,
+ err = self.assertRaises(n_exc.NetworkVlanRangeError,
self.parse_one, config_str)
self.assertEqual(str(err), expected_msg)
config_list = ["net1:100",
"net2:200:299"]
expected_msg = self._range_too_few_err(config_list[0])
- err = self.assertRaises(q_exc.NetworkVlanRangeError,
+ err = self.assertRaises(n_exc.NetworkVlanRangeError,
self.parse_list, config_list)
self.assertEqual(str(err), expected_msg)
config_list = ["net1:100:199",
"net2:200:0x200"]
expected_msg = self._vlan_not_int_err(config_list[1], '0x200')
- err = self.assertRaises(q_exc.NetworkVlanRangeError,
+ err = self.assertRaises(n_exc.NetworkVlanRangeError,
self.parse_list, config_list)
self.assertEqual(str(err), expected_msg)
from neutron.api.v2.attributes import ATTR_NOT_SPECIFIED
from neutron.api.v2.router import APIRouter
from neutron.common import config
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.common.test_lib import test_config
from neutron import context
from neutron.db import api as db
def _do_side_effect(self, patched_plugin, orig, *args, **kwargs):
"""Invoked by test cases for injecting failures in plugin."""
def second_call(*args, **kwargs):
- raise q_exc.NeutronException()
+ raise n_exc.NeutronException()
patched_plugin.side_effect = second_call
return orig(*args, **kwargs)
id = subnet['subnet']['network_id']
res = self._create_port(self.fmt, id)
data = self.deserialize(self.fmt, res)
- msg = str(q_exc.IpAddressGenerationFailure(net_id=id))
+ msg = str(n_exc.IpAddressGenerationFailure(net_id=id))
self.assertEqual(data['NeutronError']['message'], msg)
self.assertEqual(res.status_int, webob.exc.HTTPConflict.code)
# we just raise the exception that would result.
@staticmethod
def fake_gen_mac(context, net_id):
- raise q_exc.MacAddressGenerationFailure(net_id=net_id)
+ raise n_exc.MacAddressGenerationFailure(net_id=net_id)
with mock.patch.object(neutron.db.db_base_plugin_v2.NeutronDbPluginV2,
'_generate_mac', new=fake_gen_mac):
res = req.get_response(self.api)
data = self.deserialize(self.fmt, res)
self.assertEqual(res.status_int, webob.exc.HTTPConflict.code)
- msg = str(q_exc.SubnetInUse(subnet_id=id))
+ msg = str(n_exc.SubnetInUse(subnet_id=id))
self.assertEqual(data['NeutronError']['message'], msg)
def test_delete_network(self):
def test_validate_subnet_dns_nameservers_exhausted(self):
self._helper_test_validate_subnet(
'max_dns_nameservers',
- q_exc.DNSNameServersExhausted)
+ n_exc.DNSNameServersExhausted)
def test_validate_subnet_host_routes_exhausted(self):
self._helper_test_validate_subnet(
'max_subnet_host_routes',
- q_exc.HostRoutesExhausted)
+ n_exc.HostRoutesExhausted)
class DbModelTestCase(base.BaseTestCase):
with mock.patch.object(db_base_plugin_v2.NeutronDbPluginV2,
'_rebuild_availability_ranges') as rebuild:
- exception = q_exc.IpAddressGenerationFailure(net_id='n')
+ exception = n_exc.IpAddressGenerationFailure(net_id='n')
generate.side_effect = exception
# I want the side_effect to throw an exception once but I
# _try_generate_ip was called twice.
try:
db_base_plugin_v2.NeutronDbPluginV2._generate_ip('c', 's')
- except q_exc.IpAddressGenerationFailure:
+ except n_exc.IpAddressGenerationFailure:
pass
self.assertEqual(2, generate.call_count)
from neutron.api.v2 import attributes
from neutron.common import constants as l3_constants
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron import context
from neutron.db import api as qdbapi
from neutron.db import db_base_plugin_v2
None)
method = plugin_class + '._update_fip_assoc'
with mock.patch(method) as pl:
- pl.side_effect = q_exc.BadRequest(
+ pl.side_effect = n_exc.BadRequest(
resource='floatingip',
msg='fake_error')
res = self._create_floatingip(
None)
method = plugin_class + '._update_fip_assoc'
with mock.patch(method) as pl:
- pl.side_effect = q_exc.IpAddressGenerationFailure(
+ pl.side_effect = n_exc.IpAddressGenerationFailure(
net_id='netid')
res = self._create_floatingip(
self.fmt,
from oslo.config import cfg
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron.plugins.common import constants
from neutron.services import provider_configuration as provconf
':lbaas:driver_path',
'svc_type:name1:path1'],
'service_providers')
- self.assertRaises(q_exc.Invalid, provconf.parse_service_provider_opt)
+ self.assertRaises(n_exc.Invalid, provconf.parse_service_provider_opt)
def test_parse_service_provider_invalid_format(self):
cfg.CONF.set_override('service_provider',
':lbaas:driver_path',
'svc_type:name1:path1:def'],
'service_providers')
- self.assertRaises(q_exc.Invalid, provconf.parse_service_provider_opt)
+ self.assertRaises(n_exc.Invalid, provconf.parse_service_provider_opt)
cfg.CONF.set_override('service_provider',
[constants.LOADBALANCER +
':',
'svc_type:name1:path1:def'],
'service_providers')
- self.assertRaises(q_exc.Invalid, provconf.parse_service_provider_opt)
+ self.assertRaises(n_exc.Invalid, provconf.parse_service_provider_opt)
def test_parse_service_provider_name_too_long(self):
name = 'a' * 256
':' + name + ':driver_path',
'svc_type:name1:path1:def'],
'service_providers')
- self.assertRaises(q_exc.Invalid, provconf.parse_service_provider_opt)
+ self.assertRaises(n_exc.Invalid, provconf.parse_service_provider_opt)
class ProviderConfigurationTestCase(base.BaseTestCase):
pconf = provconf.ProviderConfiguration([])
pconf.providers[('svctype', 'name')] = {'driver': 'driver',
'default': True}
- self.assertRaises(q_exc.Invalid,
+ self.assertRaises(n_exc.Invalid,
pconf._ensure_driver_unique, 'driver')
self.assertIsNone(pconf._ensure_driver_unique('another_driver1'))
pconf = provconf.ProviderConfiguration([])
pconf.providers[('svctype', 'name')] = {'driver': 'driver',
'default': True}
- self.assertRaises(q_exc.Invalid,
+ self.assertRaises(n_exc.Invalid,
pconf._ensure_default_unique,
'svctype', True)
self.assertIsNone(pconf._ensure_default_unique('svctype', False))
'driver': 'path',
'default': False}
pconf.add_provider(prov)
- self.assertRaises(q_exc.Invalid, pconf.add_provider, prov)
+ self.assertRaises(n_exc.Invalid, pconf.add_provider, prov)
self.assertEqual(len(pconf.providers), 1)
def test_get_service_providers(self):
import webtest
from neutron.api import extensions
-from neutron.common import exceptions as q_exc
+from neutron.common import exceptions as n_exc
from neutron import context
from neutron.db import api as db_api
from neutron.db import servicetype_db as st_db
'default': False}
self.manager._load_conf()
self.assertRaises(
- q_exc.Invalid, self.manager.conf.add_provider, prov)
+ n_exc.Invalid, self.manager.conf.add_provider, prov)
def test_get_service_providers(self):
cfg.CONF.set_override('service_provider',
constants.LOADBALANCER +
':lbaas2:driver_path:default'],
'service_providers')
- self.assertRaises(q_exc.Invalid, self.manager._load_conf)
+ self.assertRaises(n_exc.Invalid, self.manager._load_conf)
def test_get_default_provider(self):
cfg.CONF.set_override('service_provider',