Commit bec28925 authored by Lisa Casino's avatar Lisa Casino

html5as: add flexible replicate

parent aa0508f5
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
[template-cfg] [template-cfg]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 8f422ac97ccfce5f6c5203411fbfe6dc md5sum = c9d39e620b6a8ff59e959a6c277b3def
[instance_html5as] [instance_html5as]
_update_hash_filename_ = instance_html5as.cfg.in _update_hash_filename_ = instance_html5as.cfg.in
...@@ -45,4 +45,4 @@ md5sum = 1c0ee16966e1fcdb3fd11c09f12ee2b2 ...@@ -45,4 +45,4 @@ md5sum = 1c0ee16966e1fcdb3fd11c09f12ee2b2
[template_instance_replicate] [template_instance_replicate]
_update_hash_filename_ = instance_replicate.cfg.in _update_hash_filename_ = instance_replicate.cfg.in
md5sum = a8ae9c9c7fcc3468bfeed5398f3b17d1 md5sum = cbbeafd86e686a28f84ca3c229584f0f
...@@ -38,6 +38,7 @@ default-parameters = ...@@ -38,6 +38,7 @@ default-parameters =
[instance-replicate] [instance-replicate]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
extensions = jinja2.ext.do
template = {{ template_instance_replicate }} template = {{ template_instance_replicate }}
rendered = ${buildout:directory}/${:filename} rendered = ${buildout:directory}/${:filename}
filename = instance-replicate-html5as.cfg filename = instance-replicate-html5as.cfg
...@@ -46,15 +47,10 @@ context = ...@@ -46,15 +47,10 @@ context =
section parameter_list profile-common section parameter_list profile-common
key slapparameter_dict slap-configuration:configuration key slapparameter_dict slap-configuration:configuration
jsonkey default_parameter_dict :default-parameters jsonkey default_parameter_dict :default-parameters
# User can specify parameter for any of the two instances
default-parameters = default-parameters =
{ {
"title": "",
"title1": "",
"title2": "",
"download_url": "", "download_url": "",
"port1": 8081, "replicate_quantity": 1
"port2": 8082
} }
[switch-softwaretype] [switch-softwaretype]
...@@ -68,3 +64,5 @@ recipe = slapos.cookbook:slapconfiguration ...@@ -68,3 +64,5 @@ recipe = slapos.cookbook:slapconfiguration
computer = ${slap-connection:computer-id} computer = ${slap-connection:computer-id}
partition = ${slap-connection:partition-id} partition = ${slap-connection:partition-id}
url = ${slap-connection:server-url} url = ${slap-connection:server-url}
key = ${slap-connection:key-file}
cert = ${slap-connection:cert-file}
{% set parameter_dict = dict(default_parameter_dict, **slapparameter_dict) %} {%- set parameter_dict = dict(default_parameter_dict, **slapparameter_dict) %}
{%- set replicate_quantity = parameter_dict['replicate-quantity'] | int %}
# Set default title and port for each replicate based on requested quantity
{%- for i in range(1, replicate_quantity + 1) %}
{%- do parameter_dict.setdefault("title%d" % i, "") %}
{%- do parameter_dict.setdefault("port%d" % i, 8081 + i) %}
{%- endfor %}
# Standard buildout section # Standard buildout section
[buildout] [buildout]
...@@ -24,40 +30,24 @@ software-type = default ...@@ -24,40 +30,24 @@ software-type = default
# What parameter are neede to be retrieved # What parameter are neede to be retrieved
return = server_url server-cdn-url monitor-setup-url return = server_url server-cdn-url monitor-setup-url
# Provided parameters # Provided parameters
config-title = {{ parameter_dict['title'] }}
config-download_url = {{ parameter_dict['download_url'] }} config-download_url = {{ parameter_dict['download_url'] }}
# Create request section in a loop.
{% for i in range(1, replicate_quantity + 1) %}
# Request a normal html5as instance # Request a normal html5as instance
[instance-1] [instance-{{ i }}]
<= instance-request-base <= instance-request-base
# Name of the instance # Name of the instance
name = instance-html5as-1 name = instance-html5as-{{ i }}
# Port and title can be configured by instance config-port = {{ parameter_dict["port%s" % i] }}
config-port = {{ parameter_dict['port1'] }} config-title = {{ parameter_dict["title%s" % i] }}
config-title = {{ parameter_dict['title1'] }} {% endfor %}
# Request a second html5as instance
[instance-2]
<= instance-request-base
# Name of the instance
name = instance-html5as-2
config-port = {{ parameter_dict['port2'] }}
config-title = {{ parameter_dict['title2'] }}
# User can specify parameter for any of the two instances
# [slap-parameter]
# title1 =
# title2 =
# download_url =
# port1 = 8081
# port2 = 8082
# Publish information to connect to the two instances # Publish information to connect to the two instances
[publish-connection-information] [publish-connection-information]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
instance-1-server_url = ${instance-1:connection-server_url} {% for i in range(1, replicate_quantity + 1) %}
instance-1-server-cdn-url = ${instance-1:connection-server-cdn-url} instance-{{ i }}-server_url = ${instance-{{ i }}:connection-server_url}
instance-1-server-monitor-setup-url = ${instance-1:connection-monitor-setup-url} instance-{{ i }}-server-cdn-url = ${instance-{{ i }}:connection-server-cdn-url}
instance-2-server_url = ${instance-2:connection-server_url} instance-{{ i }}-server-monitor-setup-url = ${instance-{{ i }}:connection-monitor-setup-url}
instance-2-server-cdn-url = ${instance-1:connection-server-cdn-url} {% endfor %}
instance-2-server-monitor-setup-url = ${instance-1:connection-monitor-setup-url}
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