Addressing exception.NotFound across the project
This commit is contained in:
@@ -103,9 +103,7 @@ class DbDriver(object):
|
||||
"""Create a project"""
|
||||
manager = db.user_get(context.get_admin_context(), manager_uid)
|
||||
if not manager:
|
||||
raise exception.NotFound(_("Project can't be created because "
|
||||
"manager %s doesn't exist")
|
||||
% manager_uid)
|
||||
raise exception.UserNotFound(user_id=manager_uid)
|
||||
|
||||
# description is a required attribute
|
||||
if description is None:
|
||||
@@ -119,9 +117,7 @@ class DbDriver(object):
|
||||
for member_uid in member_uids:
|
||||
member = db.user_get(context.get_admin_context(), member_uid)
|
||||
if not member:
|
||||
raise exception.NotFound(_("Project can't be created "
|
||||
"because user %s doesn't exist")
|
||||
% member_uid)
|
||||
raise exception.UserNotFound(user_id=member_uid)
|
||||
members.add(member)
|
||||
|
||||
values = {'id': name,
|
||||
@@ -154,9 +150,7 @@ class DbDriver(object):
|
||||
if manager_uid:
|
||||
manager = db.user_get(context.get_admin_context(), manager_uid)
|
||||
if not manager:
|
||||
raise exception.NotFound(_("Project can't be modified because "
|
||||
"manager %s doesn't exist") %
|
||||
manager_uid)
|
||||
raise exception.UserNotFound(user_id=manager_uid)
|
||||
values['project_manager'] = manager['id']
|
||||
if description:
|
||||
values['description'] = description
|
||||
@@ -244,8 +238,8 @@ class DbDriver(object):
|
||||
def _validate_user_and_project(self, user_id, project_id):
|
||||
user = db.user_get(context.get_admin_context(), user_id)
|
||||
if not user:
|
||||
raise exception.NotFound(_('User "%s" not found') % user_id)
|
||||
raise exception.UserNotFound(user_id=user_id)
|
||||
project = db.project_get(context.get_admin_context(), project_id)
|
||||
if not project:
|
||||
raise exception.NotFound(_('Project "%s" not found') % project_id)
|
||||
raise exception.ProjectNotFound(project_id=project_id)
|
||||
return user, project
|
||||
|
||||
@@ -202,8 +202,7 @@ class LdapDriver(object):
|
||||
self.conn.modify_s(self.__uid_to_dn(name), attr)
|
||||
return self.get_user(name)
|
||||
else:
|
||||
raise exception.NotFound(_("LDAP object for %s doesn't exist")
|
||||
% name)
|
||||
raise exception.LDAPUserNotFound(user_id=name)
|
||||
else:
|
||||
attr = [
|
||||
('objectclass', ['person',
|
||||
@@ -229,9 +228,7 @@ class LdapDriver(object):
|
||||
raise exception.Duplicate(_("Project can't be created because "
|
||||
"project %s already exists") % name)
|
||||
if not self.__user_exists(manager_uid):
|
||||
raise exception.NotFound(_("Project can't be created because "
|
||||
"manager %s doesn't exist")
|
||||
% manager_uid)
|
||||
raise exception.LDAPUserNotFound(user_id=manager_uid)
|
||||
manager_dn = self.__uid_to_dn(manager_uid)
|
||||
# description is a required attribute
|
||||
if description is None:
|
||||
@@ -240,9 +237,7 @@ class LdapDriver(object):
|
||||
if member_uids is not None:
|
||||
for member_uid in member_uids:
|
||||
if not self.__user_exists(member_uid):
|
||||
raise exception.NotFound(_("Project can't be created "
|
||||
"because user %s doesn't exist")
|
||||
% member_uid)
|
||||
raise exception.LDAPUserNotFound(user_id=member_uid)
|
||||
members.append(self.__uid_to_dn(member_uid))
|
||||
# always add the manager as a member because members is required
|
||||
if not manager_dn in members:
|
||||
@@ -265,9 +260,7 @@ class LdapDriver(object):
|
||||
attr = []
|
||||
if manager_uid:
|
||||
if not self.__user_exists(manager_uid):
|
||||
raise exception.NotFound(_("Project can't be modified because "
|
||||
"manager %s doesn't exist")
|
||||
% manager_uid)
|
||||
raise exception.LDAPUserNotFound(user_id=manager_uid)
|
||||
manager_dn = self.__uid_to_dn(manager_uid)
|
||||
attr.append((self.ldap.MOD_REPLACE, LdapDriver.project_attribute,
|
||||
manager_dn))
|
||||
@@ -347,7 +340,7 @@ class LdapDriver(object):
|
||||
def delete_user(self, uid):
|
||||
"""Delete a user"""
|
||||
if not self.__user_exists(uid):
|
||||
raise exception.NotFound(_("User %s doesn't exist") % uid)
|
||||
raise exception.LDAPUserNotFound(user_id=uid)
|
||||
self.__remove_from_all(uid)
|
||||
if FLAGS.ldap_user_modify_only:
|
||||
# Delete attributes
|
||||
@@ -477,9 +470,7 @@ class LdapDriver(object):
|
||||
if member_uids is not None:
|
||||
for member_uid in member_uids:
|
||||
if not self.__user_exists(member_uid):
|
||||
raise exception.NotFound(_("Group can't be created "
|
||||
"because user %s doesn't exist")
|
||||
% member_uid)
|
||||
raise exception.LDAPUserNotFound(user_id=member_uid)
|
||||
members.append(self.__uid_to_dn(member_uid))
|
||||
dn = self.__uid_to_dn(uid)
|
||||
if not dn in members:
|
||||
@@ -494,8 +485,7 @@ class LdapDriver(object):
|
||||
def __is_in_group(self, uid, group_dn):
|
||||
"""Check if user is in group"""
|
||||
if not self.__user_exists(uid):
|
||||
raise exception.NotFound(_("User %s can't be searched in group "
|
||||
"because the user doesn't exist") % uid)
|
||||
raise exception.LDAPUserNotFound(user_id=uid)
|
||||
if not self.__group_exists(group_dn):
|
||||
return False
|
||||
res = self.__find_object(group_dn,
|
||||
@@ -506,11 +496,9 @@ class LdapDriver(object):
|
||||
def __add_to_group(self, uid, group_dn):
|
||||
"""Add user to group"""
|
||||
if not self.__user_exists(uid):
|
||||
raise exception.NotFound(_("User %s can't be added to the group "
|
||||
"because the user doesn't exist") % uid)
|
||||
raise exception.LDAPUserNotFound(user_id=uid)
|
||||
if not self.__group_exists(group_dn):
|
||||
raise exception.NotFound(_("The group at dn %s doesn't exist") %
|
||||
group_dn)
|
||||
raise exception.LDAPGroupNotFound(group_id=group_dn)
|
||||
if self.__is_in_group(uid, group_dn):
|
||||
raise exception.Duplicate(_("User %(uid)s is already a member of "
|
||||
"the group %(group_dn)s") % locals())
|
||||
@@ -520,15 +508,12 @@ class LdapDriver(object):
|
||||
def __remove_from_group(self, uid, group_dn):
|
||||
"""Remove user from group"""
|
||||
if not self.__group_exists(group_dn):
|
||||
raise exception.NotFound(_("The group at dn %s doesn't exist")
|
||||
% group_dn)
|
||||
raise exception.LDAPGroupNotFound(group_id=group_dn)
|
||||
if not self.__user_exists(uid):
|
||||
raise exception.NotFound(_("User %s can't be removed from the "
|
||||
"group because the user doesn't exist")
|
||||
% uid)
|
||||
raise exception.LDAPUserNotFound(user_id=uid)
|
||||
if not self.__is_in_group(uid, group_dn):
|
||||
raise exception.NotFound(_("User %s is not a member of the group")
|
||||
% uid)
|
||||
raise exception.LDAPGroupMembershipNotFound(user_id=uid,
|
||||
group_id=group_dn)
|
||||
# NOTE(vish): remove user from group and any sub_groups
|
||||
sub_dns = self.__find_group_dns_with_member(group_dn, uid)
|
||||
for sub_dn in sub_dns:
|
||||
@@ -548,9 +533,7 @@ class LdapDriver(object):
|
||||
def __remove_from_all(self, uid):
|
||||
"""Remove user from all roles and projects"""
|
||||
if not self.__user_exists(uid):
|
||||
raise exception.NotFound(_("User %s can't be removed from all "
|
||||
"because the user doesn't exist")
|
||||
% uid)
|
||||
raise exception.LDAPUserNotFound(user_id=uid)
|
||||
role_dns = self.__find_group_dns_with_member(
|
||||
FLAGS.role_project_subtree, uid)
|
||||
for role_dn in role_dns:
|
||||
@@ -563,8 +546,7 @@ class LdapDriver(object):
|
||||
def __delete_group(self, group_dn):
|
||||
"""Delete Group"""
|
||||
if not self.__group_exists(group_dn):
|
||||
raise exception.NotFound(_("Group at dn %s doesn't exist")
|
||||
% group_dn)
|
||||
raise exception.LDAPGroupNotFound(group_id=group_dn)
|
||||
self.conn.delete_s(group_dn)
|
||||
|
||||
def __delete_roles(self, project_dn):
|
||||
|
||||
@@ -270,8 +270,7 @@ class AuthManager(object):
|
||||
LOG.debug('user: %r', user)
|
||||
if user is None:
|
||||
LOG.audit(_("Failed authorization for access key %s"), access_key)
|
||||
raise exception.NotFound(_('No user found for access key %s')
|
||||
% access_key)
|
||||
raise exception.AccessKeyNotFound(access_key=access_key)
|
||||
|
||||
# NOTE(vish): if we stop using project name as id we need better
|
||||
# logic to find a default project for user
|
||||
@@ -285,8 +284,7 @@ class AuthManager(object):
|
||||
uname = user.name
|
||||
LOG.audit(_("failed authorization: no project named %(pjid)s"
|
||||
" (user=%(uname)s)") % locals())
|
||||
raise exception.NotFound(_('No project called %s could be found')
|
||||
% project_id)
|
||||
raise exception.ProjectNotFound(project_id=project_id)
|
||||
if not self.is_admin(user) and not self.is_project_member(user,
|
||||
project):
|
||||
uname = user.name
|
||||
@@ -295,8 +293,8 @@ class AuthManager(object):
|
||||
pjid = project.id
|
||||
LOG.audit(_("Failed authorization: user %(uname)s not admin"
|
||||
" and not member of project %(pjname)s") % locals())
|
||||
raise exception.NotFound(_('User %(uid)s is not a member of'
|
||||
' project %(pjid)s') % locals())
|
||||
raise exception.ProjectMembershipNotFound(project_id=pjid,
|
||||
user_id=uid)
|
||||
if check_type == 's3':
|
||||
sign = signer.Signer(user.secret.encode())
|
||||
expected_signature = sign.s3_authorization(headers, verb, path)
|
||||
@@ -420,9 +418,9 @@ class AuthManager(object):
|
||||
@param project: Project in which to add local role.
|
||||
"""
|
||||
if role not in FLAGS.allowed_roles:
|
||||
raise exception.NotFound(_("The %s role can not be found") % role)
|
||||
raise exception.UserRoleNotFound(role_id=role)
|
||||
if project is not None and role in FLAGS.global_roles:
|
||||
raise exception.NotFound(_("The %s role is global only") % role)
|
||||
raise exception.GlobalRoleNotAllowed(role_id=role)
|
||||
uid = User.safe_id(user)
|
||||
pid = Project.safe_id(project)
|
||||
if project:
|
||||
|
||||
@@ -52,22 +52,6 @@ class ApiError(Error):
|
||||
super(ApiError, self).__init__('%s: %s' % (code, message))
|
||||
|
||||
|
||||
class NotFound(Error):
|
||||
pass
|
||||
|
||||
|
||||
class InstanceNotFound(NotFound):
|
||||
def __init__(self, message, instance_id):
|
||||
self.instance_id = instance_id
|
||||
super(InstanceNotFound, self).__init__(message)
|
||||
|
||||
|
||||
class VolumeNotFound(NotFound):
|
||||
def __init__(self, message, volume_id):
|
||||
self.volume_id = volume_id
|
||||
super(VolumeNotFound, self).__init__(message)
|
||||
|
||||
|
||||
class Duplicate(Error):
|
||||
pass
|
||||
|
||||
@@ -160,6 +144,10 @@ class InstanceNotSuspended(Invalid):
|
||||
message = _("Instance %(instance_id)s is not suspended.")
|
||||
|
||||
|
||||
class InstanceNotInRescueMode(Invalid):
|
||||
message = _("Instance %(instance_id)s is not in rescue mode")
|
||||
|
||||
|
||||
class InstanceSuspendFailure(Invalid):
|
||||
message = _("Failed to suspend instance") + ": %(reason)s"
|
||||
|
||||
@@ -223,5 +211,276 @@ class InvalidVLANPortGroup(Invalid):
|
||||
"is %(actual)s.")
|
||||
|
||||
|
||||
class InvalidDiskFormat(Invalid):
|
||||
message = _("Disk format %(disk_format)s is not acceptable")
|
||||
|
||||
|
||||
class ImageUnacceptable(Invalid):
|
||||
message = _("Image %(image_id)s is unacceptable") + ": %(reason)s"
|
||||
|
||||
|
||||
class InstanceUnacceptable(Invalid):
|
||||
message = _("Instance %(instance_id)s is unacceptable") + ": %(reason)s"
|
||||
|
||||
|
||||
class NotFound(NovaException):
|
||||
message = _("Resource could not be found.")
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(NotFound, self).__init__(**kwargs)
|
||||
|
||||
|
||||
class InstanceNotFound(NotFound):
|
||||
message = _("Instance %(instance_id)s could not be found.")
|
||||
|
||||
|
||||
class VolumeNotFound(NotFound):
|
||||
message = _("Volume %(volume_id)s could not be found.")
|
||||
|
||||
|
||||
class VolumeNotFoundForInstance(VolumeNotFound):
|
||||
message = _("Volume not found for instance %(instance_id)s.")
|
||||
|
||||
|
||||
class ExportDeviceNotFoundForVolume(NotFound):
|
||||
message = _("No export device found for volume %(volume_id)s.")
|
||||
|
||||
|
||||
class ISCSITargetNotFoundForVolume(NotFound):
|
||||
message = _("No target id found for volume %(volume_id)s.")
|
||||
|
||||
|
||||
class DiskNotFound(NotFound):
|
||||
message = _("No disk at %(location)s")
|
||||
|
||||
|
||||
class ImageNotFound(NotFound):
|
||||
message = _("Image %(image_id)s could not be found.")
|
||||
|
||||
|
||||
class KernelNotFoundForImage(ImageNotFound):
|
||||
message = _("Kernel not found for image %(image_id)s.")
|
||||
|
||||
|
||||
class RamdiskNotFoundForImage(ImageNotFound):
|
||||
message = _("Ramdisk not found for image %(image_id)s.")
|
||||
|
||||
|
||||
class UserNotFound(NotFound):
|
||||
message = _("User %(user_id)s could not be found.")
|
||||
|
||||
|
||||
class ProjectNotFound(NotFound):
|
||||
message = _("Project %(project_id)s could not be found.")
|
||||
|
||||
|
||||
class ProjectMembershipNotFound(NotFound):
|
||||
message = _("User %(user_id)s is not a member of project %(project_id)s.")
|
||||
|
||||
|
||||
class UserRoleNotFound(NotFound):
|
||||
message = _("Role %(role_id)s could not be found.")
|
||||
|
||||
|
||||
class StorageRepositoryNotFound(NotFound):
|
||||
message = _("Cannot find SR to read/write VDI.")
|
||||
|
||||
|
||||
class NetworkNotFound(NotFound):
|
||||
message = _("Network %(network_id)s could not be found.")
|
||||
|
||||
|
||||
class NetworkNotFoundForBridge(NetworkNotFound):
|
||||
message = _("Network could not be found for bridge %(bridge)s")
|
||||
|
||||
|
||||
class NetworkNotFoundForCidr(NetworkNotFound):
|
||||
message = _("Network could not be found with cidr %(cidr)s.")
|
||||
|
||||
|
||||
class NetworkNotFoundForInstance(NetworkNotFound):
|
||||
message = _("Network could not be found for instance %(instance_id)s.")
|
||||
|
||||
|
||||
class NoNetworksFound(NotFound):
|
||||
message = _("No networks defined.")
|
||||
|
||||
|
||||
class DatastoreNotFound(NotFound):
|
||||
message = _("Could not find the datastore reference(s) which the VM uses.")
|
||||
|
||||
|
||||
class NoFixedIpsFoundForInstance(NotFound):
|
||||
message = _("Instance %(instance_id)s has zero fixed ips.")
|
||||
|
||||
|
||||
class FloatingIpNotFound(NotFound):
|
||||
message = _("Floating ip not found for fixed address %(fixed_ip)s.")
|
||||
|
||||
|
||||
class NoFloatingIpsDefined(NotFound):
|
||||
message = _("Zero floating ips could be found.")
|
||||
|
||||
|
||||
class NoFloatingIpsDefinedForHost(NoFloatingIpsDefined):
|
||||
message = _("Zero floating ips defined for host %(host)s.")
|
||||
|
||||
|
||||
class NoFloatingIpsDefinedForInstance(NoFloatingIpsDefined):
|
||||
message = _("Zero floating ips defined for instance %(instance_id)s.")
|
||||
|
||||
|
||||
class KeypairNotFound(NotFound):
|
||||
message = _("Keypair %(keypair_name)s not found for user %(user_id)s")
|
||||
|
||||
|
||||
class CertificateNotFound(NotFound):
|
||||
message = _("Certificate %(certificate_id)s not found.")
|
||||
|
||||
|
||||
class ServiceNotFound(NotFound):
|
||||
message = _("Service %(service_id)s could not be found.")
|
||||
|
||||
|
||||
class HostNotFound(NotFound):
|
||||
message = _("Host %(host)s could not be found.")
|
||||
|
||||
|
||||
class ComputeHostNotFound(HostNotFound):
|
||||
message = _("Compute host %(host)s could not be found.")
|
||||
|
||||
|
||||
class HostBinaryNotFound(NotFound):
|
||||
message = _("Could not find binary %(binary)s on host %(host)s.")
|
||||
|
||||
|
||||
class AuthTokenNotFound(NotFound):
|
||||
message = _("Auth token %(token)s could not be found.")
|
||||
|
||||
|
||||
class AccessKeyNotFound(NotFound):
|
||||
message = _("Access Key %(access_key)s could not be found.")
|
||||
|
||||
|
||||
class QuotaNotFound(NotFound):
|
||||
message = _("Quota could not be found")
|
||||
|
||||
|
||||
class ProjectQuotaNotFound(QuotaNotFound):
|
||||
message = _("Quota for project %(project_id)s could not be found.")
|
||||
|
||||
|
||||
class SecurityGroupNotFound(NotFound):
|
||||
message = _("Security group %(security_group_id)s not found.")
|
||||
|
||||
|
||||
class SecurityGroupNotFoundForProject(SecurityGroupNotFound):
|
||||
message = _("Security group %(security_group_id)s not found "
|
||||
"for project %(project_id)s.")
|
||||
|
||||
|
||||
class SecurityGroupNotFoundForRule(SecurityGroupNotFound):
|
||||
message = _("Security group with rule %(rule_id)s not found.")
|
||||
|
||||
|
||||
class MigrationNotFound(NotFound):
|
||||
message = _("Migration %(migration_id)s could not be found.")
|
||||
|
||||
|
||||
class MigrationNotFoundByStatus(MigrationNotFound):
|
||||
message = _("Migration not found for instance %(instance_id)s "
|
||||
"with status %(status)s.")
|
||||
|
||||
|
||||
class ConsolePoolNotFound(NotFound):
|
||||
message = _("Console pool %(pool_id)s could not be found.")
|
||||
|
||||
|
||||
class ConsolePoolNotFoundForHostType(NotFound):
|
||||
message = _("Console pool of type %(console_type)s "
|
||||
"for compute host %(compute_host)s "
|
||||
"on proxy host %(host)s not found.")
|
||||
|
||||
|
||||
class ConsoleNotFound(NotFound):
|
||||
message = _("Console %(console_id)s could not be found.")
|
||||
|
||||
|
||||
class ConsoleNotFoundForInstance(ConsoleNotFound):
|
||||
message = _("Console for instance %(instance_id)s could not be found.")
|
||||
|
||||
|
||||
class ConsoleNotFoundInPoolForInstance(ConsoleNotFound):
|
||||
message = _("Console for instance %(instance_id)s "
|
||||
"in pool %(pool_id)s could not be found.")
|
||||
|
||||
|
||||
class NoInstanceTypesFound(NotFound):
|
||||
message = _("Zero instance types found.")
|
||||
|
||||
|
||||
class InstanceTypeNotFound(NotFound):
|
||||
message = _("Instance type %(instance_type_id)s could not be found.")
|
||||
|
||||
|
||||
class InstanceTypeNotFoundByName(InstanceTypeNotFound):
|
||||
message = _("Instance type with name %(instance_type_name)s "
|
||||
"could not be found.")
|
||||
|
||||
|
||||
class FlavorNotFound(NotFound):
|
||||
message = _("Flavor %(flavor_id)s could not be found.")
|
||||
|
||||
|
||||
class ZoneNotFound(NotFound):
|
||||
message = _("Zone %(zone_id)s could not be found.")
|
||||
|
||||
|
||||
class InstanceMetadataNotFound(NotFound):
|
||||
message = _("Instance %(instance_id)s has no metadata with "
|
||||
"key %(metadata_key)s.")
|
||||
|
||||
|
||||
class LDAPObjectNotFound(NotFound):
|
||||
message = _("LDAP object could not be found")
|
||||
|
||||
|
||||
class LDAPUserNotFound(LDAPObjectNotFound):
|
||||
message = _("LDAP user %(user_id)s could not be found.")
|
||||
|
||||
|
||||
class LDAPGroupNotFound(LDAPObjectNotFound):
|
||||
message = _("LDAP group %(group_id)s could not be found.")
|
||||
|
||||
|
||||
class LDAPGroupMembershipNotFound(NotFound):
|
||||
message = _("LDAP user %(user_id)s is not a member of group %(group_id)s.")
|
||||
|
||||
|
||||
class FileNotFound(NotFound):
|
||||
message = _("File %(file_path)s could not be found.")
|
||||
|
||||
|
||||
class NoFilesFound(NotFound):
|
||||
message = _("Zero files could be found.")
|
||||
|
||||
|
||||
class SwitchNotFoundForNetworkAdapter(NotFound):
|
||||
message = _("Virtual switch associated with the "
|
||||
"network adapter %(adapter)s not found.")
|
||||
|
||||
|
||||
class NetworkAdapterNotFound(NotFound):
|
||||
message = _("Network adapter %(adapter)s could not be found.")
|
||||
|
||||
|
||||
class ClassNotFound(NotFound):
|
||||
message = _("Class %(class_name)s could not be found")
|
||||
|
||||
|
||||
class NotAllowed(NovaException):
|
||||
message = _("Action not allowed.")
|
||||
|
||||
|
||||
class GlobalRoleNotAllowed(NotAllowed):
|
||||
message = _("Unable to use global role %(role_id)s")
|
||||
|
||||
@@ -120,12 +120,11 @@ class SchedulerTestCase(test.TestCase):
|
||||
dest = 'dummydest'
|
||||
ctxt = context.get_admin_context()
|
||||
|
||||
try:
|
||||
scheduler.show_host_resources(ctxt, dest)
|
||||
except exception.NotFound, e:
|
||||
c1 = (e.message.find(_("does not exist or is not a "
|
||||
"compute node.")) >= 0)
|
||||
self.assertTrue(c1)
|
||||
self.assertRaises(exception.NotFound, scheduler.show_host_resources,
|
||||
ctxt, dest)
|
||||
#TODO(bcwaldon): reimplement this functionality
|
||||
#c1 = (e.message.find(_("does not exist or is not a "
|
||||
# "compute node.")) >= 0)
|
||||
|
||||
def _dic_is_equal(self, dic1, dic2, keys=None):
|
||||
"""Compares 2 dictionary contents(Helper method)"""
|
||||
@@ -941,7 +940,7 @@ class FakeRerouteCompute(api.reroute_compute):
|
||||
|
||||
|
||||
def go_boom(self, context, instance):
|
||||
raise exception.InstanceNotFound("boom message", instance)
|
||||
raise exception.InstanceNotFound(instance_id=instance)
|
||||
|
||||
|
||||
def found_instance(self, context, instance):
|
||||
@@ -990,11 +989,8 @@ class ZoneRedirectTest(test.TestCase):
|
||||
def test_routing_flags(self):
|
||||
FLAGS.enable_zone_routing = False
|
||||
decorator = FakeRerouteCompute("foo")
|
||||
try:
|
||||
result = decorator(go_boom)(None, None, 1)
|
||||
self.assertFail(_("Should have thrown exception."))
|
||||
except exception.InstanceNotFound, e:
|
||||
self.assertEquals(e.message, 'boom message')
|
||||
self.assertRaises(exception.InstanceNotFound, decorator(go_boom),
|
||||
None, None, 1)
|
||||
|
||||
def test_get_collection_context_and_id(self):
|
||||
decorator = api.reroute_compute("foo")
|
||||
|
||||
@@ -142,7 +142,7 @@ class VolumeTestCase(test.TestCase):
|
||||
self.assertEqual(vol['status'], "available")
|
||||
|
||||
self.volume.delete_volume(self.context, volume_id)
|
||||
self.assertRaises(exception.Error,
|
||||
self.assertRaises(exception.VolumeNotFound,
|
||||
db.volume_get,
|
||||
self.context,
|
||||
volume_id)
|
||||
|
||||
@@ -63,7 +63,7 @@ def import_class(import_str):
|
||||
return getattr(sys.modules[mod_str], class_str)
|
||||
except (ImportError, ValueError, AttributeError), exc:
|
||||
LOG.debug(_('Inner Exception: %s'), exc)
|
||||
raise exception.NotFound(_('Class %s cannot be found') % class_str)
|
||||
raise exception.ClassNotFound(class_name=class_str)
|
||||
|
||||
|
||||
def import_object(import_str):
|
||||
|
||||
Reference in New Issue
Block a user