Skip to content

Commit defb21b

Browse files
committed
Implements: #1353
1 parent 0324b67 commit defb21b

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

IM/Stats.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,16 @@ def _get_data(str_data, auth=None):
5757
resp['cloud_type'] = None
5858
resp['cloud_host'] = None
5959
resp['hybrid'] = False
60-
for vm_data in dic['vm_list']:
60+
for str_vm_data in dic['vm_list']:
61+
vm_data = json.loads(str_vm_data)
62+
cloud_data = json.loads(vm_data["cloud"])
6163

6264
# only get the cloud of the first VM
6365
if not resp['cloud_type']:
64-
resp['cloud_type'] = vm_data["cloud"]["type"]
66+
resp['cloud_type'] = cloud_data["type"]
6567
if not resp['cloud_host']:
66-
resp['cloud_host'] = vm_data["cloud"]["server"]
67-
elif resp['cloud_host'] != vm_data["cloud"]["server"]:
68+
resp['cloud_host'] = cloud_data["server"]
69+
elif resp['cloud_host'] != cloud_data["server"]:
6870
resp['hybrid'] = True
6971

7072
vm_sys = parse_radl(vm_data['info']).systems[0]

test/unit/test_im_logic.py

+2-14
Original file line numberDiff line numberDiff line change
@@ -1411,20 +1411,8 @@ def test_get_stats(self, check_auth_data, DataBase):
14111411
"creation_date": 1646655374,
14121412
"extra_info": {"TOSCA": yaml.dump({"metadata": {"icon": "kubernetes.png"}})},
14131413
"vm_list": [
1414-
{
1415-
"cloud": {
1416-
"type": "OSCAR",
1417-
"server": "sharp-elbakyan5.im.grycap.net",
1418-
},
1419-
"info": radl
1420-
},
1421-
{
1422-
"cloud": {
1423-
"type": "OSCAR",
1424-
"server": "sharp-elbakyan5.im.grycap.net",
1425-
},
1426-
"info": radl
1427-
}
1414+
json.dumps({"cloud": '{"type": "OSCAR", "server": "sharp-elbakyan5.im.grycap.net"}', "info": radl}),
1415+
json.dumps({"cloud": '{"type": "OSCAR", "server": "sharp-elbakyan5.im.grycap.net"}', "info": radl})
14281416
]
14291417
}
14301418
db.select.return_value = [(json.dumps(inf_data), '2022-03-23', '1')]

0 commit comments

Comments
 (0)