Commit 7ece1a48 authored by Julien Muchembled's avatar Julien Muchembled

New recipe 'switch-softwaretype' deprecating 'softwaretype'

The inline recipe for ERP5 has been improved and converted into recipe,
which is reused for NEO.

Templates are instanciated only if they're used, so no need anymore to
wrap them with:

  {% if slap_software_type == software_type -%}
  ...
  {% endif %}
parent 6f11404d
...@@ -189,12 +189,13 @@ setup(name=name, ...@@ -189,12 +189,13 @@ setup(name=name,
'slapmonitor = slapos.recipe.slapmonitor:MonitorRecipe', 'slapmonitor = slapos.recipe.slapmonitor:MonitorRecipe',
'slapmonitor-xml = slapos.recipe.slapmonitor:MonitorXMLRecipe', 'slapmonitor-xml = slapos.recipe.slapmonitor:MonitorXMLRecipe',
'slapreport = slapos.recipe.slapreport:Recipe', 'slapreport = slapos.recipe.slapreport:Recipe',
'softwaretype = slapos.recipe.softwaretype:Recipe', 'softwaretype = slapos.recipe.softwaretype:Recipe', # BBB
'sphinx= slapos.recipe.sphinx:Recipe', 'sphinx= slapos.recipe.sphinx:Recipe',
'squid = slapos.recipe.squid:Recipe', 'squid = slapos.recipe.squid:Recipe',
'sshkeys_authority = slapos.recipe.sshkeys_authority:Recipe', 'sshkeys_authority = slapos.recipe.sshkeys_authority:Recipe',
'sshkeys_authority.request = slapos.recipe.sshkeys_authority:Request', 'sshkeys_authority.request = slapos.recipe.sshkeys_authority:Request',
'stunnel = slapos.recipe.stunnel:Recipe', 'stunnel = slapos.recipe.stunnel:Recipe',
'switch-softwaretype = slapos.recipe.switch_softwaretype:Recipe',
'symbolic.link = slapos.recipe.symbolic_link:Recipe', 'symbolic.link = slapos.recipe.symbolic_link:Recipe',
'tidstorage = slapos.recipe.tidstorage:Recipe', 'tidstorage = slapos.recipe.tidstorage:Recipe',
'trac = slapos.recipe.trac:Recipe', 'trac = slapos.recipe.trac:Recipe',
......
##############################################################################
#
# Copyright (c) 2014 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 advised 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
import os, subprocess, sys
class Recipe:
def __init__(self, buildout, name, options):
self.buildout = buildout
self.options = options
self.name = name
self.software_type = buildout["slap-configuration"]["slap-software-type"]
section, key = self.options[self.software_type].split(":")
self.base = self.buildout[section][key]
def install(self):
# XXX-Antoine: We gotta find a better way to do this. I tried to check
# out how slapgrid-cp was running buildout. But it is worse than that.
args = sys.argv[:]
for x in self.buildout["slap-connection"].iteritems():
args.append("slap-connection:%s=%s" % x)
for x in "directory", "eggs-directory", "develop-eggs-directory":
args.append("buildout:%s=%s" % (x, self.buildout["buildout"][x]))
args.append("buildout:installed=.installed-%s.cfg" % self.name)
# Options.get (from zc.buildout) should deserialize.
try:
override = self.options["override"][self.software_type]
except (KeyError, TypeError):
buildout = self.base
else:
# unfortunately, buildout:extends does not work when given at command line
buildout = os.path.join(self.buildout["buildout"]["parts-directory"],
self.name + ".cfg")
with open(override) as src, open(buildout, "w", 0) as dst:
dst.write("[buildout]\nextends = %s\n\n" % self.base + src.read())
subprocess.check_call(args + ["-oc", buildout])
return []
update = install
{% if slap_software_type not in (
mysql_storage_software_type,
admin_software_type,
) -%}
{% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%} {% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%}
{% set part_list = [] -%} {% set part_list = [] -%}
{% set master_list = [] -%} {% set master_list = [] -%}
...@@ -73,12 +69,9 @@ name = {{ section_id }} ...@@ -73,12 +69,9 @@ name = {{ section_id }}
{% endfor -%} {% endfor -%}
[buildout] [buildout]
parts = parts =
{{ part_list | join('\n\t') }} {{ part_list | join('\n\t') }}
publish publish
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
offline = true
[all-masters] [all-masters]
addresses = {% for master in master_list -%} addresses = {% for master in master_list -%}
...@@ -91,4 +84,3 @@ addresses = {% for admin in admin_list -%} ...@@ -91,4 +84,3 @@ addresses = {% for admin in admin_list -%}
{{ '${' + admin + ':connection-admin}' -}} {{ '${' + admin + ':connection-admin}' -}}
{% if not loop.last %} {% endif -%} {% if not loop.last %} {% endif -%}
{% endfor %} {% endfor %}
{% endif -%}
[buildout] [buildout]
parts = parts =
neo-admin-run-wrapper
neo-admin-promise neo-admin-promise
eggs-directory = {{eggs_directory}}
develop-eggs-directory = {{develop_eggs_directory}}
offline = true
[neo-admin] [neo-admin]
recipe = slapos.cookbook:neoppod.admin recipe = slapos.cookbook:neoppod.admin
binary = {{bin_directory}}/neoadmin binary = {{bin_directory}}/neoadmin
wrapper = ${directory:bin}/neoadmin wrapper = ${directory:run}/neoadmin
logfile = ${directory:log}/neoadmin.log logfile = ${directory:log}/neoadmin.log
ip = ${publish:ip} ip = ${publish:ip}
port = ${publish:port} port = ${publish:port}
cluster = ${slap-parameter:cluster} cluster = {{ dumps(slapparameter_dict['cluster']) }}
masters = ${slap-parameter:masters} masters = {{ dumps(slapparameter_dict['masters']) }}
[publish] [publish]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
# TODO: make port a partition parameter # TODO: make port a partition parameter
# TODO: stop using slap-network-information ip = {{ (ipv4_set | list)[0] }}
ip = [${slap-network-information:global-ipv6}]
port = 10002 port = 10002
admin = ${:ip}:${:port} admin = ${:ip}:${:port}
[neo-admin-run-wrapper]
recipe = slapos.cookbook:symbolic.link
target-directory = ${directory:run}
link-binary = ${neo-admin:wrapper}
[directory] [directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
promises = ${buildout:directory}/etc/promises promises = ${buildout:directory}/etc/promises
run = ${buildout:directory}/etc/run run = ${buildout:directory}/etc/run
log = ${buildout:directory}/var/log log = ${buildout:directory}/var/log
bin = ${buildout:directory}/bin
[neo-admin-promise] [neo-admin-promise]
recipe = slapos.cookbook:check_port_listening recipe = slapos.cookbook:check_port_listening
......
[buildout] [buildout]
parts = parts =
neo-master-run-wrapper
neo-master-promise neo-master-promise
eggs-directory = {{eggs_directory}}
develop-eggs-directory = {{develop_eggs_directory}}
offline = true
[neo-master] [neo-master]
recipe = slapos.cookbook:neoppod.master recipe = slapos.cookbook:neoppod.master
binary = {{bin_directory}}/neomaster binary = {{bin_directory}}/neomaster
wrapper = ${directory:bin}/neomaster wrapper = ${directory:run}/neomaster
logfile = ${directory:log}/neomaster.log logfile = ${directory:log}/neomaster.log
ip = ${publish:ip} ip = ${publish:ip}
port = ${publish:port} port = ${publish:port}
cluster = ${slap-parameter:cluster} cluster = {{ dumps(slapparameter_dict['cluster']) }}
partitions = ${slap-parameter:partitions} partitions = {{ dumps(slapparameter_dict.get('partitions', 12)) }}
replicas = ${slap-parameter:replicas} replicas = {{ dumps(slapparameter_dict.get('replicas', 0)) }}
masters = ${slap-parameter:masters} # "masters" parameter is not provided when just requesting a partition.
# No actuall installation takes place at that time
# (slapos.cookbook:neoppod.master raises), but cfg expansion must succeed. So
# this default value is required.
masters = {{ dumps(slapparameter_dict.get('masters', '')) }}
[publish] [publish]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
# TODO: make port a partition parameter # TODO: make port a partition parameter
# TODO: stop using slap-network-information ip = {{ (ipv4_set | list)[0] }}
ip = [${slap-network-information:global-ipv6}]
port = 10000 port = 10000
master = ${:ip}:${:port} master = ${:ip}:${:port}
[neo-master-run-wrapper]
recipe = slapos.cookbook:symbolic.link
target-directory = ${directory:run}
link-binary = ${neo-master:wrapper}
[directory] [directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
promises = ${buildout:directory}/etc/promises promises = ${buildout:directory}/etc/promises
run = ${buildout:directory}/etc/run run = ${buildout:directory}/etc/run
log = ${buildout:directory}/var/log log = ${buildout:directory}/var/log
bin = ${buildout:directory}/bin
[neo-master-promise] [neo-master-promise]
recipe = slapos.cookbook:check_port_listening recipe = slapos.cookbook:check_port_listening
hostname = ${neo-master:ip} hostname = ${neo-master:ip}
port = ${neo-master:port} port = ${neo-master:port}
path = ${directory:promises}/neo-master-promise path = ${directory:promises}/neo-master-promise
[slap-parameter]
# "masters" parameter is not provided when just requesting a partition.
# No actuall installation takes place at that time
# (slapos.cookbook:neoppod.master raises), but cfg expansion must succeed. So
# this default value is required.
masters =
[buildout] [buildout]
extends = {{ master_cfg }} extends = {{ master_cfg }}
parts += neo-storage-run-wrapper parts += neo-storage
[mariadb-instance] [mariadb-instance]
recipe = slapos.cookbook:generic.mysql recipe = slapos.cookbook:generic.mysql
...@@ -29,21 +29,17 @@ mroonga = ...@@ -29,21 +29,17 @@ mroonga =
[neo-storage] [neo-storage]
recipe = slapos.cookbook:neoppod.storage recipe = slapos.cookbook:neoppod.storage
binary = {{ bin_directory }}/neostorage binary = {{ bin_directory }}/neostorage
wrapper = ${directory:bin}/neostorage wrapper = ${directory:etc_run}/neostorage
logfile = ${directory:log}/neostorage.log logfile = ${directory:log}/neostorage.log
ip = [${slap-network-information:global-ipv6}] ip = {{ (ipv4_set | list)[0] }}
cluster = ${slap-parameter:cluster} cluster = {{ dumps(slapparameter_dict['cluster']) }}
masters = ${slap-parameter:masters} masters = {{ dumps(slapparameter_dict.get('masters', '')) }}
database-adapter = MySQL database-adapter = MySQL
database-parameters = ${mariadb-instance:user}:${mariadb-instance:password}@${mariadb-instance:database}${mariadb-instance:socket} database-parameters = ${mariadb-instance:user}:${mariadb-instance:password}@${mariadb-instance:database}${mariadb-instance:socket}
wait-database = 60 wait-database = 60
[neo-storage-run-wrapper]
recipe = slapos.cookbook:symbolic.link
target-directory = ${directory:etc_run}
link-binary = ${neo-storage:wrapper}
[directory] [directory]
bin = ${buildout:directory}/bin
etc = ${buildout:directory}/etc etc = ${buildout:directory}/etc
var = ${buildout:directory}/var var = ${buildout:directory}/var
etc_run = ${:etc}/run etc_run = ${:etc}/run
......
...@@ -4,15 +4,6 @@ ...@@ -4,15 +4,6 @@
parts = switch-softwaretype parts = switch-softwaretype
eggs-directory = {{ eggs_directory }} eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }} develop-eggs-directory = {{ develop_eggs_directory }}
offline = true
[slap-connection]
computer-id = ${slap_connection:computer_id}
partition-id = ${slap_connection:partition_id}
server-url = ${slap_connection:server_url}
software-release-url = ${slap_connection:software_release_url}
key-file = ${slap_connection:key_file}
cert-file = ${slap_connection:cert_file}
[slap-configuration] [slap-configuration]
recipe = slapos.cookbook:slapconfiguration.serialised recipe = slapos.cookbook:slapconfiguration.serialised
...@@ -22,21 +13,42 @@ url = ${slap-connection:server-url} ...@@ -22,21 +13,42 @@ url = ${slap-connection:server-url}
key = ${slap-connection:key-file} key = ${slap-connection:key-file}
cert = ${slap-connection:cert-file} cert = ${slap-connection:cert-file}
[neo-cluster] [jinja2-template-base]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
template = {{ cluster }} rendered = ${buildout:parts-directory}/${:_buildout_section_name_}.cfg
rendered = ${buildout:parts-directory}/${:_buildout_section_name_}/cluster.cfg
extensions = jinja2.ext.do extensions = jinja2.ext.do
extra-context =
context = context =
key eggs_directory buildout:eggs-directory key ipv4_set slap-configuration:ipv4
key develop_eggs_directory buildout:develop-eggs-directory raw bin_directory {{ bin_directory }}
key slap_software_type slap-configuration:slap-software-type
key slapparameter_dict slap-configuration:configuration key slapparameter_dict slap-configuration:configuration
${:extra-context}
[neo-cluster]
<= jinja2-template-base
template = {{ cluster }}
extra-context =
raw admin_software_type {{ admin_software_type }} raw admin_software_type {{ admin_software_type }}
raw mysql_storage_software_type {{ mysql_storage_software_type }} raw mysql_storage_software_type {{ mysql_storage_software_type }}
[neo-admin]
<= jinja2-template-base
template = {{ neo_admin }}
[neo-master]
<= jinja2-template-base
template = {{ neo_master }}
[neo-storage-mysql]
<= jinja2-template-base
template = {{ neo_storage_mysql }}
extra-context =
key master_cfg neo-master:rendered
raw mariadb_location {{ mariadb_location }}
[switch-softwaretype] [switch-softwaretype]
recipe = slapos.cookbook:softwaretype recipe = slapos.cookbook:switch-softwaretype
default = ${neo-cluster:rendered} override = {{ dumps(override_switch_softwaretype |default) }}
{{ admin_software_type }} = {{ neo_admin }} default = neo-cluster:rendered
{{ mysql_storage_software_type }} = {{ neo_storage_mysql }} {{ admin_software_type }} = neo-admin:rendered
{{ mysql_storage_software_type }} = neo-storage-mysql:rendered
...@@ -23,7 +23,7 @@ parts = ...@@ -23,7 +23,7 @@ parts =
mysql-python mysql-python
neoppod neoppod
# NEO instanciation # NEO instanciation
template-instance template
[slapos-deps-eggs] [slapos-deps-eggs]
recipe = zc.recipe.egg recipe = zc.recipe.egg
...@@ -32,53 +32,39 @@ eggs = ...@@ -32,53 +32,39 @@ eggs =
${lxml-python:egg} ${lxml-python:egg}
#END LXML #END LXML
[base-template] [cluster]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.build:download
template = ${:_profile_base_location_}/${:filename}.in url = ${:_profile_base_location_}/${:_buildout_section_name_}.cfg.in
rendered = ${buildout:directory}/${:filename} md5sum = 84cba584198a26289daacb3e6d199e2b
extensions = jinja2.ext.do
extra-context =
context =
key eggs_directory buildout:eggs-directory
key develop_eggs_directory buildout:develop-eggs-directory
key bin_directory buildout:bin-directory
${:extra-context}
[template-neo-master] [instance-neo-admin]
< = base-template < = cluster
filename = instance-neo-master.cfg md5sum = d9213500262acd61f0bb8e840b9af18b
md5sum = 8947620b15535b95163c11a0efab546e
[template-neo-storage-mysql] [instance-neo-master]
< = base-template < = cluster
filename = instance-neo-storage-mysql.cfg md5sum = 00e2a270d6d4e15b77e2e651ee5e7fa9
md5sum = 518c8c41ce73f0b608fbb1c3b889ca1b
extra-context =
key mariadb_location mariadb:location
key master_cfg template-neo-master:rendered
[template-neo-admin] [instance-neo-storage-mysql]
< = base-template < = cluster
filename = instance-neo-admin.cfg md5sum = c9dcaf0f4d45dd9422c39ce6ae87dfb3
md5sum = 987f69333c563898cab21455509f8024
[template-cluster] [template]
recipe = slapos.recipe.build:download recipe = slapos.recipe.template:jinja2
url = ${:_profile_base_location_}/cluster.cfg.in
md5sum = 7177d129e171b20044bf435ed549af43
[template-instance]
< = base-template
template = ${:_profile_base_location_}/instance.cfg.in template = ${:_profile_base_location_}/instance.cfg.in
md5sum = 1d427e8aca550efda1635b4ee112f8ac
# XXX: "template.cfg" is hardcoded in instanciation recipe # XXX: "template.cfg" is hardcoded in instanciation recipe
filename = template.cfg rendered = ${buildout:directory}/template.cfg
md5sum = 17e761b371487b55b39da1c39ebb1bb6 context =
extra-context = key eggs_directory buildout:eggs-directory
key neo_master template-neo-master:rendered key develop_eggs_directory buildout:develop-eggs-directory
key neo_storage_mysql template-neo-storage-mysql:rendered key bin_directory buildout:bin-directory
key neo_admin template-neo-admin:rendered key cluster cluster:target
key cluster template-cluster:target key neo_admin instance-neo-admin:target
key neo_master instance-neo-master:target
key neo_storage_mysql instance-neo-storage-mysql:target
key mariadb_location mariadb:location
[neoppod] [neoppod]
recipe = zc.recipe.egg recipe = zc.recipe.egg
eggs = neoppod[admin, master, storage-mysqldb] eggs = neoppod[admin, ctl, master, storage-importer, storage-mysqldb]
...@@ -159,7 +159,7 @@ context = ...@@ -159,7 +159,7 @@ context =
[template-mariadb] [template-mariadb]
< = download-base < = download-base
filename = instance-mariadb.cfg.in filename = instance-mariadb.cfg.in
md5sum = 99a9e71b599def71322c86c0bd02a21e md5sum = 17c9e0f260c6464493e10582e9239409
link-binary = link-binary =
${coreutils:location}/bin/basename ${coreutils:location}/bin/basename
${coreutils:location}/bin/cat ${coreutils:location}/bin/cat
...@@ -175,12 +175,12 @@ link-binary = ...@@ -175,12 +175,12 @@ link-binary =
[template-kumofs] [template-kumofs]
< = download-base < = download-base
filename = instance-kumofs.cfg.in filename = instance-kumofs.cfg.in
md5sum = fe9a9349c4bad2ba999e9d8bac065ebb md5sum = 2e3230d57f2cfb3a9783fe808ccce08c
[template-cloudooo] [template-cloudooo]
< = download-base < = download-base
filename = instance-cloudoo.cfg.in filename = instance-cloudoo.cfg.in
md5sum = 6d52007d9bdc25ed0c83a49d63d59a18 md5sum = 838e56f46ba749dfc53b8e69e21be008
[template-zope-conf] [template-zope-conf]
< = download-base < = download-base
...@@ -205,7 +205,7 @@ md5sum = b8d2d9af0c4cab45c8337aeac28d5fae ...@@ -205,7 +205,7 @@ md5sum = b8d2d9af0c4cab45c8337aeac28d5fae
[template-create-erp5-site] [template-create-erp5-site]
< = download-base < = download-base
filename = instance-create-erp5-site.cfg.in filename = instance-create-erp5-site.cfg.in
md5sum = 2ce65ad372433ae8e11e30f3191bca68 md5sum = 408fd955a876a1004ed35f578029a7d2
[template-create-erp5-site-real] [template-create-erp5-site-real]
< = download-base < = download-base
...@@ -217,7 +217,7 @@ md5sum = e40e2e39f4941c6372f4357e8589a5cf ...@@ -217,7 +217,7 @@ md5sum = e40e2e39f4941c6372f4357e8589a5cf
# XXX: "template.cfg" is hardcoded in instanciation recipe # XXX: "template.cfg" is hardcoded in instanciation recipe
filename = template.cfg filename = template.cfg
template = ${:_profile_base_location_}/instance.cfg.in template = ${:_profile_base_location_}/instance.cfg.in
md5sum = ffe07d9516691dd57014e5af73b7443e md5sum = 92398630799f98dd3bffb0f2802d07e3
extra-context = extra-context =
key mariadb_link_binary template-mariadb:link-binary key mariadb_link_binary template-mariadb:link-binary
key zope_link_binary template-zope:link-binary key zope_link_binary template-zope:link-binary
...@@ -284,22 +284,22 @@ extra-context = ...@@ -284,22 +284,22 @@ extra-context =
[template-erp5] [template-erp5]
< = download-base < = download-base
filename = instance-erp5.cfg.in filename = instance-erp5.cfg.in
md5sum = b628da98dbed2f7e46f0de207b4bd228 md5sum = ef382581a0b8f2ad01ffc523a59bfe66
[template-neo] [template-neo]
< = download-base < = download-base
filename = instance-neo.cfg.in filename = instance-neo.cfg.in
md5sum = 7735d535aa34dfdc18a776b80bc0ca3d md5sum = 7dcac2eae332e2def17579888c045320
[template-zeo] [template-zeo]
< = download-base < = download-base
filename = instance-zeo.cfg.in filename = instance-zeo.cfg.in
md5sum = 7bbb690cb2ea38cd2aa84c8a79c50399 md5sum = 9a34fa84f8d0cfc0698ed2527f63aa61
[template-zope] [template-zope]
< = download-base < = download-base
filename = instance-zope.cfg.in filename = instance-zope.cfg.in
md5sum = e67bf593eb980761c61f126417c67b0c md5sum = 91c5b56ba750cc4010bef4845b712861
link-binary = link-binary =
${aspell:location}/bin/aspell ${aspell:location}/bin/aspell
${coreutils:location}/bin/basename ${coreutils:location}/bin/basename
...@@ -329,7 +329,7 @@ link-binary = ...@@ -329,7 +329,7 @@ link-binary =
[template-balancer] [template-balancer]
< = download-base < = download-base
filename = instance-balancer.cfg.in filename = instance-balancer.cfg.in
md5sum = 86131104949100316eece4bcae8ee1b8 md5sum = fc13d528e76eb9567925077d5472b285
[template-apache-conf] [template-apache-conf]
< = download-base < = download-base
......
{% if software_type == slap_software_type -%}
{% set part_list = [] -%} {% set part_list = [] -%}
{% set ssl_parameter_dict = slapparameter_dict.get('ssl', {}) %} {% set ssl_parameter_dict = slapparameter_dict.get('ssl', {}) %}
{% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%} {% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%}
...@@ -213,7 +212,3 @@ parts += ...@@ -213,7 +212,3 @@ parts +=
publish publish
logrotate-apache logrotate-apache
{{ part_list | join('\n ') }} {{ part_list | join('\n ') }}
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
{% endif %}
{% if software_type == slap_software_type -%}
{% set bin_directory = parameter_dict['buildout-bin-directory'] -%} {% set bin_directory = parameter_dict['buildout-bin-directory'] -%}
{% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%} {% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%}
[buildout] [buildout]
...@@ -8,8 +7,6 @@ parts = ...@@ -8,8 +7,6 @@ parts =
promise promise
promise-openoffice promise-openoffice
{% if use_ipv6 %}promise-tunnel{% endif %} {% if use_ipv6 %}promise-tunnel{% endif %}
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
[publish-cloudooo-connection-information] [publish-cloudooo-connection-information]
recipe = slapos.cookbook:publish.serialised recipe = slapos.cookbook:publish.serialised
...@@ -95,4 +92,3 @@ service = ${:etc}/run ...@@ -95,4 +92,3 @@ service = ${:etc}/run
promise = ${:etc}/promise promise = ${:etc}/promise
cloudooo-data = ${:srv}/cloudooo cloudooo-data = ${:srv}/cloudooo
font = ${:srv}/font font = ${:srv}/font
{% endif %}
{% if software_type == slap_software_type -%}
{# To create the script (wrapper) which creates the ERP5Site object, pieces {# To create the script (wrapper) which creates the ERP5Site object, pieces
# of what is published by extended file are required. Because they are not # of what is published by extended file are required. Because they are not
# available at the time the file you are reading is rendered, and because # available at the time the file you are reading is rendered, and because
...@@ -39,4 +38,3 @@ slapos_promise = ...@@ -39,4 +38,3 @@ slapos_promise =
extends = {{ parameter_dict['instance-erp5'] }} extends = {{ parameter_dict['instance-erp5'] }}
parts += parts +=
instance-create-erp5-site-real-run instance-create-erp5-site-real-run
{% endif %}
{% if slap_software_type == software_type -%}
{% set frontend_dict = slapparameter_dict.get('frontend', {}) %} {% set frontend_dict = slapparameter_dict.get('frontend', {}) %}
{% set has_frontend = frontend_dict.get('software-url', '') != '' -%} {% set has_frontend = frontend_dict.get('software-url', '') != '' -%}
{% set site_id = slapparameter_dict.get('site-id', 'erp5') -%} {% set site_id = slapparameter_dict.get('site-id', 'erp5') -%}
...@@ -222,6 +221,3 @@ hosts-dict = {{ '${' ~ zope_address_list_id_dict.keys()[0] ~ ':connection-hosts- ...@@ -222,6 +221,3 @@ hosts-dict = {{ '${' ~ zope_address_list_id_dict.keys()[0] ~ ':connection-hosts-
[buildout] [buildout]
parts = publish parts = publish
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
{% endif %}
{% if software_type == slap_software_type -%}
{% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%} {% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%}
[buildout] [buildout]
parts = parts =
...@@ -13,9 +12,6 @@ parts = ...@@ -13,9 +12,6 @@ parts =
promise-kumofs-gateway promise-kumofs-gateway
promise-kumofs-manager promise-kumofs-manager
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
[publish-kumofs-connection-information] [publish-kumofs-connection-information]
recipe = slapos.cookbook:publish.serialised recipe = slapos.cookbook:publish.serialised
{% if use_ipv6 -%} {% if use_ipv6 -%}
...@@ -156,4 +152,3 @@ port = ${kumofs-instance:gateway-port} ...@@ -156,4 +152,3 @@ port = ${kumofs-instance:gateway-port}
<= promise-template <= promise-template
path = ${basedirectory:promise}/kumofs-manager path = ${basedirectory:promise}/kumofs-manager
port = ${kumofs-instance:manager-port} port = ${kumofs-instance:manager-port}
{% endif %}
{% if software_type == slap_software_type -%}
{% set part_list = [] -%} {% set part_list = [] -%}
{% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%} {% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%}
{% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%} {% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%}
...@@ -229,7 +228,3 @@ parts += ...@@ -229,7 +228,3 @@ parts +=
mysqld mysqld
promise promise
{{ part_list | join('\n ') }} {{ part_list | join('\n ') }}
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
{% endif %}
{% if software_type == slap_software_type -%}
{% set zodb_dict = {} -%} {% set zodb_dict = {} -%}
{% for export_id, mountpoint_dict in slapparameter_dict['zodb-dict'].items() -%} {% for export_id, mountpoint_dict in slapparameter_dict['zodb-dict'].items() -%}
{% do zodb_dict.__setitem__(export_id, [ {% do zodb_dict.__setitem__(export_id, [
...@@ -15,6 +14,3 @@ zodb-dict = {{ dumps(zodb_dict) }} ...@@ -15,6 +14,3 @@ zodb-dict = {{ dumps(zodb_dict) }}
[buildout] [buildout]
parts += parts +=
publish publish
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
{% endif %}
{% if software_type == slap_software_type -%}
{% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%} {% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%}
{% set next_port = slapparameter_dict['tcpv4-port'] -%} {% set next_port = slapparameter_dict['tcpv4-port'] -%}
{% set part_list = [] -%} {% set part_list = [] -%}
...@@ -232,6 +231,3 @@ extends = ...@@ -232,6 +231,3 @@ extends =
parts += parts +=
{{ part_list | join('\n ') }} {{ part_list | join('\n ') }}
publish publish
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
{% endif %}
{% if slap_software_type == software_type -%}
{% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%} {% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%}
{% set next_port = slapparameter_dict['port-base'] -%} {% set next_port = slapparameter_dict['port-base'] -%}
{% set site_id = slapparameter_dict['site-id'] -%} {% set site_id = slapparameter_dict['site-id'] -%}
...@@ -362,8 +361,6 @@ bt5 = {{ dumps(slapparameter_dict['bt5']) }} ...@@ -362,8 +361,6 @@ bt5 = {{ dumps(slapparameter_dict['bt5']) }}
bt5-repository-url = {{ dumps(slapparameter_dict['bt5-repository-url']) }} bt5-repository-url = {{ dumps(slapparameter_dict['bt5-repository-url']) }}
[buildout] [buildout]
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
extends = extends =
{{ parameter_dict['instance-logrotate-cfg'] }} {{ parameter_dict['instance-logrotate-cfg'] }}
parts += parts +=
...@@ -374,4 +371,3 @@ versions = versions ...@@ -374,4 +371,3 @@ versions = versions
[versions] [versions]
slapos.core = {{ slapos_core_version }} slapos.core = {{ slapos_core_version }}
{% endif %}
[buildout] [buildout]
parts = parts = switch-softwaretype
switch-softwaretype
eggs-directory = {{ eggs_directory }} eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }} develop-eggs-directory = {{ develop_eggs_directory }}
...@@ -20,9 +18,6 @@ extra-context = ...@@ -20,9 +18,6 @@ extra-context =
context = context =
key ipv4_set slap-configuration:ipv4 key ipv4_set slap-configuration:ipv4
key ipv6_set slap-configuration:ipv6 key ipv6_set slap-configuration:ipv6
key eggs_directory buildout:eggs-directory
key develop_eggs_directory buildout:develop-eggs-directory
key slap_software_type slap-configuration:slap-software-type
key slapparameter_dict slap-configuration:configuration key slapparameter_dict slap-configuration:configuration
key computer_id slap-configuration:computer key computer_id slap-configuration:computer
raw slapos_core_version {{ slapos_core_version }} raw slapos_core_version {{ slapos_core_version }}
...@@ -59,8 +54,7 @@ template = {{ template_cloudooo }} ...@@ -59,8 +54,7 @@ template = {{ template_cloudooo }}
filename = instance-cloudoo.cfg filename = instance-cloudoo.cfg
extra-context = extra-context =
section parameter_dict dynamic-template-cloudooo-parameters section parameter_dict dynamic-template-cloudooo-parameters
# Must match the key id in [switch-softwaretype] which uses this section.
raw software_type cloudooo
[dynamic-template-erp5-parameters] [dynamic-template-erp5-parameters]
local-bt5-repository = {{ local_bt5_repository }} local-bt5-repository = {{ local_bt5_repository }}
...@@ -71,17 +65,6 @@ filename = instance-erp5.cfg ...@@ -71,17 +65,6 @@ filename = instance-erp5.cfg
extensions = jinja2.ext.do extensions = jinja2.ext.do
extra-context = extra-context =
key local_bt5_repository dynamic-template-erp5-parameters:local-bt5-repository key local_bt5_repository dynamic-template-erp5-parameters:local-bt5-repository
# Must match the key id in [switch-softwaretype] which uses this section.
key software_type :software-type
software-type = default
[dynamic-template-erp5-RootSoftwareInstance]
< = dynamic-template-erp5
software-type = RootSoftwareInstance
[dynamic-template-erp5-create-erp5-site]
< = dynamic-template-erp5
software-type = create-erp5-site
[dynamic-template-balancer-parameters] [dynamic-template-balancer-parameters]
apache = {{ apache_location }} apache = {{ apache_location }}
...@@ -101,17 +84,12 @@ extensions = jinja2.ext.do ...@@ -101,17 +84,12 @@ extensions = jinja2.ext.do
filename = instance-balancer.cfg filename = instance-balancer.cfg
extra-context = extra-context =
section parameter_dict dynamic-template-balancer-parameters section parameter_dict dynamic-template-balancer-parameters
# Must match the key id in [switch-softwaretype] which uses this section.
raw software_type balancer
[dynamic-template-neo] [dynamic-template-neo]
< = jinja2-template-base < = jinja2-template-base
template = {{ template_neo }} template = {{ template_neo }}
filename = instance-neo.cfg filename = instance-neo.cfg
extensions = jinja2.ext.do extensions = jinja2.ext.do
extra-context =
# Must match the key id in [switch-softwaretype] which uses this section.
raw software_type zodb-neo
[dynamic-template-zeo-parameters] [dynamic-template-zeo-parameters]
buildout-bin-directory = {{ buildout_bin_directory }} buildout-bin-directory = {{ buildout_bin_directory }}
...@@ -129,8 +107,6 @@ extra-context = ...@@ -129,8 +107,6 @@ extra-context =
key buildout_directory buildout:directory key buildout_directory buildout:directory
section parameter_dict dynamic-template-zeo-parameters section parameter_dict dynamic-template-zeo-parameters
import json_module json import json_module json
# Must match the key id in [switch-softwaretype] which uses this section.
raw software_type zodb-zeo
[dynamic-template-zope-parameters] [dynamic-template-zope-parameters]
bin-directory = {{ bin_directory }} bin-directory = {{ bin_directory }}
...@@ -153,13 +129,6 @@ extra-context = ...@@ -153,13 +129,6 @@ extra-context =
key buildout_directory buildout:directory key buildout_directory buildout:directory
section parameter_dict dynamic-template-zope-parameters section parameter_dict dynamic-template-zope-parameters
import urlparse urlparse import urlparse urlparse
# Must match the key id in [switch-softwaretype] which uses this section.
key software_type :software-type
software-type = zope
[dynamic-template-cluster-zope]
< = dynamic-template-zope
software-type = cluster-zope
[dynamic-template-kumofs-parameters] [dynamic-template-kumofs-parameters]
dash-location = {{ dash_location }} dash-location = {{ dash_location }}
...@@ -174,8 +143,6 @@ template = {{ template_kumofs }} ...@@ -174,8 +143,6 @@ template = {{ template_kumofs }}
filename = instance-kumofs.cfg filename = instance-kumofs.cfg
extra-context = extra-context =
section parameter_dict dynamic-template-kumofs-parameters section parameter_dict dynamic-template-kumofs-parameters
# Must match the key id in [switch-softwaretype] which uses this section.
raw software_type kumofs
[dynamic-template-mariadb-parameters] [dynamic-template-mariadb-parameters]
coreutils-location = {{ coreutils_location }} coreutils-location = {{ coreutils_location }}
...@@ -197,11 +164,9 @@ filename = instance-mariadb.cfg ...@@ -197,11 +164,9 @@ filename = instance-mariadb.cfg
extensions = jinja2.ext.do extensions = jinja2.ext.do
extra-context = extra-context =
section parameter_dict dynamic-template-mariadb-parameters section parameter_dict dynamic-template-mariadb-parameters
# Must match the key id in [switch-softwaretype] which uses this section.
raw software_type mariadb
[dynamic-template-create-erp5-site-parameters] [dynamic-template-create-erp5-site-parameters]
instance-erp5 = ${dynamic-template-erp5-create-erp5-site:rendered} instance-erp5 = ${dynamic-template-erp5:rendered}
template-create-erp5-site-real = {{ template_create_erp5_site_real }} template-create-erp5-site-real = {{ template_create_erp5_site_real }}
dash-location = {{ dash_location }} dash-location = {{ dash_location }}
curl-location = {{ curl_location }} curl-location = {{ curl_location }}
...@@ -212,45 +177,20 @@ template = {{ template_create_erp5_site }} ...@@ -212,45 +177,20 @@ template = {{ template_create_erp5_site }}
filename = instance-create-erp5-site.cfg filename = instance-create-erp5-site.cfg
extra-context = extra-context =
section parameter_dict dynamic-template-create-erp5-site-parameters section parameter_dict dynamic-template-create-erp5-site-parameters
# Must match the key id in [switch-softwaretype] which uses this section.
raw software_type create-erp5-site
[switch-softwaretype] [switch-softwaretype]
recipe = slapos.recipe.build recipe = slapos.cookbook:switch-softwaretype
script =
import subprocess, sys
software_type = self.buildout["slap-configuration"]["slap-software-type"]
# XXX-Antoine: We gotta find a better way to do this. I tried to check
# out how slapgrid-cp was running buildout. But it is worse than that.
args = sys.argv[:]
args += map("slap-connection:%%s=%%s".__mod__,
self.buildout["slap-connection"].iteritems())
args += ("buildout:directory=${buildout:directory}",
"buildout:installed=.installed-${:_buildout_section_name_}.cfg")
buildout = self.options[software_type]
# Options.get (from zc.buildout) should deserialize.
try: override = open(self.options["override"][software_type]).read()
except (KeyError, TypeError): pass
else: \
override = "[buildout]\nextends = %%s\n\n" %% buildout + override; \
buildout = "${buildout:parts-directory}/${:_buildout_section_name_}.cfg"; \
open(buildout, "w", 0).write(override)
subprocess.check_call(args + ["-oc", buildout])
update_script = ${:script}
slapos_promise =
slapos_update_promise = ${:slapos_promise}
override = {{ dumps(override_switch_softwaretype |default) }} override = {{ dumps(override_switch_softwaretype |default) }}
# Public software types # Public software types
default = ${dynamic-template-erp5:rendered} default = dynamic-template-erp5:rendered
create-erp5-site = ${dynamic-template-create-erp5-site:rendered} create-erp5-site = dynamic-template-create-erp5-site:rendered
# BBB: Legacy software types, aliased to "default" RootSoftwareInstance = ${:default} # BBB
RootSoftwareInstance = ${dynamic-template-erp5-RootSoftwareInstance:rendered}
# Internal software types # Internal software types
kumofs = ${dynamic-template-kumofs:rendered} kumofs = dynamic-template-kumofs:rendered
cloudooo = ${dynamic-template-cloudooo:rendered} cloudooo = dynamic-template-cloudooo:rendered
mariadb = ${dynamic-template-mariadb:rendered} mariadb = dynamic-template-mariadb:rendered
balancer = ${dynamic-template-balancer:rendered} balancer = dynamic-template-balancer:rendered
zodb-neo = ${dynamic-template-neo:rendered} zodb-neo = dynamic-template-neo:rendered
zodb-zeo = ${dynamic-template-zeo:rendered} zodb-zeo = dynamic-template-zeo:rendered
zope = ${dynamic-template-zope:rendered} zope = dynamic-template-zope:rendered
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