{% if slap_software_type not in (
    mysql_storage_software_type,
    admin_software_type,
) -%}
{% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%}
{% set part_list = [] -%}
{% set master_list = [] -%}
{% set admin_list = [] -%}
[request-common]
recipe = slapos.cookbook:request
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}
config-cluster = {{ slapparameter_dict['cluster'] }}

[node-base]
< = request-common
config-masters = ${all-masters:addresses}

[mysql-storage-base]
< = request-common
config-partitions = {{ slapparameter_dict.get('partitions', 12) }}
config-replicas = {{ slapparameter_dict.get('replicas', 0) }}
software-type = {{ mysql_storage_software_type }}

[mysql-storage-request-base]
< = mysql-storage-base
return = master

[admin-base]
< = node-base
return = admin
software-type = {{ admin_software_type }}

[publish]
recipe = slapos.cookbook:publish
masters = ${all-masters:addresses}
admins = ${all-admins:addresses}

{% for node_number in range(slapparameter_dict.get('mysql-storage-count', 1)) -%}
{%   set section_id = 'storage-%i' % (node_number, ) -%}
{%   set final_section_id = 'final-' ~ section_id -%}
{%   do master_list.append(section_id) -%}
[{{ section_id }}]
< = mysql-storage-request-base
name = {{ section_id }}

[{{ section(final_section_id) }}]
< = mysql-storage-base
	node-base
name = {{ section_id }}

{% endfor -%}
{% for node_number in range(slapparameter_dict.get('admin-count', 1)) -%}
{%   set section_id = 'admin-%i' % (node_number, ) -%}
{%   do admin_list.append(section_id)%}
[{{ section(section_id) }}]
< = admin-base
name = {{ section_id }}

{% endfor -%}
[buildout]
parts = 
	{{ part_list | join('\n\t') }}
	publish
eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
offline = true

[all-masters]
addresses = {% for master in master_list -%}
{{   '${' + master + ':connection-master}' -}}
{%   if not loop.last %} {% endif -%}
{% endfor %}

[all-admins]
addresses = {% for admin in admin_list -%}
{{  '${' + admin + ':connection-admin}' -}}
{%  if not loop.last %} {% endif -%}
{% endfor %}
{% endif -%}
