On 08/31/2012 01:38 AM, Yu Mingfei wrote:
On 31/08/12 10:59, Tang Chen wrote:
Hi Chris,
Referred to your comments for net_create tests, I think we can
do the job like following.
1. Construct the class inherit tree like the following.
LibvirtXML(XMLTreeFile)
|
|------VMXML(LibvirtXML)
| |
| |------VMInterfaceXML(VMXML)
| |------VMDiskXML(VMXML)
| |------VMControllerXML(VMXML)
| |------......
|
|------NetworkXML(LibvirtXML)
|
|------StorageXML(LibvirtXML)
|
|------......
Good tree, simple config of Libvirt XML in these classes is more clear.
If we need, we can use these class in tests or other modules directly.
2. Make VMXML object as a member of class VM in libvirt_vm.py.
1) Remove all xml related function in class VM.
2) Initialize VMXML object with dumpxml command when VM object
is initialized.
Well, since class VM should include all vm's operations,
xml operation can be a member of it.
I like your way of thinking.
If we separate VMXML with VM class, when we need both them, duplicate
parse of dumpxml will happen.
3) Modify all functions like vm.attach-interface() to update
VMXML object when they modifise the vm's configuration.
How do you think about this?
I will raise an issue on github for this topic.
--
Best Regards
Yu Mingfei
Yes, any way we can simplify libvirt_vm class by moving XML related
stuff to libvirt_xml classes is good. If we keep a relatively flat
class structure it will help a lot. In the future adding marshal(*)
methods will be much easier. It doesn't preclude the xml classes from
containing or returning one another, where that makes sense.
*marshal: Fancy way of saying 'convert'. For example:
class VMXML(LibvirtXMLBase):
...
@classmethod
marshal(cls, vm):
"""Convert vm instance into VMXML instance"""
...
class VM(virt_vm.BaseVM):
...
@classmethod
marshal(cls, vmxml):
"""Convert vmxml instance into vm instance"""
...
--
Chris Evich, RHCA, RHCE, RHCDS, RHCSS
Quality Assurance Engineer
e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214
_______________________________________________
Autotest-kernel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/autotest-kernel