slaprunner is now generic

parent 3f2d794b
...@@ -31,14 +31,15 @@ class Recipe(GenericBaseRecipe): ...@@ -31,14 +31,15 @@ class Recipe(GenericBaseRecipe):
"""Deploy a fully operational cloud9 service.""" """Deploy a fully operational cloud9 service."""
def _options(self, options): def _options(self, options):
self.ip = options['ipv6'].strip() self.ip = options['ip'].strip()
self.port = options['port'].strip() self.port = options['port'].strip()
self.git = options['git-binary'].strip() self.git = options['git-binary'].strip()
self.node_executable = options['node-binary'].strip() self.node_executable = options['node-binary'].strip()
self.cloud9 = options['cloud9'].strip() self.cloud9 = options['cloud9'].strip()
self.workdir = options['working-directory'].strip() self.workdir = options['working-directory'].strip()
self.wrapper = options['wrapper'].strip()
# Set cloud9 access URL # Set cloud9 access URL
options['access_url'] = 'http://[%s]:%s' % (self.ip, self.port) options['access-url'] = 'http://[%s]:%s' % (self.ip, self.port)
def install(self): def install(self):
path_list = [] path_list = []
...@@ -50,8 +51,10 @@ class Recipe(GenericBaseRecipe): ...@@ -50,8 +51,10 @@ class Recipe(GenericBaseRecipe):
cloud9_args = [self.node_executable, self.cloud9, '-l', self.ip, '-p', cloud9_args = [self.node_executable, self.cloud9, '-l', self.ip, '-p',
self.port, '-w', self.workdir] self.port, '-w', self.workdir]
wrapper = self.createPythonScript(self.options['wrapper-name'], wrapper = self.createPythonScript(self.wrapper,
'slapos.recipe.librecipe.execute.executee', cloud9_args, environment) 'slapos.recipe.librecipe.execute.executee',
(cloud9_args, environment)
)
path_list.append(wrapper) path_list.append(wrapper)
return path_list return path_list
...@@ -24,74 +24,70 @@ ...@@ -24,74 +24,70 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
from slapos.recipe.librecipe import BaseSlapRecipe from slapos.recipe.librecipe import GenericBaseRecipe
import os import os
import pkg_resources
import sys
import zc.buildout
import zc.recipe.egg
class Recipe(GenericBaseRecipe):
def _options(self, options):
self.ipv4 = options['ipv4'].strip()
self.ipv6 = options['ipv6'].strip()
self.proxy_port = options['proxy_port'].strip()
self.runner_port = options['runner_port'].strip()
self.workdir = options['working-directory'].strip()
self.software_directory = options['software-directory'].strip()
self.instance_directory = options['instance-directory'].strip()
self.partition_amount = options['partition-amount'].strip()
self.cloud9_url = options['cloud9-url'].strip()
# Set slaprunner access URL
options['access-url'] = 'http://[%s]:%s' % (self.ipv6, self.runner_port)
def install(self):
path_list = []
class Recipe(BaseSlapRecipe):
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'
cloud9_port = '30000'
workdir = self.createDataDirectory('runner')
software_root = os.path.join(workdir, 'software')
instance_root = os.path.join(workdir, 'instance')
configuration = dict( configuration = dict(
software_root=software_root, software_root=self.software_directory,
instance_root=instance_root, instance_root=self.instance_directory,
master_url='http://%s:%s/' % (ipv4, proxy_port), master_url='http://%s:%s/' % (self.ipv4, self.proxy_port),
computer_id='slaprunner', computer_id='slaprunner',
partition_amount=7, partition_amount=self.partition_amount,
slapgrid_sr=self.options['slapgrid_sr'], slapgrid_sr=self.options['slapgrid_sr'],
slapgrid_cp=self.options['slapgrid_cp'], slapgrid_cp=self.options['slapgrid_cp'],
slapproxy=self.options['slapproxy'], slapproxy=self.options['slapproxy'],
supervisor=self.options['supervisor'], supervisor=self.options['supervisor'],
supervisord_config=os.path.join(instance_root, 'etc', supervisord_config=os.path.join(self.instance_directory, 'etc',
'supervisord.conf'), 'supervisord.conf'),
runner_workdir=workdir, runner_workdir=self.workdir,
runner_host=ipv6, runner_host=self.ipv6,
runner_port=runner_port, runner_port=self.runner_port,
ipv4_address=ipv4, ipv4_address=self.ipv4,
ipv6_address=ipv6, ipv6_address=self.ipv6,
proxy_host=ipv4, proxy_host=self.ipv4,
proxy_port=proxy_port, proxy_port=self.proxy_port,
proxy_database=os.path.join(workdir, 'proxy.db'), proxy_database=os.path.join(self.workdir, 'proxy.db'),
git=self.options['git'], git=self.options['git-binary'],
cloud9_url='http://[%s]:%s' % (ipv6, cloud9_port), ssh_client=self.options['ssh_client'],
ssh_client=self.options['ssh_client'], public_key=self.options['public_key'],
public_key=self.options['public_key'], private_key=self.options['private_key'],
private_key=self.options['private_key'], cloud9_url=self.cloud9_url
) )
config_file = self.createConfigurationFile('slapos.cfg',
self.substituteTemplate(pkg_resources.resource_filename(__name__, config_file = self.createFile(self.options['slapos.cfg'],
'template/slapos.cfg.in'), configuration)) self.substituteTemplate(self.getTemplateFilename('slapos.cfg.in'),
self.path_list.append(config_file) configuration))
path_list.append(config_file)
environment = dict( environment = dict(
PATH=os.path.dirname(self.options['git']) + ':' + os.environ['PATH'], PATH=os.path.dirname(self.options['git-binary']) + ':' + os.environ['PATH'],
GIT_SSH=self.options['ssh_client'] GIT_SSH=self.options['ssh_client']
) )
project_workdir = os.path.join(workdir, 'project')
if not os.path.exists(project_workdir):
os.mkdir(project_workdir)
launch_args = [self.options['slaprunner'].strip(), config_file, '--debug'] launch_args = [self.options['slaprunner'].strip(), config_file, '--debug']
cloud9_args = [self.options['node-bin'].strip(), self.options['cloud9'].strip(),
'-l', ipv6, '-p', cloud9_port, '-w', workdir] wrapper = self.createPythonScript(self.options['wrapper'],
self.path_list.extend(zc.buildout.easy_install.scripts([('slaprunner', 'slapos.recipe.librecipe.execute.executee',
'slapos.recipe.librecipe.execute', 'executee')], self.ws, sys.executable, (launch_args, environment)
self.wrapper_directory, arguments=[launch_args, environment])) )
self.path_list.extend(zc.buildout.easy_install.scripts([('cloud9IDE', path_list.append(wrapper)
'slapos.recipe.librecipe.execute', 'executee')], self.ws, sys.executable,
self.wrapper_directory, arguments=[cloud9_args, environment])) return path_list
self.setConnectionDict(dict(slaprunner_url='http://[%s]:%s' % (ipv6, runner_port),
cloud9_url='http://[%s]:%s' % (ipv6, cloud9_port)))
return self.path_list
[buildout] [buildout]
parts = parts =
instance cloud9
slaprunner
sshkeys-dropbear sshkeys-dropbear
dropbear-server-add-authorized-key dropbear-server-add-authorized-key
publish-connection-informations
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true offline = true
[instance]
recipe = ${instance-recipe:egg}:${instance-recipe:module} # Create all needed directories
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/
var = $${buildout:directory}/var/
srv = $${buildout:directory}/srv/
bin = $${buildout:directory}/bin/
[directory]
recipe = slapos.cookbook:mkdirectory
sshkeys = $${rootdirectory:srv}/sshkeys
services = $${rootdirectory:etc}/run/
ssh = $${rootdirectory:etc}/ssh/
[basedirectory]
recipe = slapos.cookbook:mkdirectory
log = $${rootdirectory:var}/log/
services = $${rootdirectory:etc}/run/
run = $${rootdirectory:var}/run/
backup = $${rootdirectory:srv}/backup/
promises = $${rootdirectory:etc}/promise/
[runnerdirectory]
recipe = slapos.cookbook:mkdirectory
home = $${rootdirectory:srv}/runner/
project = $${:home}/project
software-root = $${:home}/software
instance-root = $${:home}/instance
# Deploy cloud9 and slaprunner
[cloud9]
recipe = slapos.cookbook:cloud9
ip = $${slap-network-information:global-ipv6}
port = 30000
wrapper = $${basedirectory:services}/cloud9
working-directory = $${runnerdirectory:home}
git-binary = ${git:location}/bin/git
node-binary = ${nodejs:location}/bin/node
cloud9 = ${cloud9:location}/server.js
[slaprunner]
recipe = slapos.cookbook:slaprunner
slaprunner = ${buildout:directory}/bin/slaprunner slaprunner = ${buildout:directory}/bin/slaprunner
slapgrid_sr = ${buildout:directory}/bin/slapgrid-sr slapgrid_sr = ${buildout:directory}/bin/slapgrid-sr
slapgrid_cp = ${buildout:directory}/bin/slapgrid-cp slapgrid_cp = ${buildout:directory}/bin/slapgrid-cp
slapproxy = ${buildout:directory}/bin/slapproxy slapproxy = ${buildout:directory}/bin/slapproxy
supervisor = ${buildout:directory}/bin/slapgrid-supervisorctl supervisor = ${buildout:directory}/bin/slapgrid-supervisorctl
git = ${git:location}/bin/git git-binary = ${git:location}/bin/git
node-bin = ${nodejs:location}/bin/node slapos.cfg = $${rootdirectory:etc}/slapos.cfg
cloud9 = ${cloud9:location}/bin/cloud9.js working-directory = $${runnerdirectory:home}
project-directory = $${runnerdirectory:project}
software-directory = $${runnerdirectory:software-root}
instance-directory = $${runnerdirectory:instance-root}
ssh_client = $${sshkeys-dropbear:wrapper} ssh_client = $${sshkeys-dropbear:wrapper}
public_key = $${sshkeys-dropbear:public-key} public_key = $${sshkeys-dropbear:public-key}
private_key = $${sshkeys-dropbear:private-key} private_key = $${sshkeys-dropbear:private-key}
ipv4 = $${slap-network-information:local-ipv4}
ipv6 = $${slap-network-information:global-ipv6}
proxy_port = 50000
runner_port = 50000
partition-amount = 7
cloud9-url = $${cloud9:access-url}
wrapper = $${basedirectory:services}/slaprunner
[sshkeys-directory] # Deploy dropbear (minimalist ssh server)
recipe = slapos.cookbook:mkdirectory
requests = $${directory:sshkeys}/requests/
keys = $${directory:sshkeys}/keys/
# Deploy dropbear (minimalist SSH server)
[sshkeys-directory] [sshkeys-directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
requests = $${directory:sshkeys}/requests/ requests = $${directory:sshkeys}/requests/
...@@ -65,26 +113,14 @@ wrapper = $${basedirectory:services}/sshd ...@@ -65,26 +113,14 @@ wrapper = $${basedirectory:services}/sshd
recipe = slapos.cookbook:dropbear.add_authorized_key recipe = slapos.cookbook:dropbear.add_authorized_key
key = $${slap-parameter:authorized-key} key = $${slap-parameter:authorized-key}
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/
var = $${buildout:directory}/var/
srv = $${buildout:directory}/srv/
bin = $${buildout:directory}/bin/
[directory] # Send informations to SlapOS Master
recipe = slapos.cookbook:mkdirectory [publish-connection-informations]
sshkeys = $${rootdirectory:srv}/sshkeys recipe = slapos.cookbook:publish
services = $${rootdirectory:etc}/run/ url = $${slaprunner:access-url}
ssh = $${rootdirectory:etc}/ssh/ cloud9_url = $${cloud9:access-url}
ssh_command = ssh $${dropbear-server:host} -p $${dropbear-server:port}
[basedirectory]
recipe = slapos.cookbook:mkdirectory
log = $${rootdirectory:var}/log/
services = $${rootdirectory:etc}/run/
run = $${rootdirectory:var}/run/
backup = $${rootdirectory:srv}/backup/
promises = $${rootdirectory:etc}/promise/
[slap-parameter] [slap-parameter]
# Default value if no ssh key is specified # Default value if no ssh key is specified
......
...@@ -34,7 +34,7 @@ md5sum = 5307e4200f044ae57b504ad68444491c ...@@ -34,7 +34,7 @@ md5sum = 5307e4200f044ae57b504ad68444491c
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-runner.cfg url = ${:_profile_base_location_}/instance-runner.cfg
output = ${buildout:directory}/template-runner.cfg output = ${buildout:directory}/template-runner.cfg
md5sum = c24f4a76c9e8be5f5b83af28daf0fca1 md5sum = 779df8a10f18511058a49b14b8ffba18
mode = 0644 mode = 0644
[eggs] [eggs]
......
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