Merge "Analyze re-raised exceptions in Cisco Plugin"

This commit is contained in:
Jenkins 2013-09-01 18:32:00 +00:00 committed by Gerrit Code Review
commit 99cc8e3c7e
3 changed files with 14 additions and 38 deletions

View File

@ -269,7 +269,8 @@ def reserve_vlan(db_session, network_profile):
physical_network = alloc.physical_network
alloc.allocated = True
return (physical_network, segment_type, segment_id, "0.0.0.0")
raise q_exc.NoNetworkAvailable()
raise c_exc.NoMoreNetworkSegments(
network_profile_name=network_profile.name)
def reserve_vxlan(db_session, network_profile):
@ -297,7 +298,8 @@ def reserve_vxlan(db_session, network_profile):
alloc.allocated = True
return (physical_network, segment_type,
segment_id, get_multicast_ip(network_profile))
raise q_exc.NoNetworkAvailable()
raise c_exc.NoMoreNetworkSegments(
network_profile_name=network_profile.name)
def alloc_network(db_session, network_profile_id):
@ -310,14 +312,10 @@ def alloc_network(db_session, network_profile_id):
with db_session.begin(subtransactions=True):
network_profile = get_network_profile(db_session,
network_profile_id)
try:
if network_profile.segment_type == c_const.NETWORK_TYPE_VLAN:
return reserve_vlan(db_session, network_profile)
else:
return reserve_vxlan(db_session, network_profile)
except q_exc.NoNetworkAvailable:
raise c_exc.NoMoreNetworkSegments(
network_profile_name=network_profile.name)
if network_profile.segment_type == c_const.NETWORK_TYPE_VLAN:
return reserve_vlan(db_session, network_profile)
else:
return reserve_vxlan(db_session, network_profile)
def reserve_specific_vlan(db_session, physical_network, vlan_id):
@ -908,10 +906,7 @@ class NetworkProfile_db_mixin(object):
profile dictionary. Only these fields will be returned
:returns: network profile dictionary
"""
try:
profile = get_network_profile(context.session, id)
except exc.NoResultFound:
raise c_exc.NetworkProfileIdNotFound(profile_id=id)
profile = get_network_profile(context.session, id)
return self._make_network_profile_dict(profile, fields)
def get_network_profiles(self, context, filters=None, fields=None):
@ -1087,10 +1082,7 @@ class PolicyProfile_db_mixin(object):
profile dictionary. Only these fields will be returned
:returns: policy profile dictionary
"""
try:
profile = get_policy_profile(context.session, id)
except exc.NoResultFound:
raise c_exc.PolicyProfileIdNotFound(profile_id=id)
profile = get_policy_profile(context.session, id)
return self._make_policy_profile_dict(profile, fields)
def get_policy_profiles(self, context, filters=None, fields=None):

View File

@ -281,12 +281,7 @@ class PluginV2(db_base_plugin_v2.NeutronDbPluginV2):
def get_qos_details(self, tenant_id, qos_id):
"""Get QoS Details."""
LOG.debug(_("get_qos_details() called"))
try:
qos_level = cdb.get_qos(tenant_id, qos_id)
except Exception:
raise cexc.QosNotFound(tenant_id=tenant_id,
qos_id=qos_id)
return qos_level
return cdb.get_qos(tenant_id, qos_id)
def create_qos(self, tenant_id, qos_name, qos_desc):
"""Create a QoS level."""
@ -297,23 +292,12 @@ class PluginV2(db_base_plugin_v2.NeutronDbPluginV2):
def delete_qos(self, tenant_id, qos_id):
"""Delete a QoS level."""
LOG.debug(_("delete_qos() called"))
try:
cdb.get_qos(tenant_id, qos_id)
except Exception:
raise cexc.QosNotFound(tenant_id=tenant_id,
qos_id=qos_id)
return cdb.remove_qos(tenant_id, qos_id)
def rename_qos(self, tenant_id, qos_id, new_name):
"""Rename QoS level."""
LOG.debug(_("rename_qos() called"))
try:
cdb.get_qos(tenant_id, qos_id)
except Exception:
raise cexc.QosNotFound(tenant_id=tenant_id,
qos_id=qos_id)
qos = cdb.update_qos(tenant_id, qos_id, new_name)
return qos
return cdb.update_qos(tenant_id, qos_id, new_name)
def get_all_credentials(self):
"""Get all credentials."""

View File

@ -71,7 +71,7 @@ class CiscoNEXUSDriver():
break
else:
# Raise a Neutron exception. Include a description of
# the original ncclient exception.
# the original ncclient exception. No need to preserve T/B
raise cexc.NexusConfigFailed(config=config, exc=e)
def get_credential(self, nexus_ip):
@ -107,7 +107,7 @@ class CiscoNEXUSDriver():
self.connections[nexus_host] = man
except Exception as e:
# Raise a Neutron exception. Include a description of
# the original ncclient exception.
# the original ncclient exception. No need to preserve T/B.
raise cexc.NexusConnectFailed(nexus_host=nexus_host, exc=e)
return self.connections[nexus_host]