From b0a01f54c82de425d1e2a9d6a30c73d8d6900501 Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Wed, 29 Aug 2012 19:01:48 +0900 Subject: [PATCH] Add promises on lxc SR --- software/lxc/check_exists.sh.in | 3 +++ software/lxc/check_state.sh.in | 8 ++++++++ software/lxc/instance-lxc.cfg | 33 ++++++++++++++++++++++++++++++++- software/lxc/software.cfg | 23 +++++++++++++++++++---- 4 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 software/lxc/check_exists.sh.in create mode 100644 software/lxc/check_state.sh.in diff --git a/software/lxc/check_exists.sh.in b/software/lxc/check_exists.sh.in new file mode 100644 index 0000000..bbda187 --- /dev/null +++ b/software/lxc/check_exists.sh.in @@ -0,0 +1,3 @@ +#!${:bash} -e + +${:test-binary} -f ${:file} diff --git a/software/lxc/check_state.sh.in b/software/lxc/check_state.sh.in new file mode 100644 index 0000000..ae88e62 --- /dev/null +++ b/software/lxc/check_state.sh.in @@ -0,0 +1,8 @@ +#!${:bash} -e + +if [ -f ${:file} ] +then + ${:test-binary} $(${:cat} ${:file}) = ${:value} +else + exit 1 +fi diff --git a/software/lxc/instance-lxc.cfg b/software/lxc/instance-lxc.cfg index fb1df1e..37d4436 100644 --- a/software/lxc/instance-lxc.cfg +++ b/software/lxc/instance-lxc.cfg @@ -12,6 +12,10 @@ parts = shellinabox certificate-authority ca-shellinabox + container-promise + shellinabox-promise + rootfs-promise + [rootdirectory] recipe = slapos.cookbook:mkdirectory @@ -23,6 +27,7 @@ bin = $${buildout:directory}/bin [basedirectory] recipe = slapos.cookbook:mkdirectory services = $${rootdirectory:etc}/run +promises = $${rootdirectory:etc}/promise [directory] recipe = slapos.cookbook:mkdirectory @@ -45,7 +50,6 @@ certs = $${directory:ca-dir}/certs/ newcerts = $${directory:ca-dir}/newcerts/ crl = $${directory:ca-dir}/crl/ - [rootfs] recipe = slapos.cookbook:downloader url = $${slap-parameter:rootfs} @@ -118,6 +122,33 @@ recipe = slapos.cookbook:publish url = https://[$${shellinabox:ipv6}]:$${shellinabox:port}/ password = $${shellinabox:password} +[template-promise-state] +recipe = slapos.recipe.template +url = ${promise-state:location}/${promise-state:filename} +bash = ${bash:location}/bin/bash +test-binary = ${coreutils:location}/bin/test +cat = ${coreutils:location}/bin/cat +value = started +mode = 700 + +[container-promise] +<= template-promise-state +output = $${basedirectory:promises}/slapcontainer +file = $${buildout:directory}/.slapcontainer.state + +[shellinabox-promise] +<= template-promise-state +output = $${basedirectory:promises}/shellinabox +file = $${buildout:directory}/.shellinabox.state + +[rootfs-promise] +recipe = slapos.recipe.template +url = ${promise-exists:location}/${promise-exists:filename} +output = $${basedirectory:promises}/rootfs +bash = ${bash:location}/bin/bash +test-binary = ${coreutils:location}/bin/test +file = $${rootfs:downloaded-file-complete} +mode = 700 [slap-parameter] rootfs-md5sum = diff --git a/software/lxc/software.cfg b/software/lxc/software.cfg index 7853236..24f2d06 100644 --- a/software/lxc/software.cfg +++ b/software/lxc/software.cfg @@ -11,6 +11,8 @@ extends = ../../component/tar/buildout.cfg ../../component/shellinabox/buildout.cfg ../../component/pwgen/buildout.cfg + ../../component/bash/buildout.cfg + ../../component/coreutils/buildout.cfg find-links += http://www.nexedi.org/static/packages/source/slapos-lxc/ @@ -36,18 +38,31 @@ mode = 0644 [template-lxc] recipe = slapos.recipe.template url = ${:_profile_base_location_}/instance-lxc.cfg -md5sum = 056912602caa71a2af9fcae97ee6dfb9 +md5sum = af5e31fb41e2d31b25f172df45f29fc6 output = ${buildout:directory}/template-lxc.cfg mode = 0644 -[lxc-conf-in] +[download] recipe = slapos.recipe.build:download url = ${:_profile_base_location_}/${:filename} -filename = lxc.conf.in -md5sum = b25334fc369e4e0f608bc64f14b0315d download-only = true mode = 0644 +[lxc-conf-in] +<= download +filename = lxc.conf.in +md5sum = b25334fc369e4e0f608bc64f14b0315d + +[promise-state] +<= download +filename = check_state.sh.in +md5sum = 725fb0477f8b8778566ed4b22b25bf27 + +[promise-exists] +<= download +filename = check_exists.sh.in +md5sum = 60d4f5f73a3d10a3d7d7201aab977d19 + [slapos-toolbox] recipe = zc.recipe.egg scripts = slapcontainer -- 2.1.4