Introduce IncorrectState EC2 error code

'IncorrectState' ec2_code attribute was added to ImageNotActive and
VolumeUnattached exceptions.

ImageNotActive is now used instead of useless EC2APIError.

Although IncorrectState EC2 error code is used for volumes only in
Amazon EC2, it's used for incorrect image state in nova as well
because there is no error code for this (EC2 images are stateless)
and inventing new error code is a bad idea.

Implements: blueprint ec2-error-codes

Change-Id: I3566bbc4b2eb13482c93933932dd619f90cbc234
This commit is contained in:
Jakub Ruzicka
2013-08-13 10:43:18 -04:00
parent b0797c619c
commit b1c69cd8d6

View File

@@ -192,6 +192,9 @@ class PolicyNotAuthorized(NotAuthorized):
class ImageNotActive(NovaException):
# NOTE(jruzicka): IncorrectState is used for volumes only in EC2,
# but it still seems like the most appropriate option.
ec2_code = 'IncorrectState'
msg_fmt = _("Image %(image_id)s is not active.")
@@ -251,6 +254,7 @@ class InvalidAttribute(Invalid):
class VolumeUnattached(Invalid):
ec2_code = 'IncorrectState'
msg_fmt = _("Volume %(volume_id)s is not attached to anything")