diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-12-11 17:58:16 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-12-11 17:58:16 +0000 |
| commit | 5a2f8cbe52d4ec07ccf9867d567b217cdb4d11c2 (patch) | |
| tree | 50ece40116d4bfc84207c7f88b437ebdeed7009f /nova/api | |
| parent | 0111ac1dd1deb76187a13e32e20765c7bcc54bc6 (diff) | |
| parent | eed626753c23bb82453bc5176193831fbb9e538c (diff) | |
| download | nova-5a2f8cbe52d4ec07ccf9867d567b217cdb4d11c2.tar.gz nova-5a2f8cbe52d4ec07ccf9867d567b217cdb4d11c2.tar.xz nova-5a2f8cbe52d4ec07ccf9867d567b217cdb4d11c2.zip | |
Merge "Map cinder snapshot statuses to ec2."
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 26 |
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'] |
