Commit 7bc73e50 authored by Marco Mariani's avatar Marco Mariani

kvm: converted templates to jinja2

parent 3e0d0fb0
......@@ -115,15 +115,15 @@ on-update = true
[template-kvm-import]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-kvm-import.cfg.in
md5sum = 7b36d6c61154b7ec3113a1bfaa25a904
md5sum = 98b1acc438895c0fa2309144a9a52a62
output = ${buildout:directory}/template-kvm-import.cfg
mode = 0644
[template-kvm-import-script]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/kvm-import.sh.in
filename = kvm-import.sh.in
md5sum = e03ed049cddd8d157228b09e1ebc071a
url = ${:_profile_base_location_}/template/kvm-import.sh.jinja2
filename = kvm-import.sh.jinja2
md5sum = 2178e7ef7f1b9ea6639bfbaf045e1feb
download-only = true
mode = 0755
......@@ -131,15 +131,15 @@ mode = 0755
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/instance-kvm-export.cfg.jinja2
mode = 644
md5sum = 900f416956903fa4858e67e93b5169a1
md5sum = 4972bc6f6a4cb41c1820ac13a32915a8
download-only = true
on-update = true
[template-kvm-export-script]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/kvm-export.sh.in
filename = kvm-export.sh.in
md5sum = 95fde96f35cbf90d677c44d18b60fafb
url = ${:_profile_base_location_}/template/kvm-export.sh.jinja2
filename = kvm-export.sh.jinja2
md5sum = 2e2a99e33e5cdde35833d164da1e325b
download-only = true
mode = 0755
......
......@@ -40,4 +40,3 @@ command =
grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link &&
grep parts ${buildout:develop-eggs-directory}/slapos.toolbox.egg-link &&
grep parts ${buildout:develop-eggs-directory}/erp5.util.egg-link
......@@ -17,13 +17,16 @@ parts +=
# Create the exporter executable, which is a simple shell script
[exporter]
recipe = slapos.recipe.template
url = {{ template_kvm_export }}
output = ${directory:bin}/${slap-parameter:namebase}-exporter
mode = 0755
backup-disk-path = ${directory:backup}/virtual.qcow2
recipe = slapos.recipe.template:jinja2
template = {{ template_kvm_export }}
rendered = ${directory:bin}/${slap-parameter:namebase}-exporter
# Resilient stack wants a "wrapper" parameter
wrapper = ${:output}
wrapper = ${:rendered}
mode = 0700
context =
section directory directory
section buildout buildout
key socket_path kvm-instance:socket-path
# Extends publish section with resilient parameters
[publish-connection-information]
......
......@@ -25,13 +25,13 @@ crontabs = $${:etc}/crontabs
cronstamps = $${:etc}/cronstamps
[importer]
recipe = slapos.recipe.template
url = ${template-kvm-import-script:location}/${template-kvm-import-script:filename}
output = $${directory:bin}/$${slap-parameter:namebase}-importer
mode = 0755
backup-disk-path = $${directory:backup}/virtual.qcow2
disk-path = $${directory:srv}/virtual.qcow2
recipe = slapos.recipe.template:jinja2
template = ${template-kvm-import-script:location}/${template-kvm-import-script:filename}
rendered = $${directory:bin}/$${slap-parameter:namebase}-importer
mode = 0700
# Resilient stack wants a "wrapper" parameter
wrapper = $${:output}
wrapper = $${:rendered}
context =
section directory directory
backup-disk-path = $${directory:backup}/virtual.qcow2
#!/bin/bash
# Create a backup of the disk image of the virtual machine
BACKUP_PATH=${:backup-disk-path}
QMP_CLIENT=${buildout:directory}/software_release/bin/qemu-qmp-client
if [ ! -f $DISK_PATH ]; then
echo "Nothing to backup, disk image doesn't exist yet."
exit 0;
fi
$QMP_CLIENT --socket ${kvm-instance:socket-path} --drive-backup $BACKUP_PATH
#!/bin/bash
#
# Create a backup of the disk image of the virtual machine
#
LC_ALL=C
export LC_ALL
BACKUP_DIR={{ directory['backup'] }}
BACKUP_FILE=virtual.qcow2
QMP_CLIENT={{ buildout['directory'] }}/software_release/bin/qemu-qmp-client
$QMP_CLIENT --socket {{ socket_path }} --drive-backup $BACKUP_DIR/$BACKUP_FILE
cd $BACKUP_DIR && find -type f ! -name backup.signature -print0 | xargs -P4 -0 sha256sum | LC_ALL=C sort -k 66 > backup.signature
#!/bin/bash
DISK_PATH=${:disk-path}
BACKUP_PATH=${:backup-disk-path}
# TODO: Use rdiff
rm $DISK_PATH
cp $BACKUP_PATH $DISK_PATH
#!/bin/bash
VM_DIR={{ directory['srv'] }}
BACKUP_DIR={{ directory['backup'] }}
VM_FILE=virtual.qcow2
LC_ALL=C
export LC_ALL
umask 077
write_backup_proof () {
cd {{ directory['backup'] }}
find -type f ! -name backup.signature ! -wholename "./rdiff-backup-data/*" -print0 | xargs -P4 -0 sha256sum | LC_ALL=C sort -k 66 > {{ directory['srv'] }}/proof.signature
diff -ruw {{ directory['backup'] }} {{ directory['srv'] }}/proof.signature > {{ directory['srv'] }}/backup.diff
}
# For now we just make the diff before
write_backup_proof
# TODO: Use rdiff
rm $VM_DIR/$VM_FILE
cp $BACKUP_DIR/$VM_FILE $VM_DIR/$VM_FILE
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