Commit ede5ed34 authored by Łukasz Nowak's avatar Łukasz Nowak

WIP

Dirty fast way to instantiate ERP5: TidStorage, Zope, Zeo, haproxy, apache on
one partition.
parent cc85d574
......@@ -26,6 +26,13 @@
##############################################################################
from slapos.recipe.librecipe import GenericSlapRecipe
import os
import json
import pkg_resources
ZOPE_PORT_BASE = 12000
ZEO_PORT_BASE = 15000
HAPROXY_PORT_BASE = 11000
APACHE_PORT_BASE = 10000
class Recipe(GenericSlapRecipe):
def _options(self, options):
......@@ -34,6 +41,32 @@ class Recipe(GenericSlapRecipe):
options['output'] = os.path.join(self.dirname, self.name)
def _generateRealTemplate(self):
# always one distribution node
# always one admin node
current_zeo_port = ZEO_PORT_BASE
current_zope_port = ZOPE_PORT_BASE
json_data = json.loads(self.parameter_dict['json'])
site_id = str(json_data['site-id'])
# prepare zeo
output = ''
part_list = []
for zeo_id, zeo_configuration in json_data['zeo'].iteritems():
current_zeo_port += 1
output += pkg_resources.resource_string(__name__,
'template/snippet-zeo.cfg') % dict(
zeo_id=zeo_id,
zeo_port=current_zeo_port,
storage_list=' '.join([str(q['zodb']) for q in zeo_configuration])
) + '\n'
part_list.extend([
"zeo-instance-%s" % zeo_id,
"logrotate-entry-zeo-%s" % zeo_id
])
prepend = pkg_resources.resource_string(__name__,
'template/instance.cfg') % dict(
part_list=' \n'.join([' '+q for q in part_list]))
output = prepend + output
print output
raise NotImplementedError
def _install(self):
......
......@@ -10,46 +10,13 @@
# Example: event_module person_module
#
#############################
log-path = $${rootdirectory:log}/zeo-$${slap-parameter:zeo-id}.log
pid-path = $${rootdirectory:run}/zeo-$${slap-parameter:zeo-id}.pid
conf-path = $${rootdirectory:etc}/zeo-$${slap-parameter:zeo-id}.conf
zodb-path = $${basedirectory:zodb}
ip = $${slap-network-information:local-ipv4}
port = $${slap-parameter:zeo-port}
storage = $${slap-parameter:storage_list}
wrapper-path = $${basedirectory:services}/zeo-$${slap-parameter:zeo-id}
[buildout]
parts =
zeo-instance
logrotate
logrotate-entry-zeo
cron
cron-entry-logrotate
publish-zeo-connection-information
gzip-binary = ${gzip:location}/bin/gzip
eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/
var = $${buildout:directory}/var/
srv = $${buildout:directory}/srv/
bin = $${buildout:directory}/bin/
[basedirectory]
recipe = slapos.cookbook:mkdirectory
log = $${rootdirectory:var}/log/
services = $${rootdirectory:etc}/run/
run = $${rootdirectory:var}/run/
backup = $${rootdirectory:srv}/backup/
zodb = $${rootdirectory:srv}/zodb/
certificate-authority
%(part_list)s
[directory]
recipe = slapos.cookbook:mkdirectory
......@@ -60,18 +27,6 @@ cronoutput = $${basedirectory:log}/cron/
logrotate-backup = $${basedirectory:backup}/logrotate/
logrotate-entries = $${rootdirectory:etc}/logrotate.d/
[zeo-instance]
recipe = slapos.cookbook:zeo
log-path = $${rootdirectory:log}/zeo-$${slap-parameter:zeo-id}.log
pid-path = $${rootdirectory:run}/zeo-$${slap-parameter:zeo-id}.pid
conf-path = $${rootdirectory:etc}/zeo-$${slap-parameter:zeo-id}.conf
zodb-path = $${basedirectory:zodb}
ip = $${slap-network-information:local-ipv4}
port = $${slap-parameter:zeo-port}
storage = $${slap-parameter:storage_list}
wrapper-path = $${basedirectory:services}/zeo-$${slap-parameter:zeo-id}
binary-path = ${buildout:bin-directory}/runzeo
[publish-memcached-connection-information]
recipe = slapos.cookbook:publishurl
url = zeo://$${zeo-instance:ip}:$${zeo-instance:port}/
......@@ -97,28 +52,13 @@ name = logrotate
frequency = 0 0 * * *
command = $${logrotate:wrapper}
[logrotate-entry-zeo]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = zeo-$${slap-parameter:zeo-id}
log = $${zeo-instance:log-path}
frequency = daily
rotate-num = 3650
sharedscripts = true
notifempty = true
create = true
post = $${killpidfromfile:binary} $${zeo-instance:pid-path} SIGUSR2
[killpidfromfile]
binary = $${notimplemented:getkillpidfromfilefromsoftware}
# rest of parts are candidates for some generic stuff
[logrotate]
recipe = slapos.cookbook:logrotate
# Binaries
logrotate-binary = ${logrotate:location}/usr/sbin/logrotate
gzip-binary = $${buildout:gzip-binary}
gzip-binary = ${gzip:location}/bin/gzip
gunzip-binary = ${gzip:location}/bin/gunzip
# Directories
wrapper = $${rootdirectory:bin}/logrotate
......@@ -126,3 +66,38 @@ conf = $${rootdirectory:etc}/logrotate.conf
logrotate-entries = $${directory:logrotate-entries}
backup = $${directory:logrotate-backup}
state-file = $${rootdirectory:srv}/logrotate.status
[zeo-instance-entry-common]
recipe = slapos.cookbook:zeo
zodb-path = $${basedirectory:zodb}
ip = $${slap-network-information:local-ipv4}
binary-path = ${buildout:bin-directory}/runzeo
[logrotate-entry-common]
<= logrotate
recipe = slapos.cookbook:logrotate.d
frequency = daily
rotate-num = 3650
sharedscripts = true
notifempty = true
create = true
[certificate-authority]
recipe = slapos.cookbook:certificate_authority
openssl-binary = ${openssl:location}/bin/openssl
ca-dir = $${directory:ca-dir}
requests-directory = $${cadirectory:requests}
wrapper = $${basedirectory:services}/ca
ca-private = $${cadirectory:private}
ca-certs = $${cadirectory:certs}
ca-newcerts = $${cadirectory:newcerts}
ca-crl = $${cadirectory:crl}
[cadirectory]
recipe = slapos.cookbook:mkdirectory
requests = $${directory:ca-dir}/requests/
private = $${directory:ca-dir}/private/
certs = $${directory:ca-dir}/certs/
newcerts = $${directory:ca-dir}/newcerts/
crl = $${directory:ca-dir}/crl/
[zeo-instance-%(zeo_id)s]
<= zeo-instance-entry-common
log-path = $${rootdirectory:log}/zeo-%(zeo_id)s.log
pid-path = $${rootdirectory:run}/zeo-%(zeo_id)s.pid
conf-path = $${rootdirectory:etc}/zeo-%(zeo_id)s.conf
port = %(zeo_port)s
storage = %(storage_list)s
wrapper-path = $${basedirectory:services}/zeo-%(zeo_id)s
[logrotate-entry-zeo-%(zeo_id)s]
<= logrotate-entry-common
name = zeo-%(zeo_id)s
log = $${zeo-instance-%(zeo_id)s:log-path}
post = ${buildout:bin-directory}/bin/killpidfromfile $${zeo-instance-%(zeo_id)s:pid-path} SIGUSR2
[buildout]
parts =
zope-instance
apache-zope-backend-instance
ca-apache-zope-backend
logrotate-entry-zope
cron-entry-logrotate
[apache-zope-backend-instance]
recipe = slapos.cookbook:apache.zope.backend
backend = http://$${zope-instance:ip}:$${zope-instance:port}/
ip = $${slap-network-information:global-ipv6}
port = 16001
wrapper = $${rootdirectory:bin}/apache
key-file = $${directory:apache-conf}/apache.key
cert-file = $${directory:apache-conf}/apache.crt
configuration-file = $${directory:apache-conf}/apache.conf
access-control-string = $${slap-parameter:access-control-string}
pid-file = $${basedirectory:run}/apache.pid
lock-file = $${basedirectory:run}/apache.lock
error-log = $${basedirectory:log}/apache-error.log
access-log = $${basedirectory:log}/apache-access.log
apache-binary = ${apache:location}/bin/httpd
[ca-apache-zope-backend]
<= certificate-authority
recipe = slapos.cookbook:certificate_authority.request
key-file = $${apache-zope-backend-instance:key-file}
cert-file = $${apache-zope-backend-instance:cert-file}
executable = $${apache-zope-backend-instance:wrapper}
wrapper = $${basedirectory:services}/apache
[zope-instance]
recipe = slapos.cookbook:generic.zope
# XXX: products won't be needed as soon as all ERP5 (and products-deps)
# products will be eggified so then it will be possible to use them thanks to
# availability in software's eggs
products = ${products:list}
# Options
user = zope
port = 12001
ip = $${slap-network-information:local-ipv4}
zodb-cache-size = 5000
thread-amount = 4
zodb-path = $${directory:zodb}/main.cfg
deadlock-path = /manage_debug_threads
# Paths
wrapper = $${basedirectory:services}/zope_development
instance-path = $${directory:instance}
instance-etc = $${directory:instance-etc}
instance-products = $${directory:instance-products}
bt5-repository = $${rootdirectory:var}/bt5_repository
tmp-path = $${rootdirectory:tmp}
bin-path = $${rootdirectory:bin}
site-zcml = $${:instance-etc}/site.zcml
logrotate-post = $${rootdirectory:bin}/zope-post-logrotate
pid-file = $${basedirectory:run}/zope.pid
lock-file = $${basedirectory:run}/zope.lock
event-log = $${basedirectory:log}/zope-event.log
z2-log = $${basedirectory:log}/zope-Z2.log
configuration-file = $${rootdirectory:etc}/zope.conf
inituser = $${:instance-path}/inituser
# Binary information
runzope-binary = ${buildout:bin-directory}/runzope
[logrotate]
recipe = slapos.cookbook:logrotate
# Binaries
logrotate-binary = ${logrotate:location}/usr/sbin/logrotate
gzip-binary = $${buildout:gzip-binary}
gunzip-binary = ${gzip:location}/bin/gunzip
# Directories
wrapper = $${rootdirectory:bin}/logrotate
conf = $${rootdirectory:etc}/logrotate.conf
logrotate-entries = $${directory:logrotate-entries}
backup = $${directory:logrotate-backup}
state-file = $${rootdirectory:srv}/logrotate.status
[logrotate-entry-zope]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = zope
log = $${zope-instance:event-log} $${zope-instance:z2-log}
frequency = daily
rotate-num = 30
post = ${buildout:bin-directory}/killpidfromfile $${zope-instance:pid-file} SIGUSR2
sharedscripts = true
notifempty = true
create = true
[logrotate-entry-apache-zope-backend]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = zope
log = $${apache-zope-backend-instance:error-log} $${apache-zope-backend-instance:access-log}
frequency = daily
rotate-num = 30
post = ${buildout:bin-directory}/killpidfromfile $${apache-zope-backend-instance:pid-file} SIGUSR1
sharedscripts = true
notifempty = true
create = true
[cron]
recipe = slapos.cookbook:cron
dcrond-binary = ${dcron:location}/sbin/crond
cron-entries = $${directory:cron-entries}
crontabs = $${directory:crontabs}
cronstamps = $${directory:cronstamps}
catcher = $${cron-simplelogger:binary}
binary = $${basedirectory:services}/crond
[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
binary = $${rootdirectory:bin}/cron_simplelogger
output = $${directory:cronoutput}
[cron-entry-logrotate]
<= cron
recipe = slapos.cookbook:cron.d
name = logrotate
frequency = 0 0 * * *
command = $${logrotate:wrapper}
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = $${buildout:directory}/etc/
var = $${buildout:directory}/var/
srv = $${buildout:directory}/srv/
bin = $${buildout:directory}/bin/
tmp = $${buildout:directory}/tmp/
[basedirectory]
recipe = slapos.cookbook:mkdirectory
log = $${rootdirectory:var}/log/
services = $${rootdirectory:etc}/run/
run = $${rootdirectory:var}/run/
backup = $${rootdirectory:srv}/backup/
[directory]
recipe = slapos.cookbook:mkdirectory
zodb = $${rootdirectory:srv}/zodb/
instance = $${rootdirectory:srv}/erp5shared/
instance-etc = $${:instance}/etc
apache-conf = $${rootdirectory:etc}/apache
instance-etc-package-include = $${:instance}/etc/package-include
# because of bug in slapos.recipe.template keys are lowercased
instance-document = $${:instance}/Document
instance-propertysheet = $${:instance}/PropertySheet
instance-products = $${:instance}/Products
instance-extensions = $${:instance}/Extensions
instance-constraint = $${:instance}/Constraint
instance-import = $${:instance}/import
instance-lib = $${:instance}/lib
instance-tests = $${:instance}/tests
ca-dir = $${rootdirectory:srv}/ssl/
cron-entries = $${rootdirectory:etc}/cron.d/
crontabs = $${rootdirectory:etc}/crontabs/
cronstamps = $${rootdirectory:etc}/cronstamps/
cronoutput = $${basedirectory:log}/cron/
logrotate-backup = $${basedirectory:backup}/logrotate/
logrotate-entries = $${rootdirectory:etc}/logrotate.d/
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