Changing raw to qcow2 for vFuel/Controller/Compute 01/12101/1
authorNikolas Hermanns <nikolas.hermanns@ericsson.com>
Thu, 25 Feb 2016 13:51:15 +0000 (14:51 +0100)
committerJonas Bjurel <jonas.bjurel@ericsson.com>
Sat, 9 Apr 2016 17:49:16 +0000 (17:49 +0000)
A lot of diskspace is allocated although never used
this commit changes to thin provisioning
for the virtual enviroment.

Change-Id: Ia128143a3bae9f3d85a9e749319c2f5343c1df4e
(cherry picked from commit aac8573f454109c98fa2af1e5ed05c1d1b19829b)

17 files changed:
deploy/dha_adapters/libvirt_adapter.py
deploy/environments/libvirt_environment.py
deploy/environments/virtual_fuel.py
deploy/templates/ericsson/virtual_environment/noha/vms/compute.xml
deploy/templates/ericsson/virtual_environment/noha/vms/controller.xml
deploy/templates/ericsson/virtual_environment/noha/vms/fuel.xml
deploy/templates/hardware_environment/vms/ericsson_montreal_lab/fuel.xml
deploy/templates/hardware_environment/vms/fuel.xml
deploy/templates/intel/virtual_environment/noha/vms/compute.xml
deploy/templates/intel/virtual_environment/noha/vms/controller.xml
deploy/templates/intel/virtual_environment/noha/vms/fuel.xml
deploy/templates/virtual_environment/vms/compute.xml
deploy/templates/virtual_environment/vms/controller.xml
deploy/templates/virtual_environment/vms/fuel.xml
deploy/templates/virtual_environment_noha/vms/compute.xml
deploy/templates/virtual_environment_noha/vms/controller.xml
deploy/templates/virtual_environment_noha/vms/fuel.xml

index c65dab5..85913ac 100644 (file)
@@ -95,9 +95,12 @@ class LibvirtAdapter(HardwareAdapter):
                 sources = disk.xpath('source')
                 for source in sources:
                     disk_file = source.get('file')
-                    disk_size = exec_cmd('ls -l %s' % disk_file).split()[4]
+                    disk_size = exec_cmd('qemu-img info '
+                                         '%s |grep \"virtual size:\"'
+                                         % disk_file).split()[2]
                     delete(disk_file)
-                    exec_cmd('fallocate -l %s %s' % (disk_size, disk_file))
+                    exec_cmd('qemu-img create -f qcow2 %s %s' % (disk_file,
+                                                                 disk_size))
 
     def node_eject_iso(self, node_id):
         vm_name = self.get_node_property(node_id, 'libvirtName')
index c8a2ef5..2a09117 100644 (file)
@@ -40,7 +40,7 @@ class LibvirtEnvironment(ExecutionEnvironment):
             roles = self.dea.get_node_role(node_id)
             role = 'controller' if 'controller' in roles else 'compute'
             disk_size = disk_sizes[role]
-        exec_cmd('fallocate -l %s %s' % (disk_size, disk_path))
+        exec_cmd('qemu-img create -f qcow2 %s %s' % (disk_path, disk_size))
 
     def create_vms(self):
         temp_dir = tempfile.mkdtemp()
index 89a82c0..0e7f273 100644 (file)
@@ -55,7 +55,7 @@ class VirtualFuel(ExecutionEnvironment):
         disk_path = '%s/%s.raw' % (self.storage_dir, vm_name)
         disk_sizes = self.dha.get_disks()
         disk_size = disk_sizes['fuel']
-        exec_cmd('fallocate -l %s %s' % (disk_size, disk_path))
+        exec_cmd('qemu-img create -f qcow2 %s %s' % (disk_path, disk_size))
         temp_vm_file = '%s/%s' % (temp_dir, vm_name)
         exec_cmd('cp %s %s' % (vm_template, temp_vm_file))
         self.set_vm_nic(temp_vm_file)
index 063b23d..6fb3743 100644 (file)
@@ -48,7 +48,7 @@
   <devices>
     <emulator>/usr/bin/kvm</emulator>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <source file='disk.raw'/>
       <target dev='vda' bus='virtio'/>
     </disk>
index d30a95d..cf62fbc 100644 (file)
@@ -48,7 +48,7 @@
   <devices>
     <emulator>/usr/bin/kvm</emulator>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <source file='disk.raw'/>
       <target dev='vda' bus='virtio'/>
     </disk>
index a693c96..31e8479 100644 (file)
@@ -56,7 +56,7 @@
       <readonly/>
     </disk>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcwo2'/>
       <source file='disk.raw'/>
       <target dev='vda' bus='virtio'/>
     </disk>
index 7d06f2d..b55b16e 100644 (file)
@@ -35,7 +35,7 @@
   <devices>
     <emulator>/usr/bin/kvm</emulator>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <target dev='vda' bus='virtio'/>
     </disk>
     <disk type='block' device='cdrom'>
index e3e3f80..72c15b5 100644 (file)
@@ -35,7 +35,7 @@
   <devices>
     <emulator>/usr/libexec/qemu-kvm</emulator>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <target dev='vda' bus='virtio'/>
     </disk>
     <disk type='block' device='cdrom'>
index 063b23d..6fb3743 100644 (file)
@@ -48,7 +48,7 @@
   <devices>
     <emulator>/usr/bin/kvm</emulator>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <source file='disk.raw'/>
       <target dev='vda' bus='virtio'/>
     </disk>
index d30a95d..cf62fbc 100644 (file)
@@ -48,7 +48,7 @@
   <devices>
     <emulator>/usr/bin/kvm</emulator>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <source file='disk.raw'/>
       <target dev='vda' bus='virtio'/>
     </disk>
index a693c96..67cccbb 100644 (file)
@@ -56,7 +56,7 @@
       <readonly/>
     </disk>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <source file='disk.raw'/>
       <target dev='vda' bus='virtio'/>
     </disk>
index fa4ef5d..f794b65 100644 (file)
@@ -21,7 +21,7 @@
   <devices>
     <emulator>/usr/bin/kvm</emulator>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <source file='disk.raw'/>
       <target dev='vda' bus='virtio'/>
     </disk>
index 50950db..44dd5b6 100644 (file)
@@ -21,7 +21,7 @@
   <devices>
     <emulator>/usr/bin/kvm</emulator>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <source file='disk.raw'/>
       <target dev='vda' bus='virtio'/>
     </disk>
index 4e7c7fd..ce712a6 100644 (file)
@@ -29,7 +29,7 @@
       <readonly/>
     </disk>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <source file='disk.raw'/>
       <target dev='vda' bus='virtio'/>
     </disk>
index fa4ef5d..f794b65 100644 (file)
@@ -21,7 +21,7 @@
   <devices>
     <emulator>/usr/bin/kvm</emulator>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <source file='disk.raw'/>
       <target dev='vda' bus='virtio'/>
     </disk>
index 50950db..44dd5b6 100644 (file)
@@ -21,7 +21,7 @@
   <devices>
     <emulator>/usr/bin/kvm</emulator>
     <disk type='file' device='disk'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <source file='disk.raw'/>
       <target dev='vda' bus='virtio'/>
     </disk>
index 4e7c7fd..94384cd 100644 (file)
@@ -24,7 +24,7 @@
   <devices>
     <emulator>/usr/bin/kvm</emulator>
     <disk type='block' device='cdrom'>
-      <driver name='qemu' type='raw'/>
+      <driver name='qemu' type='qcow2'/>
       <target dev='hdc' bus='ide'/>
       <readonly/>
     </disk>