Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
synnefo
Commits
5dc49413
Commit
5dc49413
authored
Jan 30, 2014
by
Christos Stavrakakis
Browse files
cyclades: Update the status of images
Update the 'status' of images as returned in the Compute and Plankton API.
parent
dc40be43
Changes
3
Show whitespace changes
Inline
Side-by-side
snf-cyclades-app/synnefo/api/images.py
View file @
5dc49413
...
...
@@ -103,13 +103,22 @@ def metadata_item_demux(request, image_id, key):
'DELETE'
])
API_STATUS_FROM_IMAGE_STATUS
=
{
"CREATING"
:
"SAVING"
,
"AVAILABLE"
:
"ACTIVE"
,
"ERROR"
:
"ERROR"
,
"DELETED"
:
"DELETED"
}
def
image_to_dict
(
image
,
detail
=
True
):
d
=
dict
(
id
=
image
[
'id'
],
name
=
image
[
'name'
])
if
detail
:
d
[
'updated'
]
=
utils
.
isoformat
(
date_parse
(
image
[
'updated_at'
]))
d
[
'created'
]
=
utils
.
isoformat
(
date_parse
(
image
[
'created_at'
]))
d
[
'status'
]
=
'DELETED'
if
image
[
'deleted_at'
]
else
'ACTIVE'
d
[
'progress'
]
=
100
if
image
[
'status'
]
==
'available'
else
0
img_status
=
image
.
get
(
"status"
,
""
).
upper
()
status
=
API_STATUS_FROM_IMAGE_STATUS
.
get
(
img_status
,
"UNKNOWN"
)
d
[
'status'
]
=
status
d
[
'progress'
]
=
100
if
status
==
'ACTIVE'
else
0
d
[
'user_id'
]
=
image
[
'owner'
]
d
[
'tenant_id'
]
=
image
[
'owner'
]
d
[
'links'
]
=
util
.
image_to_links
(
image
[
"id"
])
...
...
snf-cyclades-app/synnefo/plankton/backend.py
View file @
5dc49413
...
...
@@ -536,6 +536,8 @@ def image_to_dict(location, metadata, permissions):
key
=
key
.
replace
(
PLANKTON_PREFIX
,
""
)
# Keep only those in plankton metadata
if
key
in
PLANKTON_META
:
if
key
==
"status"
:
image
[
"status"
]
=
val
.
upper
()
if
key
!=
"created_at"
:
# created timestamp is return in 'created_at' field
image
[
key
]
=
val
...
...
snf-cyclades-app/synnefo/plankton/views.py
View file @
5dc49413
...
...
@@ -62,7 +62,8 @@ LIST_FIELDS = ('status', 'name', 'disk_format', 'container_format', 'size',
DETAIL_FIELDS
=
(
'name'
,
'disk_format'
,
'container_format'
,
'size'
,
'checksum'
,
'location'
,
'created_at'
,
'updated_at'
,
'deleted_at'
,
'status'
,
'is_public'
,
'owner'
,
'properties'
,
'id'
,
"is_snapshot"
)
'status'
,
'is_public'
,
'owner'
,
'properties'
,
'id'
,
"is_snapshot"
)
ADD_FIELDS
=
(
'name'
,
'id'
,
'store'
,
'disk_format'
,
'container_format'
,
'size'
,
'checksum'
,
'is_public'
,
'owner'
,
'properties'
,
'location'
)
...
...
@@ -80,6 +81,12 @@ STORE_TYPES = ('pithos')
log
=
getLogger
(
'synnefo.plankton'
)
API_STATUS_FROM_IMAGE_STATUS
=
{
"CREATING"
:
"SAVING"
,
"AVAILABLE"
:
"ACTIVE"
,
"DELETED"
:
"DELETED"
}
def
_create_image_response
(
image
):
response
=
HttpResponse
()
...
...
@@ -88,6 +95,12 @@ def _create_image_response(image):
for
k
,
v
in
image
.
get
(
'properties'
,
{}).
items
():
name
=
'x-image-meta-property-'
+
k
.
replace
(
'_'
,
'-'
)
response
[
name
]
=
uenc
(
v
)
else
:
if
key
==
"status"
:
img_status
=
image
.
get
(
key
,
""
).
upper
()
status
=
API_STATUS_FROM_IMAGE_STATUS
.
get
(
img_status
,
"UNKNOWN"
)
response
[
"x-image-meta-status"
]
=
status
else
:
name
=
'x-image-meta-'
+
key
.
replace
(
'_'
,
'-'
)
response
[
name
]
=
uenc
(
image
.
get
(
key
,
''
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment