cluster.cfg.in 2.07 KB
Newer Older
1
{% macro assert(x) %}{{ ("",)[not x] }}{% endmacro -%}
Vincent Pelletier's avatar
Vincent Pelletier committed
2 3
{% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%}
{% set part_list = [] -%}
4
{% set section_id_list = [] -%}
Vincent Pelletier's avatar
Vincent Pelletier committed
5
[request-common]
6
recipe = slapos.cookbook:request.serialised
Vincent Pelletier's avatar
Vincent Pelletier committed
7 8 9 10 11 12 13
software-url = ${slap-connection:software-release-url}
sla-computer_guid = ${slap-connection:computer-id}
server-url = ${slap-connection:server-url}
key-file = ${slap-connection:key-file}
cert-file = ${slap-connection:cert-file}
computer-id = ${slap-connection:computer-id}
partition-id = ${slap-connection:partition-id}
14
config-cluster = {{ dumps(slapparameter_dict['cluster']) }}
15
{% set replicas = slapparameter_dict.get('replicas', 0) -%}
16
config-partitions = {{ dumps(slapparameter_dict.get('partitions', 12)) }}
17
config-replicas = {{ dumps(replicas) }}
18 19
config-upstream-cluster = {{ dumps(slapparameter_dict.get('upstream-cluster', '')) }}
config-upstream-masters = {{ dumps(slapparameter_dict.get('upstream-masters', '')) }}
20
software-type = neo
Vincent Pelletier's avatar
Vincent Pelletier committed
21 22

[publish]
23 24 25
recipe = slapos.cookbook:publish.serialised
masters = ${node-0-final:connection-masters}
admins = ${node-0-final:connection-admins}
Vincent Pelletier's avatar
Vincent Pelletier committed
26

27 28 29 30 31
{% set node_list = slapparameter_dict.get('node-list', ({},)) -%}
{% do assert(replicas < len(node_list)) -%}
{% for i, node in enumerate(node_list) -%}
{%   set section_id = 'node-' ~ i -%}
{%   do section_id_list.append(section_id) -%}
Vincent Pelletier's avatar
Vincent Pelletier committed
32

33
[{{ section_id }}-base]
Vincent Pelletier's avatar
Vincent Pelletier committed
34
name = {{ section_id }}
35 36 37
{%   for k, v in node.iteritems() -%}
config-{{ k }} = {{ dumps(v) }}
{%   endfor -%}
Vincent Pelletier's avatar
Vincent Pelletier committed
38

39 40 41 42 43 44 45 46 47 48 49 50
[{{ section_id }}]
<= request-common
  {{ section_id }}-base
return =
  master
  admin
{% endfor -%}

[final-base]
{% for i, section_id in enumerate(section_id_list) -%}
config-master-{{i}} = {{ '${' + section_id + ':connection-master}' }}
config-admin-{{i}} = {{ '${' + section_id + ':connection-admin}' }}
Vincent Pelletier's avatar
Vincent Pelletier committed
51 52
{% endfor -%}

53 54 55 56 57 58 59 60 61 62
{% for section_id in section_id_list -%}
[{{ section(section_id + '-final') }}]
<= request-common
  final-base
  {{ section_id }}-base
{%   if loop.first -%}
return =
  masters
  admins
{%   endif -%}
Vincent Pelletier's avatar
Vincent Pelletier committed
63
{% endfor -%}
64

Vincent Pelletier's avatar
Vincent Pelletier committed
65
[buildout]
66
parts =
Vincent Pelletier's avatar
Vincent Pelletier committed
67 68
	{{ part_list | join('\n\t') }}
	publish