
On 02/20/2014 02:04 PM, Adam King wrote:
Thanks for the review Sheldon. When I ran pep8 I found many violations in mockmodel.py. Rather than combine the pep8 change with my functional update, I made all the pep8 changes and submitted a pep8 patch for mockmodel.py
That's great you fix all the pep8 of src/kimchi/mockmodel.py And I find pep8 fix patch based on this patch. But I'm afraid some one can not apply this patch, for there are some whitespace in this patch. $ git am JSONfor_vms.eml Applying: Update VM (mock)model to produce valid JSON for /vms /home/shhfeng/work/workdir/kimchi/.git/rebase-apply/patch:14: trailing whitespace. warning: 1 line adds whitespace errors. For this whitespace, you can set your git as follow. $ git config --global color.ui auto Then git will show your whitespace in a different color.
On 2/19/2014 9:58 PM, Sheldon wrote:
On 02/20/2014 06:10 AM, Adam King wrote:
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@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} indentation to comply with PEP8
if you use VI, here is document about PEP8 check. https://github.com/kimchi-project/kimchi/wiki/PEP8-Checking-Using-Syntastic
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],
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center