diff options
| author | Chris Yeoh <cyeoh@au1.ibm.com> | 2013-04-18 00:02:53 +0930 |
|---|---|---|
| committer | Chris Yeoh <cyeoh@au1.ibm.com> | 2013-04-18 00:02:53 +0930 |
| commit | a977294b86287ebefba6eecb48d70166b1daf0f2 (patch) | |
| tree | c4574488d9594cd5cb9f96dfc80beb72ae8943a1 /nova/image | |
| parent | 964df95013fe65d38b3675592ae02249e93d2bc5 (diff) | |
| download | nova-a977294b86287ebefba6eecb48d70166b1daf0f2.tar.gz nova-a977294b86287ebefba6eecb48d70166b1daf0f2.tar.xz nova-a977294b86287ebefba6eecb48d70166b1daf0f2.zip | |
Map internal S3 image state to EC2 API values
Fixes the EC2 API so it maps internal S3 image state values to
ones defined by the EC2 API rather than returning the internally
used values.
Fixes bug #1074904
Change-Id: Iabbda0e5fcbe4d572c76367c6f98d4bece050e73
Diffstat (limited to 'nova/image')
| -rw-r--r-- | nova/image/s3.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/nova/image/s3.py b/nova/image/s3.py index 100d80030..563864b91 100644 --- a/nova/image/s3.py +++ b/nova/image/s3.py @@ -73,6 +73,16 @@ CONF.import_opt('my_ip', 'nova.netconf') class S3ImageService(object): """Wraps an existing image service to support s3 based register.""" + # translate our internal state to states valid by the EC2 API documentation + image_state_map = {'downloading': 'pending', + 'failed_download': 'failed', + 'decrypting': 'pending', + 'failed_decrypt': 'failed', + 'untarring': 'pending', + 'failed_untar': 'failed', + 'uploading': 'pending', + 'failed_upload': 'failed', + 'available': 'available'} def __init__(self, service=None, *args, **kwargs): self.cert_rpcapi = nova.cert.rpcapi.CertAPI() @@ -101,6 +111,12 @@ class S3ImageService(object): image_id = ec2utils.glance_id_to_id(context, image_uuid) image_copy['properties'][prop] = image_id + try: + image_copy['properties']['image_state'] = self.image_state_map[ + image['properties']['image_state']] + except (KeyError, ValueError): + pass + return image_copy def _translate_id_to_uuid(self, context, image): |
