Commit 0d16d5e8 authored by Alain Takoudjou's avatar Alain Takoudjou

kvm resilient: promise check disk corruption on kvm clone

Check that backup kvm disk is not corrupted
parent d1f6c119
......@@ -89,7 +89,7 @@ command =
[template]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg.in
md5sum = 5c159864ce41394486867c27d65c2f50
md5sum = 01bad94ed1358b27d24a6f3745408f7d
output = ${buildout:directory}/template.cfg
mode = 0644
......@@ -124,7 +124,7 @@ on-update = true
recipe = hexagonit.recipe.download
ignore-existing = true
url = ${:_profile_base_location_}/instance-kvm-import.cfg.jinja2.in
md5sum = 5e21ad759c148d26134ecefbb4d3d9f1
md5sum = 30f74f1958bd77e647a1bbe70e286e5a
mode = 0644
download-only = true
on-update = true
......@@ -152,7 +152,7 @@ recipe = hexagonit.recipe.download
ignore-existing = true
url = ${:_profile_base_location_}/template/kvm-export.sh.jinja2
filename = kvm-export.sh.jinja2
md5sum = c18e958bf374d5fa35dbb952686595fb
md5sum = b617d64de73de1eed518185f310bbc82
download-only = true
mode = 0755
......
......@@ -4,6 +4,9 @@ eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
offline = true
parts +=
kvm-disk-image-corruption-promise
# Here, we don't need KVM to run to import data, so we don't
# even extend the kvm instance profile.
extends =
......@@ -59,3 +62,21 @@ context =
raw gzip_binary {{ gzip_binary }}
backup-disk-path = ${directory:backup}/virtual.qcow2
[kvm-disk-image-corruption-promise]
# Check that disk image is not corrupted
recipe = collective.recipe.template
input = inline:#!/bin/sh
QEMU_IMAGE="${directory:srv}/virtual.qcow2"
if [ ! -s "$QEMU_IMAGE" ]; then
exit 0
fi
{{ qemu_location }}/bin/qemu-img check $QEMU_IMAGE
RETURN_CODE=$?
if [ $RETURN_CODE -eq 0 ] || [ $RETURN_CODE -eq 3 ]; then
exit 0
else
exit 1
fi
output = ${directory:promises}/kvm-disk-image-corruption
mode = 700
\ No newline at end of file
......@@ -149,6 +149,7 @@ extensions = jinja2.ext.do
context =
key develop_eggs_directory buildout:develop-eggs-directory
key eggs_directory buildout:eggs-directory
key qemu_location kvm:location
raw template_kvm_import ${template-kvm-import-script:location}/${template-kvm-import-script:filename}
raw pbsready_import_template ${pbsready-import:output}
key slapparameter_dict slap-configuration:configuration
......
......@@ -2,6 +2,7 @@
#
# Create a backup of the disk image of the virtual machine
#
set -e
LC_ALL=C
export LC_ALL
BACKUP_DIR={{ directory['backup'] }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment