Commit a462749c authored by Łukasz Nowak's avatar Łukasz Nowak

software/kvm: Extract disk-image-corruption to template

parent 41f21555
......@@ -15,11 +15,11 @@
[template]
filename = instance.cfg.in
md5sum = 2ef12d7fc16d74e0887a8cb16a848445
md5sum = 1b8048238d27d87ddadf205d4a4aa941
[template-kvm]
filename = instance-kvm.cfg.jinja2
md5sum = 957f3a3c8e5f9a905026cc01a25b326e
md5sum = 8414431b20715cb9383b5577de9afdaf
[template-kvm-cluster]
filename = instance-kvm-cluster.cfg.jinja2.in
......@@ -100,3 +100,7 @@ md5sum = d53afe719e2cbfc2480277af340f8429
[check-backup-directory.sh]
filename = template/check-backup-directory.sh
md5sum = e569494a941e1d585c2e0bbf070cf1c9
[disk-image-corruption.sh]
filename = template/disk-image-corruption.sh
md5sum = ae1f4eaf629243ea9e58c8895849e01a
......@@ -566,22 +566,12 @@ config-host = ${kvm-parameter-dict:vnc-ip}
config-port = ${kvm-parameter-dict:vnc-websocket-port}
[kvm-disk-image-corruption-bin]
recipe = collective.recipe.template
input = inline:#!/bin/sh
# Return code 0 is "OK"
# Return code 3 is "found leaks, but image is OK"
# http://git.qemu.org/?p=qemu.git;a=blob;f=qemu-img.c;h=4e9a7f5741c9cb863d978225829e68fefcae3947;hb=HEAD#l702
if [ "${slap-parameter:disk-device-path}" != "" ]; then
# disk device option is used, skip qemu img check
exit 0
fi
${kvm-parameter-dict:qemu-img-path} check -U ${kvm-parameter-dict:disk-path} > /dev/null 2>&1
RETURN_CODE=$?
if [ $RETURN_CODE -eq 0 ] || [ $RETURN_CODE -eq 3 ]; then
exit 0
else
exit 1
fi
recipe = slapos.recipe.template:jinja2
url = {{ disk_image_corruption }}
context =
key disk_device_path slap-parameter:disk-device-path
key qemu_img_path kvm-parameter-dict:qemu-img-path
key disk_path kvm-parameter-dict:disk-path
output = ${directory:bin}/kvm-disk-image-corruption
mode = 700
......
......@@ -101,6 +101,7 @@ extra-context =
raw template_nginx ${template-nginx:target}
raw websockify_executable_location ${buildout:directory}/bin/websockify
raw wipe_disk_wrapper ${buildout:directory}/bin/securedelete
raw disk_image_corruption ${disk-image-corruption.sh:target}
template-parts-destination = ${template-parts:target}
template-replicated-destination = ${template-replicated:target}
import-list = file parts :template-parts-destination
......
......@@ -147,3 +147,6 @@ context =
[check-backup-directory.sh]
<= template-base
output = ${buildout:parts-directory}/${:_buildout_section_name_}/check-backup-directory.sh
[disk-image-corruption.sh]
<= download-base
#!/bin/sh
if [ "{{ disk_device_path }}" != "" ]; then
# disk device option is used, skip qemu img check
exit 0
fi
if [ ! -s "{{ disk_path }}" ]; then
exit 0
fi
{{ qemu_img_path }} check -U {{ disk_path }} > /dev/null 2>&1
RETURN_CODE=$?
# Return code 0 is "OK"
# Return code 3 is "found leaks, but image is OK"
# http://git.qemu.org/?p=qemu.git;a=blob;f=qemu-img.c;h=4e9a7f5741c9cb863d978225829e68fefcae3947;hb=HEAD#l702
if [ $RETURN_CODE -eq 0 ] || [ $RETURN_CODE -eq 3 ]; then
exit 0
else
exit 1
fi
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