On 07/01/2012 11:21 PM, Yu Mingfei wrote:
> On 6/29/2012 8:12 PM, Cleber Rosa wrote:
>> On 06/29/2012 06:31 AM, Yu Mingfei wrote:
>>> +def vm_new_name(old_vm, newname, params):
>>> + oldfile = "/etc/libvirt/qemu/%s.xml" % old_vm.name
>>> + newfile = "/etc/libvirt/qemu/%s.xml" % newname
>>> + if oldfile == newfile:
>>> + logging.info("use old vm.")
>>> + return old_vm
>>> + shutil.copy(oldfile, newfile)
>>> + dom = parse(newfile)
>>> + root = dom.documentElement
>>> + node_name = root.getElementsByTagName("name")[0]
>>> + node_name.firstChild.data = "%s" % newname
>>> + node_uuid = root.getElementsByTagName("uuid")[0]
>>> + root.removeChild(node_uuid)
>>> + f=open(newfile, "w")
>>> + dom.writexml(f)
>>> + f.close()
>>
>> ^ Chris, IMHO this is a great opportunity for trying out xml_utils.
>
> Chris:
> It is a good idea.
> Our other patch may include this function too.
> So put this function to a single file xml_utils will save many codes.
> on the other hand, it will be esay to extend.
> So, I will split this function to a new file in client/virt directory in
> my new patch.Hehe, that was on my "next step" list also :) Can you call it libvirt_xml or libvirt_xml_utils or xml_libvirt or something like that for me? Thanks! -- Chris Evich, RHCA, RHCE, RHCDS, RHCSS Quality Assurance Engineer e-mail: cevich + `@' + redhat.com o: 1-888-RED-HAT1 x44214 _______________________________________________ Autotest mailing list [email protected] http://test.kernel.org/cgi-bin/mailman/listinfo/autotest
