Merge "Fuel deploy: timestamp for newly created images"
[armband.git] / patches / opnfv-fuel / 0005-virtual_fuel-make-vm_template-an-attribute.patch
1 From: Josep Puigdemont <josep.puigdemont@enea.com>
2 Date: Wed, 4 May 2016 14:27:23 +0200
3 Subject: [PATCH] virtual_fuel: make vm_template an attribute
4
5 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
6 ---
7  deploy/environments/virtual_fuel.py | 11 +++++------
8  1 file changed, 5 insertions(+), 6 deletions(-)
9
10 diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
11 index 82c4e47..ac5fc53 100644
12 --- a/deploy/environments/virtual_fuel.py
13 +++ b/deploy/environments/virtual_fuel.py
14 @@ -28,6 +28,10 @@ class VirtualFuel(ExecutionEnvironment):
15          self.temp_dir = tempfile.mkdtemp()
16          self.vm_name = self.dha.get_node_property(self.fuel_node_id,
17                                                    'libvirtName')
18 +        self.vm_template = '%s/%s' % (self.root_dir,
19 +                                      self.dha.get_node_property(
20 +                                          self.fuel_node_id, 'libvirtTemplate'))
21 +        check_file_exists(self.vm_template)
22  
23      def __del__(self):
24          delete(self.temp_dir)
25 @@ -55,18 +59,13 @@ class VirtualFuel(ExecutionEnvironment):
26          exec_cmd('qemu-img create -f qcow2 %s %s' % (disk_path, disk_size))
27  
28      def create_vm(self):
29 -        vm_template = '%s/%s' % (self.root_dir,
30 -                                 self.dha.get_node_property(
31 -                                     self.fuel_node_id, 'libvirtTemplate'))
32 -        check_file_exists(vm_template)
33 -
34          disk_path = '%s/%s.raw' % (self.storage_dir, self.vm_name)
35          disk_sizes = self.dha.get_disks()
36          disk_size = disk_sizes['fuel']
37          self.create_image(disk_path, disk_size)
38  
39          temp_vm_file = '%s/%s' % (self.temp_dir, self.vm_name)
40 -        exec_cmd('cp %s %s' % (vm_template, temp_vm_file))
41 +        exec_cmd('cp %s %s' % (self.vm_template, temp_vm_file))
42          self.set_vm_nic(temp_vm_file)
43          vm_definition_overwrite = self.dha.get_vm_definition('fuel')
44          self.define_vm(self.vm_name, temp_vm_file, disk_path,