Merge "Fix exception message format error"
This commit is contained in:
commit
c1d2fa7172
@ -97,7 +97,7 @@ class OperationNotPermitted(NotAuthorized):
|
|||||||
|
|
||||||
|
|
||||||
class Forbidden(MoganException):
|
class Forbidden(MoganException):
|
||||||
msg_fmt = _("Forbidden")
|
_msg_fmt = _("Forbidden")
|
||||||
code = 403
|
code = 403
|
||||||
|
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ class InvalidMAC(Invalid):
|
|||||||
|
|
||||||
|
|
||||||
class InvalidUUID(Invalid):
|
class InvalidUUID(Invalid):
|
||||||
msg_fmt = _("Expected a uuid but received %(uuid)s.")
|
_msg_fmt = _("Expected a uuid but received %(uuid)s.")
|
||||||
|
|
||||||
|
|
||||||
class InstanceTypeAlreadyExists(MoganException):
|
class InstanceTypeAlreadyExists(MoganException):
|
||||||
@ -153,7 +153,7 @@ class InstanceTypeAlreadyExists(MoganException):
|
|||||||
|
|
||||||
|
|
||||||
class InstanceTypeNotFound(NotFound):
|
class InstanceTypeNotFound(NotFound):
|
||||||
msg_fmt = _("InstanceType %(type_id)s could not be found.")
|
_msg_fmt = _("InstanceType %(type_id)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class InstanceAlreadyExists(MoganException):
|
class InstanceAlreadyExists(MoganException):
|
||||||
@ -161,7 +161,7 @@ class InstanceAlreadyExists(MoganException):
|
|||||||
|
|
||||||
|
|
||||||
class InstanceNotFound(NotFound):
|
class InstanceNotFound(NotFound):
|
||||||
msg_fmt = _("Instance %(instance)s could not be found.")
|
_msg_fmt = _("Instance %(instance)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class ComputeNodeAlreadyExists(MoganException):
|
class ComputeNodeAlreadyExists(MoganException):
|
||||||
@ -169,7 +169,7 @@ class ComputeNodeAlreadyExists(MoganException):
|
|||||||
|
|
||||||
|
|
||||||
class ComputeNodeNotFound(NotFound):
|
class ComputeNodeNotFound(NotFound):
|
||||||
msg_fmt = _("ComputeNode %(node)s could not be found.")
|
_msg_fmt = _("ComputeNode %(node)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class ComputePortAlreadyExists(MoganException):
|
class ComputePortAlreadyExists(MoganException):
|
||||||
@ -177,7 +177,7 @@ class ComputePortAlreadyExists(MoganException):
|
|||||||
|
|
||||||
|
|
||||||
class ComputePortNotFound(NotFound):
|
class ComputePortNotFound(NotFound):
|
||||||
msg_fmt = _("ComputePort %(port)s could not be found.")
|
_msg_fmt = _("ComputePort %(port)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class ComputeDiskAlreadyExists(MoganException):
|
class ComputeDiskAlreadyExists(MoganException):
|
||||||
@ -185,25 +185,25 @@ class ComputeDiskAlreadyExists(MoganException):
|
|||||||
|
|
||||||
|
|
||||||
class ComputeDiskNotFound(NotFound):
|
class ComputeDiskNotFound(NotFound):
|
||||||
msg_fmt = _("ComputeDisk %(disk)s could not be found.")
|
_msg_fmt = _("ComputeDisk %(disk)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class NodeNotFound(NotFound):
|
class NodeNotFound(NotFound):
|
||||||
msg_fmt = _("Node associated with instance %(instance)s "
|
_msg_fmt = _("Node associated with instance %(instance)s "
|
||||||
"could not be found.")
|
"could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class InvalidActionParameterValue(Invalid):
|
class InvalidActionParameterValue(Invalid):
|
||||||
msg_fmt = _("The Parameter value: %(value)s for %(action) action of "
|
_msg_fmt = _("The Parameter value: %(value)s for %(action) action of "
|
||||||
"instance %(instance)s is invalid.")
|
"instance %(instance)s is invalid.")
|
||||||
|
|
||||||
|
|
||||||
class InstanceDeployFailure(Invalid):
|
class InstanceDeployFailure(Invalid):
|
||||||
msg_fmt = _("Failed to deploy instance: %(reason)s")
|
_msg_fmt = _("Failed to deploy instance: %(reason)s")
|
||||||
|
|
||||||
|
|
||||||
class InstanceDeployAborted(Invalid):
|
class InstanceDeployAborted(Invalid):
|
||||||
msg_fmt = _("Instance deployment is aborted: %(reason)s")
|
_msg_fmt = _("Instance deployment is aborted: %(reason)s")
|
||||||
|
|
||||||
|
|
||||||
class NoFreeEngineWorker(TemporaryFailure):
|
class NoFreeEngineWorker(TemporaryFailure):
|
||||||
@ -242,17 +242,17 @@ class NoValidNode(MoganException):
|
|||||||
|
|
||||||
|
|
||||||
class TypeExtraSpecUpdateCreateFailed(MoganException):
|
class TypeExtraSpecUpdateCreateFailed(MoganException):
|
||||||
msg_fmt = _("Instance Type %(id)s extra spec cannot be updated or"
|
_msg_fmt = _("Instance Type %(id)s extra spec cannot be updated or"
|
||||||
"created after %(retries)d retries.")
|
"created after %(retries)d retries.")
|
||||||
|
|
||||||
|
|
||||||
class InstanceTypeExtraSpecsNotFound(NotFound):
|
class InstanceTypeExtraSpecsNotFound(NotFound):
|
||||||
msg_fmt = _("Instance Type %(type_id)s has no extra specs with "
|
_msg_fmt = _("Instance Type %(type_id)s has no extra specs with "
|
||||||
"key %(extra_specs_key)s.")
|
"key %(extra_specs_key)s.")
|
||||||
|
|
||||||
|
|
||||||
class InterfacePlugException(MoganException):
|
class InterfacePlugException(MoganException):
|
||||||
msg_fmt = _("Interface plugin failed")
|
_msg_fmt = _("Interface plugin failed")
|
||||||
|
|
||||||
|
|
||||||
class NetworkError(MoganException):
|
class NetworkError(MoganException):
|
||||||
@ -260,25 +260,25 @@ class NetworkError(MoganException):
|
|||||||
|
|
||||||
|
|
||||||
class ValidationError(Invalid):
|
class ValidationError(Invalid):
|
||||||
msg_fmt = "%(detail)s"
|
_msg_fmt = "%(detail)s"
|
||||||
|
|
||||||
|
|
||||||
class ImageNotAuthorized(MoganException):
|
class ImageNotAuthorized(MoganException):
|
||||||
msg_fmt = _("Not authorized for image %(image_id)s.")
|
_msg_fmt = _("Not authorized for image %(image_id)s.")
|
||||||
|
|
||||||
|
|
||||||
class ImageBadRequest(Invalid):
|
class ImageBadRequest(Invalid):
|
||||||
msg_fmt = _("Request of image %(image_id)s got BadRequest response: "
|
_msg_fmt = _("Request of image %(image_id)s got BadRequest response: "
|
||||||
"%(response)s")
|
"%(response)s")
|
||||||
|
|
||||||
|
|
||||||
class ImageNotFound(NotFound):
|
class ImageNotFound(NotFound):
|
||||||
msg_fmt = _("Image %(image_id)s could not be found.")
|
_msg_fmt = _("Image %(image_id)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class GlanceConnectionFailed(MoganException):
|
class GlanceConnectionFailed(MoganException):
|
||||||
msg_fmt = _("Connection to glance host %(server)s failed: "
|
_msg_fmt = _("Connection to glance host %(server)s failed: "
|
||||||
"%(reason)s")
|
"%(reason)s")
|
||||||
|
|
||||||
|
|
||||||
class PatchError(Invalid):
|
class PatchError(Invalid):
|
||||||
@ -286,7 +286,7 @@ class PatchError(Invalid):
|
|||||||
|
|
||||||
|
|
||||||
class AZNotFound(NotFound):
|
class AZNotFound(NotFound):
|
||||||
msg_fmt = _("The availability zone could not be found.")
|
_msg_fmt = _("The availability zone could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class InvalidState(Invalid):
|
class InvalidState(Invalid):
|
||||||
@ -298,32 +298,32 @@ class DuplicateState(Conflict):
|
|||||||
|
|
||||||
|
|
||||||
class PortNotFound(NotFound):
|
class PortNotFound(NotFound):
|
||||||
msg_fmt = _("Port id %(port_id)s could not be found.")
|
_msg_fmt = _("Port id %(port_id)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class FloatingIpNotFoundForAddress(NotFound):
|
class FloatingIpNotFoundForAddress(NotFound):
|
||||||
msg_fmt = _("Floating IP not found for address %(address)s.")
|
_msg_fmt = _("Floating IP not found for address %(address)s.")
|
||||||
|
|
||||||
|
|
||||||
class FloatingIpMultipleFoundForAddress(MoganException):
|
class FloatingIpMultipleFoundForAddress(MoganException):
|
||||||
msg_fmt = _("Multiple floating IPs are found for address %(address)s.")
|
_msg_fmt = _("Multiple floating IPs are found for address %(address)s.")
|
||||||
|
|
||||||
|
|
||||||
class NetworkNotFound(NotFound):
|
class NetworkNotFound(NotFound):
|
||||||
msg_fmt = _("Network %(network_id)s could not be found.")
|
_msg_fmt = _("Network %(network_id)s could not be found.")
|
||||||
|
|
||||||
|
|
||||||
class NetworkRequiresSubnet(Invalid):
|
class NetworkRequiresSubnet(Invalid):
|
||||||
msg_fmt = _("Network %(network_uuid)s requires a subnet in order to boot"
|
_msg_fmt = _("Network %(network_uuid)s requires a subnet in order to boot"
|
||||||
" instances on.")
|
" instances on.")
|
||||||
|
|
||||||
|
|
||||||
class InstanceIsLocked(Invalid):
|
class InstanceIsLocked(Invalid):
|
||||||
msg_fmt = _("Instance %(instance_uuid)s is locked")
|
_msg_fmt = _("Instance %(instance_uuid)s is locked")
|
||||||
|
|
||||||
|
|
||||||
class InstanceInMaintenance(Invalid):
|
class InstanceInMaintenance(Invalid):
|
||||||
msg_fmt = _("Instance %(instance_uuid)s is in maintenance mode")
|
_msg_fmt = _("Instance %(instance_uuid)s is in maintenance mode")
|
||||||
|
|
||||||
|
|
||||||
class InvalidReservationExpiration(Invalid):
|
class InvalidReservationExpiration(Invalid):
|
||||||
@ -347,7 +347,7 @@ class OverQuota(MoganException):
|
|||||||
|
|
||||||
|
|
||||||
class PortLimitExceeded(OverQuota):
|
class PortLimitExceeded(OverQuota):
|
||||||
msg_fmt = _("Maximum number of ports exceeded")
|
_msg_fmt = _("Maximum number of ports exceeded")
|
||||||
|
|
||||||
|
|
||||||
class QuotaAlreadyExists(MoganException):
|
class QuotaAlreadyExists(MoganException):
|
||||||
@ -365,7 +365,7 @@ class ReservationNotFound(NotFound):
|
|||||||
|
|
||||||
|
|
||||||
class InvalidToken(Invalid):
|
class InvalidToken(Invalid):
|
||||||
msg_fmt = _("Invalid token: %(token)s")
|
_msg_fmt = _("Invalid token: %(token)s")
|
||||||
|
|
||||||
|
|
||||||
class ConsoleNotAvailable(MoganException):
|
class ConsoleNotAvailable(MoganException):
|
||||||
@ -373,27 +373,27 @@ class ConsoleNotAvailable(MoganException):
|
|||||||
|
|
||||||
|
|
||||||
class ConsoleTypeUnavailable(Invalid):
|
class ConsoleTypeUnavailable(Invalid):
|
||||||
msg_fmt = _("Unavailable console type %(console_type)s.")
|
_msg_fmt = _("Unavailable console type %(console_type)s.")
|
||||||
|
|
||||||
|
|
||||||
class ConfigDriveMountFailed(MoganException):
|
class ConfigDriveMountFailed(MoganException):
|
||||||
msg_fmt = _("Could not mount vfat config drive. %(operation)s failed. "
|
_msg_fmt = _("Could not mount vfat config drive. %(operation)s failed. "
|
||||||
"Error: %(error)s")
|
"Error: %(error)s")
|
||||||
|
|
||||||
|
|
||||||
class ConfigDriveUnknownFormat(MoganException):
|
class ConfigDriveUnknownFormat(MoganException):
|
||||||
msg_fmt = _("Unknown config drive format %(format)s. Select one of "
|
_msg_fmt = _("Unknown config drive format %(format)s. Select one of "
|
||||||
"iso9660 or vfat.")
|
"iso9660 or vfat.")
|
||||||
|
|
||||||
|
|
||||||
class InstanceUserDataTooLarge(MoganException):
|
class InstanceUserDataTooLarge(MoganException):
|
||||||
msg_fmt = _("User data too large. User data must be no larger than "
|
_msg_fmt = _("User data too large. User data must be no larger than "
|
||||||
"%(maxsize)s bytes once base64 encoded. Your data is "
|
"%(maxsize)s bytes once base64 encoded. Your data is "
|
||||||
"%(length)d bytes")
|
"%(length)d bytes")
|
||||||
|
|
||||||
|
|
||||||
class InstanceUserDataMalformed(MoganException):
|
class InstanceUserDataMalformed(MoganException):
|
||||||
msg_fmt = _("User data needs to be valid base 64.")
|
_msg_fmt = _("User data needs to be valid base 64.")
|
||||||
|
|
||||||
|
|
||||||
class Base64Exception(MoganException):
|
class Base64Exception(MoganException):
|
||||||
|
@ -135,7 +135,7 @@ class Connection(api.Connection):
|
|||||||
return _dict_with_extra_specs(query.one())
|
return _dict_with_extra_specs(query.one())
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
raise exception.InstanceTypeNotFound(
|
raise exception.InstanceTypeNotFound(
|
||||||
instance_type=instance_type_uuid)
|
type_id=instance_type_uuid)
|
||||||
|
|
||||||
def instance_type_update(self, context, instance_type_id, values):
|
def instance_type_update(self, context, instance_type_id, values):
|
||||||
with _session_for_write():
|
with _session_for_write():
|
||||||
@ -145,7 +145,7 @@ class Connection(api.Connection):
|
|||||||
ref = query.with_lockmode('update').one()
|
ref = query.with_lockmode('update').one()
|
||||||
except NoResultFound:
|
except NoResultFound:
|
||||||
raise exception.InstanceTypeNotFound(
|
raise exception.InstanceTypeNotFound(
|
||||||
instance_type=instance_type_id)
|
type_id=instance_type_id)
|
||||||
|
|
||||||
ref.update(values)
|
ref.update(values)
|
||||||
return ref
|
return ref
|
||||||
@ -171,7 +171,7 @@ class Connection(api.Connection):
|
|||||||
count = query.delete()
|
count = query.delete()
|
||||||
if count != 1:
|
if count != 1:
|
||||||
raise exception.InstanceTypeNotFound(
|
raise exception.InstanceTypeNotFound(
|
||||||
instance_type=instance_type_uuid)
|
type_id=instance_type_uuid)
|
||||||
|
|
||||||
def instance_create(self, context, values):
|
def instance_create(self, context, values):
|
||||||
if not values.get('uuid'):
|
if not values.get('uuid'):
|
||||||
|
@ -97,7 +97,7 @@ class IronicDriver(base_driver.BaseEngineDriver):
|
|||||||
return self.ironicclient.call('node.get_by_instance_uuid',
|
return self.ironicclient.call('node.get_by_instance_uuid',
|
||||||
instance.uuid, fields=_NODE_FIELDS)
|
instance.uuid, fields=_NODE_FIELDS)
|
||||||
except ironic_exc.NotFound:
|
except ironic_exc.NotFound:
|
||||||
raise exception.InstanceNotFound(instance_id=instance.uuid)
|
raise exception.InstanceNotFound(instance=instance.uuid)
|
||||||
|
|
||||||
def _parse_node_properties(self, node):
|
def _parse_node_properties(self, node):
|
||||||
"""Helper method to parse the node's properties."""
|
"""Helper method to parse the node's properties."""
|
||||||
@ -224,12 +224,12 @@ class IronicDriver(base_driver.BaseEngineDriver):
|
|||||||
if node.target_provision_state in (ironic_states.DELETED,
|
if node.target_provision_state in (ironic_states.DELETED,
|
||||||
ironic_states.AVAILABLE):
|
ironic_states.AVAILABLE):
|
||||||
# ironic is trying to delete it now
|
# ironic is trying to delete it now
|
||||||
raise exception.InstanceNotFound(instance_id=instance.uuid)
|
raise exception.InstanceNotFound(instance=instance.uuid)
|
||||||
|
|
||||||
if node.provision_state in (ironic_states.NOSTATE,
|
if node.provision_state in (ironic_states.NOSTATE,
|
||||||
ironic_states.AVAILABLE):
|
ironic_states.AVAILABLE):
|
||||||
# ironic already deleted it
|
# ironic already deleted it
|
||||||
raise exception.InstanceNotFound(instance_id=instance.uuid)
|
raise exception.InstanceNotFound(instance=instance.uuid)
|
||||||
|
|
||||||
if node.provision_state == ironic_states.DEPLOYFAIL:
|
if node.provision_state == ironic_states.DEPLOYFAIL:
|
||||||
# ironic failed to deploy
|
# ironic failed to deploy
|
||||||
|
@ -181,7 +181,7 @@ class ManageInstanceTestCase(mgr_utils.ServiceSetUpMixin,
|
|||||||
|
|
||||||
@manager.wrap_instance_fault
|
@manager.wrap_instance_fault
|
||||||
def failer(engine_manager, context, instance):
|
def failer(engine_manager, context, instance):
|
||||||
raise exception.InstanceNotFound(instance_id=instance['uuid'])
|
raise exception.InstanceNotFound(instance=instance['uuid'])
|
||||||
|
|
||||||
self.assertRaises(exception.InstanceNotFound, failer,
|
self.assertRaises(exception.InstanceNotFound, failer,
|
||||||
manager.EngineManager, self.context, instance=inst)
|
manager.EngineManager, self.context, instance=inst)
|
||||||
|
Loading…
Reference in New Issue
Block a user