[Kimchi-devel] [PATCH 1/5] Update VM (mock)model to produce valid JSON for /vms

Adam King rak at linux.vnet.ibm.com
Thu Feb 20 06:04:14 UTC 2014


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

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 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}
> 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],
>
>

-- 
Adam King <rak at linux.vnet.ibm.com>
IBM C&SI





More information about the Kimchi-devel mailing list