summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorMichael Still <mikal@stillhq.com>2012-11-20 16:51:40 +1100
committerMichael Still <michael.still@canonical.com>2012-12-11 07:57:17 +1100
commiteed626753c23bb82453bc5176193831fbb9e538c (patch)
treee3dbe966ea5682e1fadf0c78fe92aa5a809b37d6 /nova/api
parent2f962f50e472505a86782d0fc44a0b6cfd67813d (diff)
Map cinder snapshot statuses to ec2.
EC2 has way fewer statuses than cinder does, so we need to map them to valid entries. Resolves bug 1080284. DocImpact. Change-Id: I73bb2905577fb6f727c0a805df2654ad1bb4ad72
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/cloud.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 8155efb10..796505b57 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -345,14 +345,34 @@ class CloudController(object):
snapshots.append(snapshot)
else:
snapshots = self.volume_api.get_all_snapshots(context)
- snapshots = [self._format_snapshot(context, s) for s in snapshots]
- return {'snapshotSet': snapshots}
+
+ formatted_snapshots = []
+ for s in snapshots:
+ formatted = self._format_snapshot(context, s)
+ if formatted:
+ formatted_snapshots.append(formatted)
+ return {'snapshotSet': formatted_snapshots}
def _format_snapshot(self, context, snapshot):
+ # NOTE(mikal): this is just a set of strings in cinder. If they
+ # implement an enum, then we should move this code to use it. The
+ # valid ec2 statuses are "pending", "completed", and "error".
+ status_map = {'new': 'pending',
+ 'creating': 'pending',
+ 'available': 'completed',
+ 'active': 'completed',
+ 'deleting': 'pending',
+ 'deleted': None,
+ 'error': 'error'}
+
+ mapped_status = status_map.get(snapshot['status'], snapshot['status'])
+ if not mapped_status:
+ return None
+
s = {}
s['snapshotId'] = ec2utils.id_to_ec2_snap_id(snapshot['id'])
s['volumeId'] = ec2utils.id_to_ec2_vol_id(snapshot['volume_id'])
- s['status'] = snapshot['status']
+ s['status'] = mapped_status
s['startTime'] = snapshot['created_at']
s['progress'] = snapshot['progress']
s['ownerId'] = snapshot['project_id']