Renaming plugin-specific exceptions to match NSX

Try to get rid of Nvp as much as possible, the base
class already uses the plugin short name so it's
pointless to carry it over.

Partial-implements blueprint nicira-plugin-renaming

Change-Id: Ic3e53bc4e41ffe1a19ea03e807ec89bb6c864f51
This commit is contained in:
armando-migliaccio 2014-02-13 16:57:19 -08:00
parent c624dc3230
commit efba6e0250
18 changed files with 127 additions and 136 deletions

View File

@ -63,7 +63,7 @@ from neutron.openstack.common import lockutils
from neutron.plugins.common import constants as plugin_const
from neutron.plugins.nicira.api_client import exception as api_exc
from neutron.plugins.nicira.common import config # noqa
from neutron.plugins.nicira.common import exceptions as nvp_exc
from neutron.plugins.nicira.common import exceptions as nsx_exc
from neutron.plugins.nicira.common import nsx_utils
from neutron.plugins.nicira.common import securitygroups as sg_utils
from neutron.plugins.nicira.common import sync
@ -265,9 +265,9 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
port_data.get('mac_address'))
LOG.debug(_("Created NVP router port:%s"), lrouter_port['uuid'])
except api_exc.NsxApiException:
LOG.exception(_("Unable to create port on NVP logical router %s"),
LOG.exception(_("Unable to create port on NSX logical router %s"),
nsx_router_id)
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=_("Unable to create logical router port for neutron "
"port id %(port_id)s on router %(nsx_router_id)s") %
{'port_id': port_data.get('id'),
@ -357,7 +357,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
"Neutron %(q_port_id)s"),
{'r_port_id': nsx_router_port_id,
'q_port_id': port_data.get('id')})
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=(_("Unable to plug attachment in router port "
"%(r_port_id)s for neutron port id %(q_port_id)s "
"on router %(router_id)s") %
@ -407,7 +407,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
err_desc = _("An exception occurred while selecting logical "
"switch for the port")
LOG.exception(err_desc)
raise nvp_exc.NvpPluginException(err_msg=err_desc)
raise nsx_exc.NsxPluginException(err_msg=err_desc)
def _nvp_create_port_helper(self, session, ls_uuid, port_data,
do_port_security=True):
@ -562,7 +562,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
"""Driver for creating a switch port to be connected to a router."""
# No router ports on external networks!
if self._network_is_external(context, port_data['network_id']):
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=(_("It is not allowed to create router interface "
"ports on external networks as '%s'") %
port_data['network_id']))
@ -610,7 +610,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
lr_port = routerlib.find_router_gw_port(context, self.cluster,
nsx_router_id)
if not lr_port:
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=(_("The gateway port for the NSX router %s "
"was not found on the backend")
% nsx_router_id))
@ -686,11 +686,11 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self.cluster.default_l3_gw_service_uuid)
except api_exc.ResourceNotFound:
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=_("Logical router resource %s not found "
"on NVP platform") % router_id)
except api_exc.NsxApiException:
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=_("Unable to update logical router"
"on NVP Platform"))
LOG.debug(_("_nvp_delete_ext_gw_port completed on external network "
@ -755,11 +755,11 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
Exceptions specific to the NVP Plugin are mapped to standard
HTTP Exceptions.
"""
base.FAULT_MAP.update({nvp_exc.NvpInvalidNovaZone:
base.FAULT_MAP.update({nsx_exc.InvalidNovaZone:
webob.exc.HTTPBadRequest,
nvp_exc.NvpNoMorePortsException:
nsx_exc.NoMorePortsException:
webob.exc.HTTPBadRequest,
nvp_exc.MaintenanceInProgress:
nsx_exc.MaintenanceInProgress:
webob.exc.HTTPServiceUnavailable})
def _validate_provider_create(self, context, network):
@ -890,7 +890,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
else:
LOG.error(_("Maximum number of logical ports reached for "
"logical network %s"), network.id)
raise nvp_exc.NvpNoMorePortsException(network=network.id)
raise nsx_exc.NoMorePortsException(network=network.id)
def _convert_to_nvp_transport_zones(self, cluster, network=None,
bindings=None):
@ -1410,7 +1410,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self.cluster, router['id'],
tenant_id, router['name'], nexthop,
distributed=attr.is_attr_set(distributed) and distributed)
except nvp_exc.NvpInvalidVersion:
except nsx_exc.InvalidVersion:
msg = _("Cannot create a distributed router with the NVP "
"platform currently in execution. Please, try "
"without specifying the 'distributed' attribute.")
@ -1419,7 +1419,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
except api_exc.NsxApiException:
err_msg = _("Unable to create logical router on NVP Platform")
LOG.exception(err_msg)
raise nvp_exc.NvpPluginException(err_msg=err_msg)
raise nsx_exc.NsxPluginException(err_msg=err_msg)
# Create the port here - and update it later if we have gw_info
try:
@ -1427,7 +1427,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self.cluster, context, lrouter['uuid'], {'fake_ext_gw': True},
"L3GatewayAttachment",
self.cluster.default_l3_gw_service_uuid)
except nvp_exc.NvpPluginException:
except nsx_exc.NsxPluginException:
LOG.exception(_("Unable to create L3GW port on logical router "
"%(router_uuid)s. Verify Default Layer-3 Gateway "
"service %(def_l3_gw_svc)s id is correct"),
@ -1437,7 +1437,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# Try and remove logical router from NVP
routerlib.delete_lrouter(self.cluster, lrouter['uuid'])
# Return user a 500 with an apter message
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=(_("Unable to create router %s on NSX backend") %
router['id']))
lrouter['status'] = plugin_const.ACTIVE
@ -1576,13 +1576,13 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
with context.session.begin(subtransactions=True):
router_db = self._get_router(context, router_id)
router_db['status'] = constants.NET_STATUS_ERROR
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=_("Logical router %s not found "
"on NVP Platform") % router_id)
except api_exc.NsxApiException:
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=_("Unable to update logical router on NVP Platform"))
except nvp_exc.NvpInvalidVersion:
except nsx_exc.InvalidVersion:
msg = _("Request cannot contain 'routes' with the NVP "
"platform currently in execution. Please, try "
"without specifying the static routes.")
@ -1643,7 +1643,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
LOG.warning(_("Logical router '%s' not found "
"on NVP Platform"), router_id)
except api_exc.NsxApiException:
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=(_("Unable to delete logical router '%s' "
"on NVP Platform") % nsx_router_id))
# Remove the NSX mapping first in order to ensure a mapping to
@ -1784,11 +1784,11 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
max_num_expected=1, min_num_expected=0,
destination_ip_addresses=subnet['cidr'])
except api_exc.ResourceNotFound:
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=(_("Logical router resource %s not found "
"on NVP platform") % router_id))
except api_exc.NsxApiException:
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
err_msg=(_("Unable to update logical router"
"on NVP Platform")))
return info
@ -1824,7 +1824,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
"on the NVP platform for floating ip:%s"),
floating_ip_address)
raise
except nvp_exc.NvpNatRuleMismatch:
except nsx_exc.NatRuleMismatch:
# Do not surface to the user
LOG.warning(_("An incorrect number of matching NAT rules "
"was found on the NVP platform"))
@ -1965,7 +1965,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
{'floating_ip': floating_ip,
'internal_ip': internal_ip})
msg = _("Failed to update NAT rules for floatingip update")
raise nvp_exc.NvpPluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
floatingip_db.update({'fixed_ip_address': internal_ip,
'fixed_port_id': port_id,
@ -2027,11 +2027,11 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
self.cluster, tenant_id, gw_data['name'], devices)
nsx_uuid = nsx_res.get('uuid')
except api_exc.Conflict:
raise nvp_exc.NvpL2GatewayAlreadyInUse(gateway=gw_data['name'])
raise nsx_exc.L2GatewayAlreadyInUse(gateway=gw_data['name'])
except api_exc.NsxApiException:
err_msg = _("Unable to create l2_gw_service for: %s") % gw_data
LOG.exception(err_msg)
raise nvp_exc.NvpPluginException(err_msg=err_msg)
raise nsx_exc.NsxPluginException(err_msg=err_msg)
gw_data['id'] = nsx_uuid
return super(NvpPluginV2, self).create_network_gateway(context,
network_gateway)
@ -2095,7 +2095,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
return super(NvpPluginV2, self).connect_network(
context, network_gateway_id, network_mapping_info)
except api_exc.Conflict:
raise nvp_exc.NvpL2GatewayAlreadyInUse(gateway=network_gateway_id)
raise nsx_exc.L2GatewayAlreadyInUse(gateway=network_gateway_id)
def disconnect_network(self, context, network_gateway_id,
network_mapping_info):
@ -2170,7 +2170,7 @@ class NvpPluginV2(addr_pair_db.AllowedAddressPairsMixin,
"%(sec_group_id)s"),
{'sec_profile_id': nsx_sec_profile_id,
'sec_group_id': security_group_id})
raise nvp_exc.NvpPluginException(
raise nsx_exc.NsxPluginException(
_("Unable to remove security group %s from backend"),
security_group['id'])
return super(NvpPluginV2, self).delete_security_group(

View File

@ -32,7 +32,7 @@ from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as service_constants
from neutron.plugins.nicira.api_client import exception as api_exc
from neutron.plugins.nicira.common import config # noqa
from neutron.plugins.nicira.common import exceptions as nvp_exc
from neutron.plugins.nicira.common import exceptions as nsx_exc
from neutron.plugins.nicira.common import utils
from neutron.plugins.nicira.dbexts import servicerouter as sr_db
from neutron.plugins.nicira.dbexts import vcns_db
@ -882,7 +882,7 @@ class NvpAdvancedPlugin(sr_db.ServiceRouter_mixin,
context, firewall_db.Firewall, router_id=router_id):
msg = _("A firewall is already associated with the router")
LOG.error(msg)
raise nvp_exc.NvpServiceOverQuota(
raise nsx_exc.ServiceOverQuota(
overs='firewall', err_msg=msg)
fw = super(NvpAdvancedPlugin, self).create_firewall(context, firewall)
@ -1119,7 +1119,7 @@ class NvpAdvancedPlugin(sr_db.ServiceRouter_mixin,
{'model': model,
'id': id})
LOG.error(msg)
raise nvp_exc.NvpServicePluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
else:
res.status = status
except sa_exc.NoResultFound:
@ -1127,7 +1127,7 @@ class NvpAdvancedPlugin(sr_db.ServiceRouter_mixin,
{'model': model,
'id': id})
LOG.exception(msg)
raise nvp_exc.NvpServicePluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
if obj:
obj['status'] = status
@ -1194,7 +1194,7 @@ class NvpAdvancedPlugin(sr_db.ServiceRouter_mixin,
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 nvp_exc.NvpServicePluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
#Check whether the vip port is an external port
subnet_id = vip['vip']['subnet_id']
@ -1203,7 +1203,7 @@ class NvpAdvancedPlugin(sr_db.ServiceRouter_mixin,
if not ext_net.external:
msg = (_("Network '%s' is not a valid external "
"network") % network_id)
raise nvp_exc.NvpServicePluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
v = super(NvpAdvancedPlugin, self).create_vip(context, vip)
#Get edge_id for the resource
@ -1504,7 +1504,7 @@ class NvpAdvancedPlugin(sr_db.ServiceRouter_mixin,
msg = _("Vcns right now can only support "
"one monitor per pool")
LOG.error(msg)
raise nvp_exc.NvpServicePluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
#Check whether the pool is already associated with the vip
if not pool.get('vip_id'):
res = super(NvpAdvancedPlugin,

View File

@ -1,6 +1,5 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2012 Nicira Networks, Inc
# Copyright 2012 VMware, Inc
#
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@ -15,79 +14,71 @@
# License for the specific language governing permissions and limitations
# under the License.
"""NVP Plugin exceptions"""
from neutron.common import exceptions as q_exc
from neutron.common import exceptions as n_exc
class NvpPluginException(q_exc.NeutronException):
message = _("An unexpected error occurred in the NVP Plugin:%(err_msg)s")
class NsxPluginException(n_exc.NeutronException):
message = _("An unexpected error occurred in the NSX Plugin: %(err_msg)s")
class NvpInvalidVersion(NvpPluginException):
class InvalidVersion(NsxPluginException):
message = _("Unable to fulfill request with version %(version)s.")
class NvpInvalidConnection(NvpPluginException):
message = _("Invalid NVP connection parameters: %(conn_params)s")
class InvalidConnection(NsxPluginException):
message = _("Invalid NSX connection parameters: %(conn_params)s")
class NvpInvalidClusterConfiguration(NvpPluginException):
class InvalidClusterConfiguration(NsxPluginException):
message = _("Invalid cluster values: %(invalid_attrs)s. Please ensure "
"that these values are specified in the [DEFAULT] "
"section of the nvp plugin ini file.")
"section of the NSX plugin ini file.")
class NvpInvalidNovaZone(NvpPluginException):
class InvalidNovaZone(NsxPluginException):
message = _("Unable to find cluster config entry "
"for nova zone: %(nova_zone)s")
class NvpNoMorePortsException(NvpPluginException):
class NoMorePortsException(NsxPluginException):
message = _("Unable to create port on network %(network)s. "
"Maximum number of ports reached")
class NvpNatRuleMismatch(NvpPluginException):
class NatRuleMismatch(NsxPluginException):
message = _("While retrieving NAT rules, %(actual_rules)s were found "
"whereas rules in the (%(min_rules)s,%(max_rules)s) interval "
"were expected")
class NvpInvalidAttachmentType(NvpPluginException):
message = _("Invalid NVP attachment type '%(attachment_type)s'")
class InvalidAttachmentType(NsxPluginException):
message = _("Invalid NSX attachment type '%(attachment_type)s'")
class MaintenanceInProgress(NvpPluginException):
class MaintenanceInProgress(NsxPluginException):
message = _("The networking backend is currently in maintenance mode and "
"therefore unable to accept requests which modify its state. "
"Please try later.")
class NvpServicePluginException(q_exc.NeutronException):
"""NVP Service Plugin exceptions."""
message = _("An unexpected error happened "
"in the NVP Service Plugin: %(err_msg)s")
class NvpL2GatewayAlreadyInUse(q_exc.Conflict):
class L2GatewayAlreadyInUse(n_exc.Conflict):
message = _("Gateway Service %(gateway)s is already in use")
class NvpServiceOverQuota(q_exc.Conflict):
class ServiceOverQuota(n_exc.Conflict):
message = _("Quota exceeded for Vcns resource: %(overs)s: %(err_msg)s")
class NvpVcnsDriverException(NvpServicePluginException):
message = _("Error happened in NVP VCNS Driver: %(err_msg)s")
class VcnsDriverException(NsxPluginException):
message = _("Error happened in NSX VCNS Driver: %(err_msg)s")
class ServiceClusterUnavailable(NvpPluginException):
class ServiceClusterUnavailable(NsxPluginException):
message = _("Service cluster: '%(cluster_id)s' is unavailable. Please, "
"check NVP setup and/or configuration")
"check NSX setup and/or configuration")
class PortConfigurationError(NvpPluginException):
class PortConfigurationError(NsxPluginException):
message = _("An error occurred while connecting LSN %(lsn_id)s "
"and network %(net_id)s via port %(port_id)s")
@ -96,18 +87,18 @@ class PortConfigurationError(NvpPluginException):
self.port_id = kwargs.get('port_id')
class LsnNotFound(q_exc.NotFound):
class LsnNotFound(n_exc.NotFound):
message = _('Unable to find LSN for %(entity)s %(entity_id)s')
class LsnPortNotFound(q_exc.NotFound):
class LsnPortNotFound(n_exc.NotFound):
message = (_('Unable to find port for LSN %(lsn_id)s '
'and %(entity)s %(entity_id)s'))
class LsnMigrationConflict(q_exc.Conflict):
class LsnMigrationConflict(n_exc.Conflict):
message = _("Unable to migrate network '%(net_id)s' to LSN: %(reason)s")
class LsnConfigurationConflict(NvpPluginException):
class LsnConfigurationConflict(NsxPluginException):
message = _("Configuration conflict on Logical Service Node %(lsn_id)s")

View File

@ -26,7 +26,7 @@ from neutron.openstack.common import log
from neutron.openstack.common import loopingcall
from neutron.openstack.common import timeutils
from neutron.plugins.nicira.api_client import exception as api_exc
from neutron.plugins.nicira.common import exceptions as nvp_exc
from neutron.plugins.nicira.common import exceptions as nsx_exc
from neutron.plugins.nicira.common import nsx_utils
from neutron.plugins.nicira.nsxlib import router as routerlib
from neutron.plugins.nicira.nsxlib import switch as switchlib
@ -224,7 +224,7 @@ class NvpSynchronizer():
{'req_delay': self._req_delay,
'sync_interval': self._sync_interval})
LOG.error(err_msg)
raise nvp_exc.NvpPluginException(err_msg=err_msg)
raise nsx_exc.NsxPluginException(err_msg=err_msg)
# Backoff time in case of failures while fetching sync data
self._sync_backoff = 1
# Store the looping call in an instance variable to allow unit tests

View File

@ -17,7 +17,7 @@
from sqlalchemy.orm import exc
from neutron.openstack.common import log as logging
from neutron.plugins.nicira.common import exceptions as nvp_exc
from neutron.plugins.nicira.common import exceptions as nsx_exc
from neutron.plugins.nicira.dbexts import vcns_models
from neutron.plugins.nicira.vshield.common import (
exceptions as vcns_exc)
@ -75,7 +75,7 @@ def delete_vcns_edge_firewallrule_binding(session, id):
if not (session.query(vcns_models.VcnsEdgeFirewallRuleBinding).
filter_by(rule_id=id).delete()):
msg = _("Rule Resource binding with id:%s not found!") % id
raise nvp_exc.NvpServicePluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
def get_vcns_edge_firewallrule_binding(session, id, edge_id):
@ -92,7 +92,7 @@ def get_vcns_edge_firewallrule_binding_by_vseid(
filter_by(edge_id=edge_id, rule_vseid=rule_vseid).one())
except exc.NoResultFound:
msg = _("Rule Resource binding not found!")
raise nvp_exc.NvpServicePluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
def cleanup_vcns_edge_firewallrule_binding(session, edge_id):
@ -132,7 +132,7 @@ def delete_vcns_edge_vip_binding(session, id):
if not qry.filter_by(vip_id=id).delete():
msg = _("VIP Resource binding with id:%s not found!") % id
LOG.exception(msg)
raise nvp_exc.NvpServicePluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
def add_vcns_edge_pool_binding(session, map_info):
@ -163,7 +163,7 @@ def get_vcns_edge_pool_binding_by_vseid(session, edge_id, pool_vseid):
"pool_vseid:%(pool_vseid)s not found!") %
{'edge_id': edge_id, 'pool_vseid': pool_vseid})
LOG.exception(msg)
raise nvp_exc.NvpServicePluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
return binding
@ -173,7 +173,7 @@ def delete_vcns_edge_pool_binding(session, id, edge_id):
if not qry.filter_by(pool_id=id, edge_id=edge_id).delete():
msg = _("Pool Resource binding with id:%s not found!") % id
LOG.exception(msg)
raise nvp_exc.NvpServicePluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
def add_vcns_edge_monitor_binding(session, map_info):
@ -199,4 +199,4 @@ def delete_vcns_edge_monitor_binding(session, id, edge_id):
if not qry.filter_by(monitor_id=id, edge_id=edge_id).delete():
msg = _("Monitor Resource binding with id:%s not found!") % id
LOG.exception(msg)
raise nvp_exc.NvpServicePluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)

View File

@ -78,7 +78,7 @@ class LsnManager(object):
return lsn_api.lsn_for_network_create(self.cluster, network_id)
except api_exc.NsxApiException:
err_msg = _('Unable to create LSN for network %s') % network_id
raise p_exc.NvpPluginException(err_msg=err_msg)
raise p_exc.NsxPluginException(err_msg=err_msg)
def lsn_delete(self, context, lsn_id):
"""Delete a LSN given its id."""
@ -145,7 +145,7 @@ class LsnManager(object):
raise p_exc.LsnNotFound(entity='', entity_id=lsn_id)
except api_exc.NsxApiException:
err_msg = _('Unable to create port for LSN %s') % lsn_id
raise p_exc.NvpPluginException(err_msg=err_msg)
raise p_exc.NsxPluginException(err_msg=err_msg)
def lsn_port_delete(self, context, lsn_id, lsn_port_id):
"""Delete a LSN port from the Logical Service Node."""
@ -184,7 +184,7 @@ class LsnManager(object):
self.cluster, network_id, port_id)['uuid']
lsn_id = self.lsn_get(context, network_id)
lsn_port_id = self.lsn_port_create(context, lsn_id, port_data)
except (n_exc.NotFound, p_exc.NvpPluginException):
except (n_exc.NotFound, p_exc.NsxPluginException):
raise p_exc.PortConfigurationError(
net_id=network_id, lsn_id=lsn_id, port_id=port_id)
else:
@ -217,7 +217,7 @@ class LsnManager(object):
const.METADATA_PORT_ID, const.METADATA_PORT_NAME,
const.METADATA_DEVICE_ID, True)['uuid']
lsn_port_id = self.lsn_port_create(self.cluster, lsn_id, data)
except (n_exc.NotFound, p_exc.NvpPluginException,
except (n_exc.NotFound, p_exc.NsxPluginException,
api_exc.NsxApiException):
raise p_exc.PortConfigurationError(
net_id=network_id, lsn_id=lsn_id, port_id=lswitch_port_id)
@ -257,7 +257,7 @@ class LsnManager(object):
'Node %(lsn_id)s and port %(lsn_port_id)s')
% {'lsn_id': lsn_id, 'lsn_port_id': lsn_port_id})
LOG.error(err_msg)
raise p_exc.NvpPluginException(err_msg=err_msg)
raise p_exc.NsxPluginException(err_msg=err_msg)
def lsn_metadata_configure(self, context, subnet_id, is_enabled):
"""Configure metadata service for the specified subnet."""
@ -277,7 +277,7 @@ class LsnManager(object):
err_msg = (_('Unable to configure metadata '
'for subnet %s') % subnet_id)
LOG.error(err_msg)
raise p_exc.NvpPluginException(err_msg=err_msg)
raise p_exc.NsxPluginException(err_msg=err_msg)
if is_enabled:
try:
# test that the lsn port exists
@ -369,14 +369,14 @@ class PersistentLsnManager(LsnManager):
except db_exc.DBError:
err_msg = _('Unable to save LSN for network %s') % network_id
LOG.exception(err_msg)
raise p_exc.NvpPluginException(err_msg=err_msg)
raise p_exc.NsxPluginException(err_msg=err_msg)
def lsn_create(self, context, network_id):
lsn_id = super(PersistentLsnManager,
self).lsn_create(context, network_id)
try:
self.lsn_save(context, network_id, lsn_id)
except p_exc.NvpPluginException:
except p_exc.NsxPluginException:
super(PersistentLsnManager, self).lsn_delete(context, lsn_id)
raise
return lsn_id
@ -431,7 +431,7 @@ class PersistentLsnManager(LsnManager):
except db_exc.DBError:
err_msg = _('Unable to save LSN port for subnet %s') % subnet_id
LOG.exception(err_msg)
raise p_exc.NvpPluginException(err_msg=err_msg)
raise p_exc.NsxPluginException(err_msg=err_msg)
def lsn_port_create(self, context, lsn_id, subnet_info):
lsn_port_id = super(PersistentLsnManager,
@ -439,7 +439,7 @@ class PersistentLsnManager(LsnManager):
try:
self.lsn_port_save(context, lsn_port_id, subnet_info['subnet_id'],
subnet_info['mac_address'], lsn_id)
except p_exc.NvpPluginException:
except p_exc.NsxPluginException:
super(PersistentLsnManager, self).lsn_port_delete(
context, lsn_id, lsn_port_id)
raise

View File

@ -198,7 +198,7 @@ def check_services_requirements(cluster):
if not lsn_api.service_cluster_exists(cluster, cluster_id):
raise p_exc.ServiceClusterUnavailable(cluster_id=cluster_id)
else:
raise p_exc.NvpInvalidVersion(version=ver)
raise p_exc.InvalidVersion(version=ver)
def handle_network_dhcp_access(plugin, context, network, action):
@ -309,7 +309,7 @@ def handle_router_metadata_access(plugin, context, router_id, interface=None):
try:
plugin.lsn_manager.lsn_metadata_configure(
context, subnet_id, is_enabled)
except p_exc.NvpPluginException:
except p_exc.NsxPluginException:
if is_enabled:
l3_db.L3_NAT_db_mixin.remove_router_interface(
plugin, context, router_id, interface)

View File

@ -33,7 +33,7 @@ from neutron.db import models_v2
from neutron.openstack.common import log as logging
from neutron.plugins.nicira.api_client import exception as api_exc
from neutron.plugins.nicira.common import config
from neutron.plugins.nicira.common import exceptions as nvp_exc
from neutron.plugins.nicira.common import exceptions as nsx_exc
LOG = logging.getLogger(__name__)
@ -135,7 +135,7 @@ def handle_router_metadata_access(plugin, context, router_id, interface=None):
"created or destroyed"), router_id)
# TODO(salvatore-orlando): A better exception handling in the
# NSX plugin would allow us to improve error handling here
except (ntn_exc.NeutronException, nvp_exc.NvpPluginException,
except (ntn_exc.NeutronException, nsx_exc.NsxPluginException,
api_exc.NsxApiException):
# Any exception here should be regarded as non-fatal
LOG.exception(_("An error occurred while operating on the "
@ -188,7 +188,7 @@ def _create_metadata_access_network(plugin, context, router_id):
{'subnet_id': meta_sub['id']})
greenthread.sleep(0) # yield
except (ntn_exc.NeutronException,
nvp_exc.NvpPluginException,
nsx_exc.NsxPluginException,
api_exc.NsxApiException):
# It is not necessary to explicitly delete the subnet
# as it will be removed with the network
@ -214,7 +214,7 @@ def _destroy_metadata_access_network(plugin, context, router_id, ports):
# Remove network (this will remove the subnet too)
plugin.delete_network(context, meta_net_id)
greenthread.sleep(0) # yield
except (ntn_exc.NeutronException, nvp_exc.NvpPluginException,
except (ntn_exc.NeutronException, nsx_exc.NsxPluginException,
api_exc.NsxApiException):
# must re-add the router interface
plugin.add_router_interface(context, router_id,

View File

@ -53,7 +53,7 @@ class DhcpMetadataAccess(object):
else:
error = _("Invalid agent_mode: %s") % cfg.CONF.NSX.agent_mode
LOG.error(error)
raise nsx_exc.NvpPluginException(err_msg=error)
raise nsx_exc.NsxPluginException(err_msg=error)
self.handle_network_dhcp_access_delegate = (
mod.handle_network_dhcp_access
)
@ -118,7 +118,7 @@ class DhcpMetadataAccess(object):
try:
error = None
nsx_svc.check_services_requirements(self.cluster)
except nsx_exc.NvpInvalidVersion:
except nsx_exc.InvalidVersion:
error = _("Unable to run Neutron with config option '%s', as NSX "
"does not support it") % cfg.CONF.NSX.agent_mode
except nsx_exc.ServiceClusterUnavailable:
@ -126,7 +126,7 @@ class DhcpMetadataAccess(object):
"'%s'") % cfg.CONF.NSX.agent_mode
if error:
LOG.exception(error)
raise nsx_exc.NvpPluginException(err_msg=error)
raise nsx_exc.NsxPluginException(err_msg=error)
def get_lsn(self, context, network_id, fields=None):
report = self.migration_manager.report(context, network_id)

View File

@ -60,7 +60,7 @@ class NSXCluster(object):
# If everything went according to plan these two lists should be empty
if self._required_attributes:
raise exceptions.NvpInvalidClusterConfiguration(
raise exceptions.InvalidClusterConfiguration(
invalid_attrs=self._required_attributes)
if self._important_attributes:
LOG.info(_("The following cluster attributes were "

View File

@ -42,7 +42,7 @@ def create_l2_gw_service(cluster, tenant_id, display_name, devices):
:param display_name: Descriptive name of this gateway service
:param devices: List of transport node uuids (and network
interfaces on them) to use for the network gateway service
:raise NvpApiException: if there is a problem while communicating
:raise NsxApiException: if there is a problem while communicating
with the NSX controller
"""
# NOTE(salvatore-orlando): This is a little confusing, but device_id in

View File

@ -20,7 +20,7 @@ import json
from neutron.common import exceptions as exception
from neutron.openstack.common import log
from neutron.plugins.nicira.api_client import exception as api_exc
from neutron.plugins.nicira.common import exceptions as nvp_exc
from neutron.plugins.nicira.common import exceptions as nsx_exc
from neutron.plugins.nicira.common import utils
from neutron.plugins.nicira.nvplib import _build_uri_path
from neutron.plugins.nicira.nvplib import do_request
@ -174,7 +174,7 @@ def lsn_port_plug_network(cluster, lsn_id, lsn_port_id, lswitch_port_id):
"already exists with another port") %
{'lsn': lsn_id, 'port': lswitch_port_id})
LOG.exception(msg)
raise nvp_exc.LsnConfigurationConflict(lsn_id=lsn_id)
raise nsx_exc.LsnConfigurationConflict(lsn_id=lsn_id)
def _lsn_configure_action(

View File

@ -18,7 +18,7 @@ from neutron.openstack.common import excutils
from neutron.openstack.common import jsonutils
from neutron.openstack.common import log
from neutron.plugins.nicira.api_client import exception as api_exc
from neutron.plugins.nicira.common import exceptions as nvp_exc
from neutron.plugins.nicira.common import exceptions as nsx_exc
from neutron.plugins.nicira.common import utils
from neutron.plugins.nicira.nsxlib.switch import get_port
from neutron.plugins.nicira.nsxlib.versioning import DEFAULT_VERSION
@ -427,7 +427,7 @@ def plug_router_port_attachment(cluster, router_id, port_id,
if attachment_vlan:
attach_obj['vlan_id'] = attachment_vlan
else:
raise nvp_exc.NvpInvalidAttachmentType(
raise nsx_exc.InvalidAttachmentType(
attachment_type=nsx_attachment_type)
return do_request(
HTTP_PUT, uri, jsonutils.dumps(attach_obj), cluster=cluster)
@ -556,9 +556,9 @@ def delete_nat_rules_by_match(cluster, router_id, rule_type,
to_delete_ids.append(r['uuid'])
if not (len(to_delete_ids) in
range(min_num_expected, max_num_expected + 1)):
raise nvp_exc.NvpNatRuleMismatch(actual_rules=len(to_delete_ids),
min_rules=min_num_expected,
max_rules=max_num_expected)
raise nsx_exc.NatRuleMismatch(actual_rules=len(to_delete_ids),
min_rules=min_num_expected,
max_rules=max_num_expected)
for rule_id in to_delete_ids:
delete_router_nat_rule(cluster, router_id, rule_id)
@ -597,12 +597,12 @@ def update_lrouter_port_ips(cluster, lrouter_id, lport_id,
msg = (_("Router Port %(lport_id)s not found on router "
"%(lrouter_id)s") % data)
LOG.exception(msg)
raise nvp_exc.NvpPluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
except api_exc.NsxApiException as e:
msg = _("An exception occurred while updating IP addresses on a "
"router logical port:%s") % str(e)
LOG.exception(msg)
raise nvp_exc.NvpPluginException(err_msg=msg)
raise nsx_exc.NsxPluginException(err_msg=msg)
ROUTER_FUNC_DICT = {
@ -638,7 +638,7 @@ def create_lrouter(cluster, *args, **kwargs):
if kwargs.get('distributed', None):
v = cluster.api_client.get_version()
if (v.major, v.minor) < (3, 1):
raise nvp_exc.NvpInvalidVersion(version=v)
raise nsx_exc.InvalidVersion(version=v)
return v
@ -652,7 +652,7 @@ def update_lrouter(cluster, *args, **kwargs):
if kwargs.get('routes', None):
v = cluster.api_client.get_version()
if (v.major, v.minor) < (3, 2):
raise nvp_exc.NvpInvalidVersion(version=v)
raise nsx_exc.InvalidVersion(version=v)
return v

View File

@ -20,7 +20,7 @@ from neutron.common import constants
from neutron.common import exceptions as exception
from neutron.openstack.common import log
from neutron.plugins.nicira.api_client import exception as api_exc
from neutron.plugins.nicira.common import exceptions as nvp_exc
from neutron.plugins.nicira.common import exceptions as nsx_exc
from neutron.plugins.nicira.common import utils
from neutron.plugins.nicira.nvplib import _build_uri_path
from neutron.plugins.nicira.nvplib import do_request
@ -246,7 +246,7 @@ def get_ports(cluster, networks=None, devices=None, tenants=None):
except Exception:
err_msg = _("Unable to get ports")
LOG.exception(err_msg)
raise nvp_exc.NvpPluginException(err_msg=err_msg)
raise nsx_exc.NsxPluginException(err_msg=err_msg)
return nsx_lports

View File

@ -26,7 +26,7 @@ import json
from neutron.common import exceptions as exception
from neutron.openstack.common import log
from neutron.plugins.nicira.api_client import exception as api_exc
from neutron.plugins.nicira.common import exceptions as nvp_exc
from neutron.plugins.nicira.common import exceptions as nsx_exc
LOG = log.getLogger(__name__)
@ -145,4 +145,4 @@ def do_request(*args, **kwargs):
except api_exc.ResourceNotFound:
raise exception.NotFound()
except api_exc.ReadOnlyMode:
raise nvp_exc.MaintenanceInProgress()
raise nsx_exc.MaintenanceInProgress()

View File

@ -384,13 +384,13 @@ class TestLogicalRouters(base.NsxlibTestCase):
'foo_nexthop', routes={'foo_destination': 'foo_address'})
def test_version_dependent_update_lrouter_old_versions(self):
self.assertRaises(nsx_exc.NvpInvalidVersion,
self.assertRaises(nsx_exc.InvalidVersion,
self._test_version_dependent_update_lrouter,
"2.9")
self.assertRaises(nsx_exc.NvpInvalidVersion,
self.assertRaises(nsx_exc.InvalidVersion,
self._test_version_dependent_update_lrouter,
"3.0")
self.assertRaises(nsx_exc.NvpInvalidVersion,
self.assertRaises(nsx_exc.InvalidVersion,
self._test_version_dependent_update_lrouter,
"3.1")
@ -658,7 +658,7 @@ class TestLogicalRouters(base.NsxlibTestCase):
def test_update_lrouter_port_ips_nonexistent_router_raises(self):
self.assertRaises(
nsx_exc.NvpPluginException, routerlib.update_lrouter_port_ips,
nsx_exc.NsxPluginException, routerlib.update_lrouter_port_ips,
self.fake_cluster, 'boo-router', 'boo-port', [], [])
def test_update_lrouter_port_ips_nsx_exception_raises(self):
@ -676,7 +676,7 @@ class TestLogicalRouters(base.NsxlibTestCase):
with mock.patch.object(routerlib, 'do_request', new=raise_nsx_exc):
self.assertRaises(
nsx_exc.NvpPluginException, routerlib.update_lrouter_port_ips,
nsx_exc.NsxPluginException, routerlib.update_lrouter_port_ips,
self.fake_cluster, lrouter['uuid'],
lrouter_port['uuid'], [], [])
@ -752,7 +752,7 @@ class TestLogicalRouters(base.NsxlibTestCase):
lrouter_port = routerlib.create_router_lport(
self.fake_cluster, lrouter['uuid'], 'pippo', 'neutron_port_id',
'name', True, ['192.168.0.1'], '00:11:22:33:44:55')
self.assertRaises(nsx_exc.NvpInvalidAttachmentType,
self.assertRaises(nsx_exc.InvalidAttachmentType,
routerlib.plug_router_port_attachment,
self.fake_cluster, lrouter['uuid'],
lrouter_port['uuid'], 'gw_att', 'BadType')
@ -912,7 +912,7 @@ class TestLogicalRouters(base.NsxlibTestCase):
rules = routerlib.query_nat_rules(self.fake_cluster, lrouter['uuid'])
self.assertEqual(len(rules), 3)
self.assertRaises(
nsx_exc.NvpNatRuleMismatch,
nsx_exc.NatRuleMismatch,
routerlib.delete_nat_rules_by_match,
self.fake_cluster, lrouter['uuid'],
'SomeWeirdType', 1, 1)

View File

@ -313,7 +313,7 @@ class LsnManagerTestCase(base.BaseTestCase):
def test_lsn_create_raise_api_error(self):
self.mock_lsn_api.lsn_for_network_create.side_effect = NsxApiException
self.assertRaises(p_exc.NvpPluginException,
self.assertRaises(p_exc.NsxPluginException,
self.manager.lsn_create,
mock.ANY, self.net_id)
self.mock_lsn_api.lsn_for_network_create.assert_called_once_with(
@ -412,7 +412,7 @@ class LsnManagerTestCase(base.BaseTestCase):
def test_lsn_port_create_api_exception(self):
self._test_lsn_port_create_with_exc(NsxApiException,
p_exc.NvpPluginException)
p_exc.NsxPluginException)
def test_lsn_port_delete(self):
self.manager.lsn_port_delete(mock.ANY, mock.ANY, mock.ANY)
@ -549,7 +549,7 @@ class LsnManagerTestCase(base.BaseTestCase):
p_exc.LsnNotFound(entity='lsn', entity_id=self.lsn_id))
self.manager.plugin.get_subnet.return_value = (
{'network_id': self.net_id})
self.assertRaises(p_exc.NvpPluginException,
self.assertRaises(p_exc.NsxPluginException,
self.manager.lsn_metadata_configure,
mock.ANY, self.sub_id, True)
@ -745,8 +745,8 @@ class PersistentLsnManagerTestCase(base.BaseTestCase):
def test_lsn_create_failure(self):
with mock.patch.object(
self.manager, 'lsn_save',
side_effect=p_exc.NvpPluginException(err_msg='')):
self.assertRaises(p_exc.NvpPluginException,
side_effect=p_exc.NsxPluginException(err_msg='')):
self.assertRaises(p_exc.NsxPluginException,
self.manager.lsn_create,
self.context, self.net_id)
self.assertTrue(self.mock_lsn_api.lsn_delete.call_count)
@ -831,8 +831,8 @@ class PersistentLsnManagerTestCase(base.BaseTestCase):
subnet = {'subnet_id': self.sub_id, 'mac_address': self.mac}
with mock.patch.object(
self.manager, 'lsn_port_save',
side_effect=p_exc.NvpPluginException(err_msg='')):
self.assertRaises(p_exc.NvpPluginException,
side_effect=p_exc.NsxPluginException(err_msg='')):
self.assertRaises(p_exc.NsxPluginException,
self.manager.lsn_port_create,
self.context, self.net_id, subnet)
self.assertTrue(self.mock_lsn_api.lsn_port_delete.call_count)
@ -1378,8 +1378,8 @@ class MetadataTestCase(base.BaseTestCase):
if raise_exc:
with mock.patch.object(nsx.l3_db.L3_NAT_db_mixin,
'remove_router_interface') as d:
mock_func.side_effect = p_exc.NvpPluginException(err_msg='')
self.assertRaises(p_exc.NvpPluginException,
mock_func.side_effect = p_exc.NsxPluginException(err_msg='')
self.assertRaises(p_exc.NsxPluginException,
nsx.handle_router_metadata_access,
self.plugin, mock.ANY, 'foo_router_id',
interface)

View File

@ -70,7 +70,7 @@ class NSXClusterTest(base.BaseTestCase):
def test_create_cluster_missing_required_attribute_raises(self):
opts = self.cluster_opts.copy()
opts.pop('default_tz_uuid')
self.assertRaises(exceptions.NvpInvalidClusterConfiguration,
self.assertRaises(exceptions.InvalidClusterConfiguration,
nsx_cluster.NSXCluster, **opts)
@ -172,7 +172,7 @@ class ConfigurationTest(base.BaseTestCase):
with mock.patch.object(client.NsxApiClient,
'get_version',
return_value=version.Version("3.2")):
self.assertRaises(exceptions.NvpPluginException, NeutronManager)
self.assertRaises(exceptions.NsxPluginException, NeutronManager)
def test_agentless_extensions_unmet_deps_fail(self):
q_config.parse(['--config-file', BASE_CONF_PATH,
@ -186,7 +186,7 @@ class ConfigurationTest(base.BaseTestCase):
with mock.patch.object(lsnlib,
'service_cluster_exists',
return_value=False):
self.assertRaises(exceptions.NvpPluginException,
self.assertRaises(exceptions.NsxPluginException,
NeutronManager)
def test_agent_extensions(self):