root / api / helpers.py @ 253f0c82
History | View | Annotate | Download (737 Bytes)
1 |
# vim: ts=4 sts=4 et ai sw=4 fileencoding=utf-8
|
---|---|
2 |
#
|
3 |
# Copyright © 2010 Greek Research and Technology Network
|
4 |
#
|
5 |
|
6 |
# XXX: most of the keys below are dummy
|
7 |
def instance_to_server(instance): |
8 |
server = { |
9 |
"id": instance["name"], |
10 |
"name": instance["name"], |
11 |
"hostId": instance["pnode"], |
12 |
"imageId": 1, |
13 |
"flavorId": 1, |
14 |
"addresses": {
|
15 |
"public": [ ],
|
16 |
"private": [ ],
|
17 |
}, |
18 |
"metadata": { }
|
19 |
} |
20 |
if instance["status"] == "running": |
21 |
server["status"] = "ACTIVE" |
22 |
elif instance["status"] == "ADMIN_down": |
23 |
server["status"] = "SUSPENDED" |
24 |
else:
|
25 |
server["status"] = "UNKNOWN" |
26 |
|
27 |
return server
|