New wrapper system allowing to fetch informations from instances and stop/delete instance

parent a80a8be2
......@@ -24,12 +24,12 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
import os
import shutil
from slapos.recipe.librecipe import GenericBaseRecipe
from slapos.recipe.librecipe import GenericSlapRecipe
from subprocess import Popen
import sys
class Recipe(GenericBaseRecipe):
class Recipe(GenericSlapRecipe):
def install(self):
path_list = []
poc_location = self.buildout['pocdirectory']['poc']
......@@ -69,13 +69,15 @@ class Recipe(GenericBaseRecipe):
# Generate wrapper
wrapper_config_dict = dict(
dash_location=self.options['dash-location'],
python_location=sys.executable,
poc_location=poc_location,
manifest_name=self.options['manifest-name'],
# XXX this is workaround
accords_lib_directory=self.options['accords_lib_directory'])
path_list.append(self.createExecutable(self.options['accords'],
self.substituteTemplate(self.getTemplateFilename('accords.in'),
wrapper_config_dict)))
wrapper_location = self.createPythonScript(self.options['accords'],
'%s.accords.runAccords' % __name__,
wrapper_config_dict)
path_list.append(wrapper_location)
return path_list
#!%(python_location)s
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from slapos import slap
import signal
from subprocess import Popen
import time
def runAccords(args):
"""Launch ACCORDS, parse manifest, broker manifest, send connection
informations to SlapOS Master. Destroy instance and stops ACCORDS at
SIGTERM."""
computer_id, computer_partition_id, server_url, software_release_url, \
key_file, cert_file, \
accords_lib_directory, poc_location, manifest_name = args
environment = dict(
LD_LIBRARY_PATH=accords_lib_directory,
)
# Set handler to stop ACCORDS when end of world comes
def sigtermHandler(signum, frame):
Popen(['./co-command', 'stop', '/service/*'],
cwd=poc_location, env=environment).communicate()
Popen(['./co-stop'],
cwd=poc_location, env=environment).communicate()
signal.signal(signal.SIGTERM, sigtermHandler)
# Launch ACCORDS, parse & broke manifest to deploy instance
Popen(['./co-start'],cwd=poc_location, env=environment).communicate()
Popen(['./co-parser', manifest_name],
cwd=poc_location, env=environment).communicate()
Popen(['./co-broker', manifest_name],
cwd=poc_location, env=environment).communicate()
# Parse answer
# XXX
# Send information about published service to SlapOS Master
slap_connection = slap.slap()
slap_connection.initializeConnection(server_url, key_file, cert_file)
computer_partition = slap_connection.registerComputerPartition(computer_id,
computer_partition_id)
computer_partition.setConnectionDict()
# Go to sleep, wait kill
while(True):
time.sleep(60)
\ No newline at end of file
#!%(dash_location)s
#Workaround
LD_LIBRARY_PATH=%(accords_lib_directory)s
POC=%(poc_location)s
MANIFEST=%(manifest_name)s
cd $POC
./co-start
./co-parser $MANIFEST
./co-broker $MANIFEST
[buildout]
extends =
../../component/dash/buildout.cfg
../../component/dcron/buildout.cfg
../../component/logrotate/buildout.cfg
../../component/occi/buildout.cfg
......
......@@ -29,7 +29,6 @@ accords-configuration-file = $${pocdirectory:poc}/accords.ini
manifest-source = ${occi-manifest:target}
manifest-destination = $${pocdirectory:poc}/manifest.xml
manifest-name = $${pocdirectory:poc}/manifest.xml
dash-location = ${dash:location}/bin/dash
# Workaround
accords_lib_directory : ${accords:location}/lib
......
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