1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-25 15:45:23 +00:00

fix setting title/description function (xml -> lxml)

This commit is contained in:
catborise 2020-05-14 14:13:04 +03:00 committed by catborise
parent e911db8124
commit e72073fa79

View file

@ -1139,6 +1139,12 @@ class wvmInstance(wvmConnect):
uuid = tree.find('uuid') uuid = tree.find('uuid')
tree.remove(uuid) tree.remove(uuid)
options = {
'title': clone_data.get('clone-title', ''),
'description': clone_data.get('clone-description', ''),
}
self._set_options(tree, options)
src_nvram_path = self.get_nvram() src_nvram_path = self.get_nvram()
if src_nvram_path: if src_nvram_path:
# Change XML for nvram # Change XML for nvram
@ -1247,11 +1253,6 @@ class wvmInstance(wvmConnect):
storage = self.get_wvmStorage(pool_name) storage = self.get_wvmStorage(pool_name)
storage.clone_volume(vol_name, target_file) storage.clone_volume(vol_name, target_file)
options = {
'title': clone_data.get('clone-title', ''),
'description': clone_data.get('clone-description', ''),
}
self._set_options(tree, options)
self._defineXML(ElementTree.tostring(tree).decode()) self._defineXML(ElementTree.tostring(tree).decode())
return self.get_instance(clone_data['name']).UUIDString() return self.get_instance(clone_data['name']).UUIDString()
@ -1391,7 +1392,7 @@ class wvmInstance(wvmConnect):
tree.remove(option) tree.remove(option)
else: else:
if option is None: if option is None:
option = ElementTree.SubElement(tree, o) option = etree.SubElement(tree , o)
option.text = option_value option.text = option_value
def set_options(self, options): def set_options(self, options):
@ -1399,10 +1400,10 @@ class wvmInstance(wvmConnect):
Function change description, title Function change description, title
""" """
xml = self._XMLDesc(VIR_DOMAIN_XML_SECURE) xml = self._XMLDesc(VIR_DOMAIN_XML_SECURE)
tree = ElementTree.fromstring(xml) tree = etree.fromstring(xml)
self._set_options(tree, options) self._set_options(tree, options)
new_xml = ElementTree.tostring(tree).decode() new_xml = etree.tostring(tree).decode()
self._defineXML(new_xml) self._defineXML(new_xml)
def set_memory(self, size, flags=0): def set_memory(self, size, flags=0):