Commit b7c1d8bb authored by Antoine Catton's avatar Antoine Catton

Add slapcontainer.promise recipe

parent 00e6958b
No related merge requests found
...@@ -110,6 +110,7 @@ setup(name=name, ...@@ -110,6 +110,7 @@ setup(name=name,
'siptester = slapos.recipe.siptester:SipTesterRecipe', 'siptester = slapos.recipe.siptester:SipTesterRecipe',
'simplelogger = slapos.recipe.simplelogger:Recipe', 'simplelogger = slapos.recipe.simplelogger:Recipe',
'slapcontainer = slapos.recipe.container:Recipe', 'slapcontainer = slapos.recipe.container:Recipe',
'slapcontainer.promise = slapos.recipe.container:Promise',
'slaprunner = slapos.recipe.slaprunner:Recipe', 'slaprunner = slapos.recipe.slaprunner:Recipe',
'slapmonitor = slapos.recipe.slapmonitor:Recipe', 'slapmonitor = slapos.recipe.slapmonitor:Recipe',
'slapreport = slapos.recipe.slapreport:Recipe', 'slapreport = slapos.recipe.slapreport:Recipe',
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
############################################################################## ##############################################################################
import ConfigParser import ConfigParser
import uuid
import os
import subprocess
# XXX : This is in order to get the computer_partition object # XXX : This is in order to get the computer_partition object
# which exposes the state of the current partition. # which exposes the state of the current partition.
...@@ -34,6 +37,36 @@ import ConfigParser ...@@ -34,6 +37,36 @@ import ConfigParser
# state of the current partition offline. But this is # state of the current partition offline. But this is
# written to have the most minimal impact. # written to have the most minimal impact.
from slapos.recipe.librecipe import GenericSlapRecipe from slapos.recipe.librecipe import GenericSlapRecipe
from slapos.recipe.librecipe import GenericBaseRecipe
def promise_func(args):
output = subprocess.check_output(
[args['lxc-info'], '-n', args['name']]
)
if 'RUNNING' in output:
return 0
else:
return 127
class Promise(GenericBaseRecipe):
def install(self):
return [
self.createPythonScript(
self.options['promise'],
'slapos.recipe.container.promise_func',
{
'lxc-info': self.options['lxc-info'],
'name': self.options['slapcontainer-name']
}
)
]
class Recipe(GenericSlapRecipe): class Recipe(GenericSlapRecipe):
......
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