Commit 3205dfad authored by Alain Takoudjou's avatar Alain Takoudjou

Merge branch 're6st-master'

parents 0a4813ec e97aef9e
...@@ -6,8 +6,9 @@ parts = babeld ...@@ -6,8 +6,9 @@ parts = babeld
[babeld] [babeld]
recipe = slapos.recipe.cmmi recipe = slapos.recipe.cmmi
url = https://softinst51707.host.vifib.net/public/babel-nxd.tar.gz # Babeld version v1.6.0-nxd1
md5sum = 5b4391addf42956a84f9ca2bb1cfd1f9 url = http://git.erp5.org/gitweb/babeld.git/snapshot/e39e62b5ecbce9d488b4f2a0999f8b5e7612e75f.tar.gz
md5sum = 3a2697f3f6e5815632809c84c004bfaa
configure-command = configure-command =
echo "No configure.." echo "No configure.."
......
...@@ -29,7 +29,7 @@ import subprocess ...@@ -29,7 +29,7 @@ import subprocess
from slapos.recipe.librecipe import GenericBaseRecipe from slapos.recipe.librecipe import GenericBaseRecipe
import socket import socket
import struct import struct
import os import os, stat
import string, random import string, random
import json import json
import traceback import traceback
...@@ -49,7 +49,9 @@ class Recipe(GenericBaseRecipe): ...@@ -49,7 +49,9 @@ class Recipe(GenericBaseRecipe):
self.software_release_url = slap_connection['software-release-url'] self.software_release_url = slap_connection['software-release-url']
self.key_file = slap_connection.get('key-file') self.key_file = slap_connection.get('key-file')
self.cert_file = slap_connection.get('cert-file') self.cert_file = slap_connection.get('cert-file')
self.slave_list = json.loads(options['slave-instance-list'])
options['slave-amount'] = '%s' % len(self.slave_list)
return GenericBaseRecipe.__init__(self, buildout, name, options) return GenericBaseRecipe.__init__(self, buildout, name, options)
def getSerialFromIpv6(self, ipv6): def getSerialFromIpv6(self, ipv6):
...@@ -72,12 +74,18 @@ class Recipe(GenericBaseRecipe): ...@@ -72,12 +74,18 @@ class Recipe(GenericBaseRecipe):
key_file = self.options['key-file'].strip() key_file = self.options['key-file'].strip()
cert_file = self.options['cert-file'].strip() cert_file = self.options['cert-file'].strip()
dh_file = self.options['dh-file'].strip() dh_file = self.options['dh-file'].strip()
if not os.path.exists(key_file): if not os.path.exists(dh_file):
serial = self.getSerialFromIpv6(self.options['ipv6-prefix'].strip())
dh_command = [self.options['openssl-bin'], 'dhparam', '-out', dh_command = [self.options['openssl-bin'], 'dhparam', '-out',
'%s' % dh_file, self.options['key-size']] '%s' % dh_file, self.options['key-size']]
try:
subprocess.check_call(dh_command)
except Exception:
if os.path.exists(dh_file):
os.unlink(dh_file)
raise
if not os.path.exists(cert_file):
serial = self.getSerialFromIpv6(self.options['ipv6-prefix'].strip())
key_command = [self.options['openssl-bin'], 'genrsa', '-out', key_command = [self.options['openssl-bin'], 'genrsa', '-out',
'%s' % key_file, self.options['key-size']] '%s' % key_file, self.options['key-size']]
...@@ -86,9 +94,19 @@ class Recipe(GenericBaseRecipe): ...@@ -86,9 +94,19 @@ class Recipe(GenericBaseRecipe):
'-x509', '-batch', '-key', '%s' % key_file, '-set_serial', '-x509', '-batch', '-key', '%s' % key_file, '-set_serial',
'%s' % serial, '-days', '3650', '-out', '%s' % cert_file] '%s' % serial, '-days', '3650', '-out', '%s' % cert_file]
subprocess.check_call(dh_command) try:
subprocess.check_call(key_command) subprocess.check_call(key_command)
subprocess.check_call(cert_command) except Exception:
if os.path.exists(key_file):
os.unlink(key_file)
raise
try:
subprocess.check_call(cert_command)
except Exception:
if os.path.exists(cert_file):
os.unlink(cert_file)
raise
def generateSlaveTokenList(self, slave_instance_list, token_file): def generateSlaveTokenList(self, slave_instance_list, token_file):
to_remove_dict = {} to_remove_dict = {}
...@@ -150,16 +168,21 @@ class Recipe(GenericBaseRecipe): ...@@ -150,16 +168,21 @@ class Recipe(GenericBaseRecipe):
self.generateCertificate() self.generateCertificate()
wrapper = self.createWrapper(name=self.options['wrapper'], wrapper = self.createFile(self.options['wrapper'], self.substituteTemplate(
command=self.options['command'], self.getTemplateFilename('registry-run.in'), dict(
parameters=['@%s' % self.options['config-file']]) parameter='@%s' % self.options['config-file'],
pid_file=self.options['pid-file'],
command=self.options['command']
)
)
)
os.chmod(self.options['wrapper'], stat.S_IRWXU)
path_list.append(wrapper) path_list.append(wrapper)
slave_list = json.loads(self.options['slave-instance-list'])
registry_url = 'http://%s:%s/' % (self.options['ipv4'], self.options['port']) registry_url = 'http://%s:%s/' % (self.options['ipv4'], self.options['port'])
token_dict, add_token_dict, rm_token_dict = self.generateSlaveTokenList( token_dict, add_token_dict, rm_token_dict = self.generateSlaveTokenList(
slave_list, token_save_path) self.slave_list, token_save_path)
# write request add token # write request add token
for reference in add_token_dict: for reference in add_token_dict:
......
#!/bin/sh
echo $$ > %(pid_file)s
exec %(command)s \
%(parameter)s
\ No newline at end of file
...@@ -53,5 +53,5 @@ Listen {{ ipv6 }}:{{ apache_port }} ...@@ -53,5 +53,5 @@ Listen {{ ipv6 }}:{{ apache_port }}
SSLProxyEngine On SSLProxyEngine On
{% endif -%} {% endif -%}
ProxyPass / {{ uri_scheme }}://{{ re6st_ipv4 }}:{{ re6st_port }}/ ProxyPass / http://{{ re6st_ipv4 }}:{{ re6st_port }}/
</VirtualHost> </VirtualHost>
\ No newline at end of file
...@@ -88,6 +88,15 @@ key-file = ${certificate-authority:ca-private}/apache.key ...@@ -88,6 +88,15 @@ key-file = ${certificate-authority:ca-private}/apache.key
cert-file = ${certificate-authority:ca-certs}/apache.crt cert-file = ${certificate-authority:ca-certs}/apache.crt
{% endif %} {% endif %}
[apache-httpd-graceful]
recipe = slapos.recipe.template:jinja2
template = {{ parameter_dict['template-wrapper'] }}
rendered = ${directory:script}/httpd-graceful
mode = 0700
context =
raw content {{ parameter_dict['apache-location'] }}/bin/httpd -Sf ${apache-conf:rendered}; if [ $? -eq 0 ]; then kill -USR1 $(cat ${apache-conf:pid-file}); fi
raw dash {{ dash_binary }}
[logrotate-apache] [logrotate-apache]
< = logrotate-entry-base < = logrotate-entry-base
name = apache name = apache
...@@ -108,7 +117,7 @@ ca = ${re6stnet-dirs:ssl}/re6stnet.crt ...@@ -108,7 +117,7 @@ ca = ${re6stnet-dirs:ssl}/re6stnet.crt
key = ${re6stnet-dirs:ssl}/re6stnet.key key = ${re6stnet-dirs:ssl}/re6stnet.key
dh = ${re6stnet-dirs:ssl}/dh.pem dh = ${re6stnet-dirs:ssl}/dh.pem
mailhost = 127.0.0.1 mailhost = 127.0.0.1
prefix-length = 16 prefix-length = {{ slapparameter_dict.get('prefix-length', 16) }}
anonymous-prefix-length = 32 anonymous-prefix-length = 32
logfile = ${re6stnet-dirs:log}/registry.log logfile = ${re6stnet-dirs:log}/registry.log
verbose = 2 verbose = 2
...@@ -123,6 +132,7 @@ context = section parameter_dict re6st-registry-conf-dict ...@@ -123,6 +132,7 @@ context = section parameter_dict re6st-registry-conf-dict
recipe = slapos.cookbook:re6stnet.registry recipe = slapos.cookbook:re6stnet.registry
command = {{ re6st_registry }} command = {{ re6st_registry }}
wrapper = ${directory:services}/re6st-registry wrapper = ${directory:services}/re6st-registry
pid-file = ${directory:run}/registry.pid
manager-wrapper = ${directory:bin}/re6stManageToken manager-wrapper = ${directory:bin}/re6stManageToken
check-service-wrapper = ${directory:bin}/re6stCheckService check-service-wrapper = ${directory:bin}/re6stCheckService
drop-service-wrapper = ${directory:bin}/re6stManageDeleteToken drop-service-wrapper = ${directory:bin}/re6stManageDeleteToken
...@@ -178,6 +188,7 @@ command = {{ python_bin }} ${re6st-registry:drop-service-wrapper} ...@@ -178,6 +188,7 @@ command = {{ python_bin }} ${re6st-registry:drop-service-wrapper}
< = logrotate-entry-base < = logrotate-entry-base
name = re6stnet name = re6stnet
log = ${re6st-registry-conf-dict:logfile} log = ${re6st-registry-conf-dict:logfile}
post = {{ parameter_dict['bin-directory'] }}/slapos-kill --pidfile ${re6st-registry:pid-file} -s USR1
[re6st-registry-promise] [re6st-registry-promise]
recipe = slapos.cookbook:check_port_listening recipe = slapos.cookbook:check_port_listening
...@@ -193,6 +204,7 @@ port = ${apache-conf:port} ...@@ -193,6 +204,7 @@ port = ${apache-conf:port}
{% do publish_dict.__setitem__('re6stry-url', uri_scheme ~ '://[${apache-conf:ipv6}]:${apache-conf:port}') -%} {% do publish_dict.__setitem__('re6stry-url', uri_scheme ~ '://[${apache-conf:ipv6}]:${apache-conf:port}') -%}
{% do publish_dict.__setitem__('re6stry-local-url', 'http://${re6st-registry:ipv4}:${re6st-registry:port}/') -%} {% do publish_dict.__setitem__('re6stry-local-url', 'http://${re6st-registry:ipv4}:${re6st-registry:port}/') -%}
{% do publish_dict.__setitem__('slave-amount', '${re6st-registry:slave-amount}') -%}
[publish] [publish]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
{% for name, value in publish_dict.items() -%} {% for name, value in publish_dict.items() -%}
...@@ -213,6 +225,7 @@ parts = ...@@ -213,6 +225,7 @@ parts =
cron-entry-re6st-drop cron-entry-re6st-drop
cron-entry-re6st-revoke cron-entry-re6st-revoke
apache-httpd apache-httpd
apache-httpd-graceful
publish publish
re6st-registry-promise re6st-registry-promise
......
...@@ -33,6 +33,7 @@ python-executable = {{ python_with_eggs }} ...@@ -33,6 +33,7 @@ python-executable = {{ python_with_eggs }}
re6st-registry = {{ bin_directory }}/re6st-registry re6st-registry = {{ bin_directory }}/re6st-registry
re6stnet = {{ bin_directory }}/re6stnet re6stnet = {{ bin_directory }}/re6stnet
template-apache-conf = {{ template_apache_conf }} template-apache-conf = {{ template_apache_conf }}
template-wrapper = {{ template_wrapper }}
apache-location = {{ apache_location }} apache-location = {{ apache_location }}
template-re6st-registry-conf = {{ template_re6st_registry_conf }} template-re6st-registry-conf = {{ template_re6st_registry_conf }}
......
...@@ -13,6 +13,7 @@ extends = ...@@ -13,6 +13,7 @@ extends =
develop = develop =
${:parts-directory}/re6stnet-repository ${:parts-directory}/re6stnet-repository
${:parts-directory}/slapos.cookbook-repository
parts = parts =
slapos-cookbook slapos-cookbook
...@@ -47,7 +48,7 @@ eggs = ...@@ -47,7 +48,7 @@ eggs =
[re6stnet-repository] [re6stnet-repository]
repository = http://git.erp5.org/repos/re6stnet.git repository = http://git.erp5.org/repos/re6stnet.git
branch = re6st-slapos branch = re6st-slapos
revision = e70bead521b3e8747865b089124a71d54988da16 revision =
[slapos.cookbook-repository] [slapos.cookbook-repository]
...@@ -79,7 +80,7 @@ context = ...@@ -79,7 +80,7 @@ context =
< = template-jinja2-base < = template-jinja2-base
filename = template.cfg filename = template.cfg
template = ${:_profile_base_location_}/instance.cfg.in template = ${:_profile_base_location_}/instance.cfg.in
md5sum = ded1faad7f289ffe9ac7aeee3d98413e md5sum = 1f39ec8d7d91c0ba2b4ad56f27ebac39
extra-context = extra-context =
key apache_location apache:location key apache_location apache:location
key dash_location dash:location key dash_location dash:location
...@@ -89,12 +90,13 @@ extra-context = ...@@ -89,12 +90,13 @@ extra-context =
key template_re6stnet template-re6stnet:target key template_re6stnet template-re6stnet:target
key template_re6st_registry_conf template-re6st-registry-conf:target key template_re6st_registry_conf template-re6st-registry-conf:target
key template_logrotate_base template-logrotate-base:rendered key template_logrotate_base template-logrotate-base:rendered
key template_wrapper template-wrapper:target
raw python_with_eggs ${buildout:directory}/bin/${extra-eggs:interpreter} raw python_with_eggs ${buildout:directory}/bin/${extra-eggs:interpreter}
[template-re6stnet] [template-re6stnet]
< = download-base < = download-base
filename = instance-re6stnet.cfg.in filename = instance-re6stnet.cfg.in
md5sum = df2a0c4f63c5e12cbd314cc02fbf23e1 md5sum = 3f72b0d5ef63b037e26e742e8eecaa1d
[template-logrotate-base] [template-logrotate-base]
< = template-jinja2-base < = template-jinja2-base
...@@ -108,19 +110,25 @@ extra-context = ...@@ -108,19 +110,25 @@ extra-context =
[template-apache-conf] [template-apache-conf]
< = download-base < = download-base
filename = apache.conf.in filename = apache.conf.in
md5sum = c220229ee37866c8cc404d602edd389d md5sum = 6fcf417f6b9651b1ed442f00c094f50c
[template-re6st-registry-conf] [template-re6st-registry-conf]
< = download-base < = download-base
filename = re6st-registry.conf.in filename = re6st-registry.conf.in
md5sum = 7760a213896755e707993d67d8d980bb md5sum = 7760a213896755e707993d67d8d980bb
[template-wrapper]
< = download-base
filename = wrapper.in
md5sum = 69e63cb58267335e21da772bd867657e
[check-recipe] [check-recipe]
recipe = plone.recipe.command recipe = plone.recipe.command
stop-on-error = true stop-on-error = true
update-command = ${:command} update-command = ${:command}
command = command =
grep parts ${buildout:develop-eggs-directory}/re6stnet.egg-link grep parts ${buildout:develop-eggs-directory}/re6stnet.egg-link
grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link
[versions] [versions]
apache-libcloud = 0.17.0 apache-libcloud = 0.17.0
......
#!{{ dash }}
{{ content }}
\ No newline at end of file
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