Rebase: Sync after Build system uplift to Fuel 9.0
[armband.git] / patches / opnfv-fuel / 0014-virtual_fuel-factor-out-image-creation-into-a-method.patch
1 From: Josep Puigdemont <josep.puigdemont@enea.com>
2 Date: Wed, 4 May 2016 14:27:23 +0200
3 Subject: [PATCH] virtual_fuel: factor out image creation into a method
4
5 Signed-off-by: Josep Puigdemont <josep.puigdemont@enea.com>
6 ---
7  deploy/environments/virtual_fuel.py | 7 ++++++-
8  1 file changed, 6 insertions(+), 1 deletion(-)
9
10 diff --git a/deploy/environments/virtual_fuel.py b/deploy/environments/virtual_fuel.py
11 index 966bb91..82c4e47 100644
12 --- a/deploy/environments/virtual_fuel.py
13 +++ b/deploy/environments/virtual_fuel.py
14 @@ -51,15 +51,20 @@ class VirtualFuel(ExecutionEnvironment):
15          with open(temp_vm_file, 'w') as f:
16              vm_xml.write(f, pretty_print=True, xml_declaration=True)
17  
18 +    def create_image(self, disk_path, disk_size):
19 +        exec_cmd('qemu-img create -f qcow2 %s %s' % (disk_path, disk_size))
20 +
21      def create_vm(self):
22          vm_template = '%s/%s' % (self.root_dir,
23                                   self.dha.get_node_property(
24                                       self.fuel_node_id, 'libvirtTemplate'))
25          check_file_exists(vm_template)
26 +
27          disk_path = '%s/%s.raw' % (self.storage_dir, self.vm_name)
28          disk_sizes = self.dha.get_disks()
29          disk_size = disk_sizes['fuel']
30 -        exec_cmd('qemu-img create -f qcow2 %s %s' % (disk_path, disk_size))
31 +        self.create_image(disk_path, disk_size)
32 +
33          temp_vm_file = '%s/%s' % (self.temp_dir, self.vm_name)
34          exec_cmd('cp %s %s' % (vm_template, temp_vm_file))
35          self.set_vm_nic(temp_vm_file)