summaryrefslogtreecommitdiffstats
path: root/patches/opnfv-fuel/0007-virtual_fuel-add-XML-tree-as-attribute-of-VirtualFue.patch
diff options
context:
space:
mode:
authorAlexandru Avadanii <Alexandru.Avadanii@enea.com>2016-05-31 22:34:54 +0200
committerAlexandru Avadanii <Alexandru.Avadanii@enea.com>2016-06-04 16:04:52 +0000
commite7e2d84bec0d404057bce203f9c90231360e88ee (patch)
tree43e54e897217da67906580991c3c7f0a110250e8 /patches/opnfv-fuel/0007-virtual_fuel-add-XML-tree-as-attribute-of-VirtualFue.patch
parent70f2caa773fc5f0e2b1154a5c095665375f02666 (diff)
Rebase: deploy related patch series.
After change "common.py: catch stderr in exec_cmd" [1] and other unrelated changes were merged upstream, we need to rebase the complete deploy related series. While we're at it, re-export Fuel@OPNFV patches in Armband. [1] https://gerrit.opnfv.org/gerrit/#/c/14561/ Change-Id: Icbc8261c2e24e4b29e8f5f2bc83db6829219129a
Diffstat (limited to 'patches/opnfv-fuel/0007-virtual_fuel-add-XML-tree-as-attribute-of-VirtualFue.patch')
-rw-r--r--patches/opnfv-fuel/0007-virtual_fuel-add-XML-tree-as-attribute-of-VirtualFue.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/patches/opnfv-fuel/0007-virtual_fuel-add-XML-tree-as-attribute-of-VirtualFue.patch b/patches/opnfv-fuel/0007-virtual_fuel-add-XML-tree-as-attribute-of-VirtualFue.patch
new file mode 100644
index 00000000..53e1a8db
--- /dev/null
+++ b/patches/opnfv-fuel/0007-virtual_fuel-add-XML-tree-as-attribute-of-VirtualFue.patch
@@ -0,0 +1,62 @@
+From: Josep Puigdemont <josep.puigdemont@enea.com>
+Date: Fri, 20 May 2016 10:05:11 +0200
+Subject: [PATCH] virtual_fuel: add XML tree as attribute of VirtualFuel
+
+Now the VM XML definition tree is an attribute of the object, this way
+it can be used by all methods without having to re-read the file.
+
+Methods added:
+update_vm_template_file: Flushes the contents of the in-memory XML
+ representation of the VM to the backing file.
+
+Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
+---
+ deploy/environments/virtual_fuel.py | 21 ++++++++++++++-------
+ 1 file changed, 14 insertions(+), 7 deletions(-)
+
+diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
+index f9f9f7a..7dc9720 100644
+--- a/deploy/environments/virtual_fuel.py
++++ b/deploy/environments/virtual_fuel.py
+@@ -54,14 +54,21 @@ class VirtualFuel(ExecutionEnvironment):
+ self.dha.get_node_property(
+ self.fuel_node_id, 'libvirtTemplate'))
+ check_file_exists(self.vm_template)
++ with open(self.vm_template) as f:
++ self.vm_xml = etree.parse(f)
++
++ self.temp_vm_file = '%s/%s' % (self.temp_dir, self.vm_name)
++ self.update_vm_template_file()
+
+ def __del__(self):
+ delete(self.temp_dir)
+
+- def set_vm_nic(self, temp_vm_file):
+- with open(temp_vm_file) as f:
+- vm_xml = etree.parse(f)
+- interfaces = vm_xml.xpath('/domain/devices/interface')
++ def update_vm_template_file(self):
++ with open(self.temp_vm_file, "wc") as f:
++ self.vm_xml.write(f, pretty_print=True, xml_declaration=True)
++
++ def set_vm_nic(self):
++ interfaces = self.vm_xml.xpath('/domain/devices/interface')
+ for interface in interfaces:
+ interface.getparent().remove(interface)
+ interface = etree.Element('interface')
+@@ -70,12 +77,12 @@ class VirtualFuel(ExecutionEnvironment):
+ source.set('bridge', self.pxe_bridge)
+ model = etree.SubElement(interface, 'model')
+ model.set('type', 'virtio')
+- devices = vm_xml.xpath('/domain/devices')
++ devices = self.vm_xml.xpath('/domain/devices')
+ if devices:
+ device = devices[0]
+ device.append(interface)
+- with open(temp_vm_file, 'w') as f:
+- vm_xml.write(f, pretty_print=True, xml_declaration=True)
++
++ self.update_vm_template_file()
+
+ def create_volume(self, pool, name, su, img_type='qcow2'):
+ log('Creating image using Libvirt volumes in pool %s, name: %s' %