Commit 57cca9ae authored by Rafael Monnerat's avatar Rafael Monnerat

monitor-sr: Fix json generatation for distributor

  The final file were not a valid json sometimes as some entries '0.0.0.0' or '::' were been ignored
  and an additionalcomman was added on the wrong place.
parent df7adade
{% set slave_list = json_module.loads(slave_information.get('slave_instance_list', '{}')) -%} {% set slave_list = json_module.loads(slave_information.get('slave_instance_list', '{}')) -%}
{% set ipv4_list = [] -%}
{% set ipv6_list = [] -%}
{% set url_list = [] -%}
{% set name_list = [] -%}
{% for slave_instance in slave_list -%}
{% if slave_instance.get('ping_ip_list') not in [None, "", "0.0.0.0"] -%}
{% do ipv4_list.append(slave_instance.get('ping_ip_list')) -%}
{% endif -%}
{% if slave_instance.get('ping6_ip_list') not in [None, "", "::"] -%}
{% do ipv6_list.append(slave_instance.get('ping6_ip_list')) -%}
{% endif -%}
{% if slave_instance.get('test_http_url_list') not in [None, ""] -%}
{% do url_list.append(slave_instance.get('test_http_url_list')) -%}
{% endif -%}
{% if slave_instance.get('test_name_list') not in [None, ""] -%}
{% do name_list.append(slave_instance.get('test_name_list')) -%}
{% endif -%}
{% endfor -%}
{ {
"id" : "id" :
[ [
...@@ -13,55 +32,47 @@ ...@@ -13,55 +32,47 @@
], ],
"ping" : "ping" :
[ [
{% for slave_instance in slave_list -%} {% for ipv4 in ipv4_list -%}
{% if slave_instance.get('ping_ip_list') not in [None, "", "0.0.0.0"] -%} {% if ipv4 != ipv4_list[-1] -%}
{% if slave_instance != slave_list[-1] -%} "{{ ipv4 }}",
"{{ slave_instance.get('ping_ip_list') }}",
{% endif %} {% endif %}
{% if slave_instance == slave_list[-1] -%} {% if ipv4 == ipv4_list[-1] -%}
"{{ slave_instance.get('ping_ip_list') }}" "{{ ipv4 }}"
{% endif -%}
{% endif -%} {% endif -%}
{% endfor -%} {% endfor -%}
], ],
"ping6" : "ping6" :
[ [
{% for slave_instance in slave_list -%} {% for ipv6 in ipv6_list -%}
{% if slave_instance.get('ping6_ip_list') not in [None, "", "0.0.0.0"] -%} {% if ipv6 != ipv6_list[-1] -%}
{% if slave_instance != slave_list[-1] -%} "{{ ipv6 }}",
"{{ slave_instance.get('ping6_ip_list') }}", {% endif %}
{% endif -%} {% if ipv6 == ipv6_list[-1] -%}
{% if slave_instance == slave_list[-1] -%} "{{ ipv6 }}"
"{{ slave_instance.get('ping6_ip_list') }}"
{% endif -%}
{% endif -%} {% endif -%}
{% endfor -%} {% endfor -%}
], ],
"url" : "url" :
[ [
{% for slave_instance in slave_list -%} {% for url in url_list -%}
{% if slave_instance.get('test_http_url_list') not in [None, ""] -%} {% if url != url_list[-1] -%}
{% if slave_instance != slave_list[-1] -%} "{{ url }}",
"{{ slave_instance.get('test_http_url_list') }}", {% endif %}
{% endif -%} {% if url == url_list[-1] -%}
{% if slave_instance == slave_list[-1] -%} "{{ url }}"
"{{ slave_instance.get('test_http_url_list') }}"
{% endif -%}
{% endif -%} {% endif -%}
{% endfor -%} {% endfor -%}
], ],
"dns" : "dns" :
[ [
{% for slave_instance in slave_list -%} {% for name in name_list -%}
{% if slave_instance.get('test_name_list') not in [None, ""] -%} {% if name != name_list[-1] -%}
{% if slave_instance != slave_list[-1] -%} "{{ name }}",
"{{ slave_instance.get('test_name_list') }}", {% endif %}
{% endif -%} {% if name == name_list[-1] -%}
{% if slave_instance == slave_list[-1] -%} "{{ name }}"
"{{ slave_instance.get('test_name_list') }}"
{% endif -%}
{% endif -%} {% endif -%}
{% endfor -%} {% endfor -%}
] ]
......
...@@ -45,7 +45,7 @@ mode = 0644 ...@@ -45,7 +45,7 @@ mode = 0644
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/json-test-template.json.in.jinja2 url = ${:_profile_base_location_}/json-test-template.json.in.jinja2
destination = ${buildout:directory}/json-test-template.json.in.jinja2 destination = ${buildout:directory}/json-test-template.json.in.jinja2
md5sum = ee38d92178576359deb013ca6bd22299 md5sum = 2eb5596544d9c341acf653d4f7ce2680
mode = 0644 mode = 0644
......
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