[Kimchi-devel] [PATCH 1/5] Update VM (mock)model to produce valid JSON for /vms
Adam King
rak at linux.vnet.ibm.com
Wed Feb 19 22:10:26 UTC 2014
Current implementations of model and mock model do not produce valid JSON for /vms stats: field.
Update both to produce valid JSON.
Signed-off-by: Adam King <rak at linux.vnet.ibm.com>
---
src/kimchi/mockmodel.py | 8 +++++---
src/kimchi/model/vms.py | 2 +-
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 8ef4431..ece016e 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -915,10 +915,12 @@ class MockVM(object):
ifaces = [MockVMIface(net) for net in self.networks]
self.storagedevices = {}
self.ifaces = dict([(iface.info['mac'], iface) for iface in ifaces])
+
+ stats = {'cpu_utilization': 20, 'net_throughput' : 35,
+ 'net_throughput_peak': 100, 'io_throughput': 45,
+ 'io_throughput_peak': 100}
self.info = {'state': 'shutoff',
- 'stats': "{'cpu_utilization': 20, 'net_throughput' : 35, \
- 'net_throughput_peak': 100, 'io_throughput': 45, \
- 'io_throughput_peak': 100}",
+ 'stats': stats,
'uuid': self.uuid,
'memory': template_info['memory'],
'cpus': template_info['cpus'],
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index b482e80..9da6688 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -306,7 +306,7 @@ class VMModel(object):
res['io_throughput_peak'] = vm_stats.get('max_disk_io', 100)
return {'state': state,
- 'stats': str(res),
+ 'stats': res,
'uuid': dom.UUIDString(),
'memory': info[2] >> 10,
'cpus': info[3],
--
1.8.1.4
More information about the Kimchi-devel
mailing list