Revision eb3c549b snf-cyclades-app/synnefo/api/images.py
b/snf-cyclades-app/synnefo/api/images.py | ||
---|---|---|
103 | 103 |
'DELETE']) |
104 | 104 |
|
105 | 105 |
|
106 |
API_STATUS_FROM_IMAGE_STATUS = { |
|
107 |
"CREATING": "SAVING", |
|
108 |
"AVAILABLE": "ACTIVE", |
|
109 |
"ERROR": "ERROR", |
|
110 |
"DELETED": "DELETED"} |
|
111 |
|
|
112 |
|
|
106 | 113 |
def image_to_dict(image, detail=True): |
107 | 114 |
d = dict(id=image['id'], name=image['name']) |
108 | 115 |
if detail: |
109 | 116 |
d['updated'] = utils.isoformat(date_parse(image['updated_at'])) |
110 | 117 |
d['created'] = utils.isoformat(date_parse(image['created_at'])) |
111 |
d['status'] = 'DELETED' if image['deleted_at'] else 'ACTIVE' |
|
112 |
d['progress'] = 100 if image['status'] == 'available' else 0 |
|
118 |
img_status = image.get("status", "").upper() |
|
119 |
status = API_STATUS_FROM_IMAGE_STATUS.get(img_status, "UNKNOWN") |
|
120 |
d['status'] = status |
|
121 |
d['progress'] = 100 if status == 'ACTIVE' else 0 |
|
113 | 122 |
d['user_id'] = image['owner'] |
114 | 123 |
d['tenant_id'] = image['owner'] |
115 | 124 |
d['links'] = util.image_to_links(image["id"]) |
Also available in: Unified diff