Commit 7a2f0ca1 authored by Łukasz Nowak's avatar Łukasz Nowak

Slaprunner instantiation recipe.

parent d53bca5e
Changelog
=========
1.2 (unreleased)
----------------
1.1 (2011-04-22)
----------------
include CHANGES.txt
recursive-include src/slapos/recipe/slaprunner/ *.in
from setuptools import setup, find_packages
name = "slapos.recipe.slaprunner"
version = '1.2-dev'
def read(name):
return open(name).read()
long_description = (read('README.txt') + '\n' + read('CHANGES.txt'))
setup(
name=name,
version=version,
description="ZC Buildout recipe for OSOE SlapOS training",
long_description=long_description,
license="GPLv3",
keywords="buildout slapos recipe runner",
classifiers=[
"Framework :: Buildout :: Recipe",
"Programming Language :: Python",
],
packages=find_packages('src'),
package_dir={'': 'src'},
include_package_data=True,
install_requires=[
'setuptools', # for namespacing
'slapos.lib.recipe', # uses internally
'zc.recipe.egg',
'zc.buildout', # it is recipe
],
namespace_packages=['slapos', 'slapos.recipe'],
entry_points={'zc.buildout': ['default = %s:Recipe' % name]},
)
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
try:
__import__('pkg_resources').declare_namespace(__name__)
except ImportError:
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
##############################################################################
#
# 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.lib.recipe.BaseSlapRecipe import BaseSlapRecipe
import os
import pkg_resources
import sys
import zc.buildout
import zc.recipe.egg
class Recipe(BaseSlapRecipe):
def __init__(self, buildout, name, options):
BaseSlapRecipe.__init__(self, buildout, name, options)
options['eggs'] = 'slapos.recipe.slaprunner'
self.egg = zc.recipe.egg.Scripts(buildout, name, options)
def _install(self):
self.path_list = []
self.requirements, self.ws = self.egg.working_set()
ipv4 = self.getLocalIPv4Address()
ipv6 = self.getGlobalIPv6Address()
proxy_port = '50000'
runner_port = '50000'
workdir = self.createDataDirectory('runner')
software_root = os.path.join(workdir, 'software')
instance_root = os.path.join(workdir, 'instance')
configuration = dict(
software_root=software_root,
instance_root=instance_root,
master_url='http://%s:%s/' % (ipv4, proxy_port),
computer_id='slaprunner',
partition_amount=2,
slapgrid_sr=self.options['slapgrid_sr'],
slapgrid_cp=self.options['slapgrid_cp'],
slapproxy=self.options['slapproxy'],
supervisor=self.options['supervisor'],
supervisord_config=os.path.join(instance_root, 'etc',
'supervisord.conf'),
runner_workdir=workdir,
runner_host=ipv6,
runner_port=runner_port,
ipv4_address=ipv4,
ipv6_address=ipv6,
proxy_host=ipv4,
proxy_port=proxy_port,
proxy_database=os.path.join(workdir, 'proxy.db')
)
config_file = self.createConfigurationFile('slapos.cfg',
self.substituteTemplate(pkg_resources.resource_filename(__name__,
'template/slapos.cfg.in'), configuration))
self.path_list.append(config_file)
self.path_list.extend(zc.buildout.easy_install.scripts([('slaprunner',
'slapos.recipe.slaprunner.execute', 'execute')], self.ws, sys.executable,
self.wrapper_directory, arguments=[self.options['slaprunner'].strip(),
config_file]))
self.setConnectionDict(dict(url='http://[%s]:%s' % (ipv6, runner_port)))
return self.path_list
import os
def execute(args):
"""Portable execution with process replacement"""
os.execv(args[0], args)
[slapos]
software_root = %(software_root)s
instance_root = %(instance_root)s
master_url = %(master_url)s
computer_id = %(computer_id)s
[slapformat]
partition_amount = %(partition_amount)s
[slaprunner]
slapgrid_sr = %(slapgrid_sr)s
slapgrid_cp = %(slapgrid_cp)s
slapproxy = %(slapproxy)s
supervisor = %(supervisor)s
supervisord_config = %(supervisord_config)s
runner_workdir = %(runner_workdir)s
runner_host = %(runner_host)s
runner_port = %(runner_port)s
ipv4_address = %(ipv4_address)s
ipv6_address = %(ipv6_address)s
[slapproxy]
host = %(proxy_host)s
port = %(proxy_port)s
database_uri = %(proxy_database)s
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