1 From: Josep Puigdemont <josep.puigdemont@enea.com>
2 Date: Wed, 4 May 2016 14:27:23 +0200
3 Subject: [PATCH] VirtualFuel: Add temp_dir and vm_name attributes
5 These two variables are defined in one of the methods right now. They
6 will be useful to other methods too, so we add them as attributes to the
9 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
11 deploy/environments/virtual_fuel.py | 15 +++++++++------
12 1 file changed, 9 insertions(+), 6 deletions(-)
14 diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
15 index cb3bc6c..966bb91 100644
16 --- a/deploy/environments/virtual_fuel.py
17 +++ b/deploy/environments/virtual_fuel.py
18 @@ -25,6 +25,12 @@ class VirtualFuel(ExecutionEnvironment):
19 def __init__(self, storage_dir, pxe_bridge, dha_file, root_dir):
20 super(VirtualFuel, self).__init__(storage_dir, dha_file, root_dir)
21 self.pxe_bridge = pxe_bridge
22 + self.temp_dir = tempfile.mkdtemp()
23 + self.vm_name = self.dha.get_node_property(self.fuel_node_id,
27 + delete(self.temp_dir)
29 def set_vm_nic(self, temp_vm_file):
30 with open(temp_vm_file) as f:
31 @@ -46,23 +52,20 @@ class VirtualFuel(ExecutionEnvironment):
32 vm_xml.write(f, pretty_print=True, xml_declaration=True)
35 - temp_dir = tempfile.mkdtemp()
36 - vm_name = self.dha.get_node_property(self.fuel_node_id, 'libvirtName')
37 vm_template = '%s/%s' % (self.root_dir,
38 self.dha.get_node_property(
39 self.fuel_node_id, 'libvirtTemplate'))
40 check_file_exists(vm_template)
41 - disk_path = '%s/%s.raw' % (self.storage_dir, vm_name)
42 + disk_path = '%s/%s.raw' % (self.storage_dir, self.vm_name)
43 disk_sizes = self.dha.get_disks()
44 disk_size = disk_sizes['fuel']
45 exec_cmd('qemu-img create -f qcow2 %s %s' % (disk_path, disk_size))
46 - temp_vm_file = '%s/%s' % (temp_dir, vm_name)
47 + temp_vm_file = '%s/%s' % (self.temp_dir, self.vm_name)
48 exec_cmd('cp %s %s' % (vm_template, temp_vm_file))
49 self.set_vm_nic(temp_vm_file)
50 vm_definition_overwrite = self.dha.get_vm_definition('fuel')
51 - self.define_vm(vm_name, temp_vm_file, disk_path,
52 + self.define_vm(self.vm_name, temp_vm_file, disk_path,
53 vm_definition_overwrite)
56 def setup_environment(self):