From c72cc198c4bb8653a5aa5dcbc8a9e9ab02177daa Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Fri, 24 Aug 2018 14:07:38 +0100 Subject: [PATCH] MNAIO: Compress the disk image when saving it When we save the VM disks, we now use compression to prepare the base disk so that it reduces the base disk file sizes to a much smaller base. For the infra hosts this reduces the file from ~23GB to ~8GB. Once this is done, we then also create a copy-on-write image in the original disk's place so that the VM can be booted up to verify functionality or continue work without having to re-run the 'deploy-vms' playbook. Change-Id: If95b71d8625b4d5b2a036cec13952e4fd73cecd4 --- multi-node-aio/playbooks/save-vms.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/multi-node-aio/playbooks/save-vms.yml b/multi-node-aio/playbooks/save-vms.yml index 07311f4d..f328cc24 100644 --- a/multi-node-aio/playbooks/save-vms.yml +++ b/multi-node-aio/playbooks/save-vms.yml @@ -46,13 +46,14 @@ - hostvars[item]['server_vm'] | default(false) | bool with_items: "{{ groups['pxe_servers'] }}" - - name: Save VM Disk Image + - name: Commit, compress and save VM Disk Image and prepare new copy-on-write image shell: | if [[ -e {{ hostvars[item]['server_hostname'] }}.img ]]; then if [[ -e {{ hostvars[item]['server_hostname'] }}-base.img ]]; then qemu-img commit {{ hostvars[item]['server_hostname'] }}.img else - mv {{ hostvars[item]['server_hostname'] }}.img {{ hostvars[item]['server_hostname'] }}-base.img + qemu-img convert -O qcow2 -c {{ hostvars[item]['server_hostname'] }}.img {{ hostvars[item]['server_hostname'] }}-base.img + qemu-img create -f qcow2 -b {{ hostvars[item]['server_hostname'] }}-base.img {{ hostvars[item]['server_hostname'] }}.img fi exit 2 fi