[Kimchi-devel] [PATCH 2/5] Store qemu user name in class attribute
Aline Manera
alinefm at linux.vnet.ibm.com
Wed Jun 11 16:57:05 UTC 2014
On 06/10/2014 07:26 AM, Sheldon wrote:
> Just a minor inline comment below
>
> On 06/10/2014 06:06 PM, lvroyce at linux.vnet.ibm.com wrote:
>> From: Royce Lv <lvroyce at linux.vnet.ibm.com>
>>
>> To prevent qemu user be probed multiple times,
>> store it in class attribute so that next time we don't need to create
>> vm.
>>
>> Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
>> Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
>> ---
>> src/kimchi/kvmusertests.py | 22 ++++++++++++----------
>> 1 file changed, 12 insertions(+), 10 deletions(-)
>>
>> diff --git a/src/kimchi/kvmusertests.py b/src/kimchi/kvmusertests.py
>> index 4884ccf..30c287a 100644
>> --- a/src/kimchi/kvmusertests.py
>> +++ b/src/kimchi/kvmusertests.py
>> @@ -37,14 +37,16 @@ class UserTests(object):
>> <boot dev='hd'/>
>> </os>
>> </domain>"""
>> + user = None
>> + @classmethod
>> + def probe_user(cls):
>> + if cls.user:
> pip8 recommends
> if cls.user is not None:
You should run "make check-local" to avoid those problems
>> + return cls.user
>>
>> - def __init__(self):
>> - self.vm_uuid = uuid.uuid1()
>> - self.vm_name = "kimchi_test_%s" % self.vm_uuid
>> + vm_uuid = uuid.uuid1()
>> + vm_name = "kimchi_test_%s" % vm_uuid
>>
>> - def probe_user(self):
>> - xml = self.SIMPLE_VM_XML % (self.vm_name, self.vm_uuid)
>> - user = None
>> + xml = cls.SIMPLE_VM_XML % (vm_name, vm_uuid)
>> with RollbackContext() as rollback:
>> conn = libvirt.open('qemu:///system')
>> rollback.prependDefer(conn.close)
>> @@ -52,7 +54,7 @@ class UserTests(object):
>> rollback.prependDefer(dom.undefine)
>> dom.create()
>> rollback.prependDefer(dom.destroy)
>> - with open('/var/run/libvirt/qemu/%s.pid' % self.vm_name)
>> as f:
>> + with open('/var/run/libvirt/qemu/%s.pid' % vm_name) as f:
>> pidStr = f.read()
>> p = psutil.Process(int(pidStr))
>>
>> @@ -60,11 +62,11 @@ class UserTests(object):
>> # in psutil 2.0 and above versions, username will be a
>> method,
>> # not a string
>> if callable(p.username):
>> - user = p.username()
>> + cls.user = p.username()
>> else:
>> - user = p.username
>> + cls.user = p.username
>>
>> - return user
>> + return cls.user
>>
>>
>> if __name__ == '__main__':
>
>
More information about the Kimchi-devel
mailing list