Hi~

I'm sorry, maybe I didn't quite get your opinion.

"uri" is necessary, and it is specific to a VM object.

About class VM, I think an object of it represents a VM. But perhaps you are 
running Autotest 
on Host A, and some of your VMs are on Host B, and some are on Host C. So I 
think taking "uri" as an 
attribute of class VM is just fine. And it may be different in different VM 
object.

As you see, virsh_xxx() is not a method of VM object. It is a helper function 
called by VM.get_xxx(). 
In VM.get_xxx(), you don't need to pass a "uri" parameter, it automatically 
uses the self.connect_uri attribute. 
So users just set the VM.connect_uri, and call VM.get_xxx(). No more extra 
parameter needs to be pass.

Thanks. :)

On 02/23/2012 04:23 PM, Alex Jia wrote:
> On 02/22/2012 06:46 PM, Lucas Meneghel Rodrigues wrote:
>> On 02/22/2012 01:47 AM, tangchen wrote:
>>> Hi~
>>>
>>> Any comment on this patch?
>>> Thanks:)
>> Applied:
>>
>> https://github.com/autotest/autotest/commit/4b8e75f9f44494c47c7bd68540777ad1e30b99db
>>
>> Thanks!
>>
>>> On 02/16/2012 03:11 PM, tangchen wrote:
>>>> This patch adds 3 member functions for libvirt_vm:
>>>>       1) get_id()
>>>>       2) get_uuid()
>>>>       3) get_xml()
>>>>
>>>> Signed-off-by: Tang Chen<[email protected]>
>>>> ---
>>>>    client/virt/libvirt_vm.py |   22 ++++++++++++++++++++++
>>>>    1 files changed, 22 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/client/virt/libvirt_vm.py b/client/virt/libvirt_vm.py
>>>> index 85021d9..c7a99b5 100644
>>>> --- a/client/virt/libvirt_vm.py
>>>> +++ b/client/virt/libvirt_vm.py
>>>> @@ -106,6 +106,11 @@ def virsh_domstate(name, uri = ""):
> We instantiated class VM with 'uri' then pass it to each wrapper function,
> Is the 'uri' parameter necessary?  whether we may define a VIRSH_CMD
> class to initialize it then directly use it in each wrapper function instead 
> of
> a extra parameter?
> 
> Regards
> Alex
>>>>        """
>>>>        return virsh_cmd("domstate %s" % name, uri)
>>>>
>>>> +def virsh_domid(name, uri = ""):
>>>> +    """
>>>> +    Return VM's ID.
>>>> +    """
>>>> +    return virsh_cmd("domid %s" % (name), uri)
>>>>
>>>>    def virsh_uuid(name, uri = ""):
>>>>        """
>>>> @@ -445,6 +450,23 @@ class VM(virt_vm.BaseVM):
>>>>            """
>>>>            return virsh_domstate(self.name, self.connect_uri)
>>>>
>>>> +    def get_uuid(self):
>>>> +        """
>>>> +        Return VM's UUID.
>>>> +        """
>>>> +        return virsh_uuid(self.name, self.connect_uri)
>>>> +
>>>> +    def get_id(self):
>>>> +        """
>>>> +        Return VM's ID.
>>>> +        """
>>>> +        return virsh_domid(self.name, self.connect_uri)
>>>> +
>>>> +    def get_xml(self):
>>>> +        """
>>>> +        Return VM's xml file.
>>>> +        """
>>>> +        return virsh_dumpxml(self.name, self.connect_uri)
>>>>
>>>>        def clone(self, name=None, params=None, root_dir=None, 
>>>> address_cache=None,
>>>>                  copy_state=False):
>> _______________________________________________
>> Autotest mailing list
>> [email protected]
>> http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
> 
> 

-- 
Best Regards,
Tang chen
_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to