Skip to content

Commit

Permalink
Use YAML instead of JSON for configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
akscram committed Dec 27, 2016
1 parent e4e1ee3 commit 3dde249
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 87 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ matrix:
node_js: "4.2.6"
env:
- PYTHONPATH=/home/travis/build/seecloud/availability
- AVAILABILITY_CONF=/home/travis/build/seecloud/availability/tests/ci/api/config.json
- AVAILABILITY_CONF=/home/travis/build/seecloud/availability/tests/ci/api/config.yaml
services:
- docker
install:
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz -O - | tar xz
- ./elasticsearch-5.1.1/bin/elasticsearch -d
- docker build -t availability .
- docker run -d -p 127.0.0.1:5000:5000 --net=host -e "AVAILABILITY_CONF=/app/tests/ci/api/config.json" availability /app/entrypoint-api.sh
- docker run -d -p 127.0.0.1:5000:5000 --net=host -e "AVAILABILITY_CONF=/app/tests/ci/api/config.yaml" availability /app/entrypoint-api.sh
- git clone http://github.com/cybertk/abao && cd abao && git checkout 0.5.0
- npm install
- cp ../tests/ci/api/abao_hooks.js hooks.js
Expand Down
25 changes: 0 additions & 25 deletions etc/sample_config.json

This file was deleted.

21 changes: 21 additions & 0 deletions etc/sample_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
backend:
type: elastic
connection:
- host: 127.0.0.1
port: 9200
regions:
- name: west-1
services:
- name: nova
url: http://foo.example.org:1234/
- name: cinder
url: http://foo.example.org:4567/
- name: west-2
services:
- name: keystone
url: http://example.org/ab/
- name: cinder
url: http://example.org/cd/
period: 60
connection_timeout: 1
read_timeout: 10
2 changes: 1 addition & 1 deletion service/availability-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ service:

files:
availability.conf:
path: /etc/availability/config.json
path: /etc/availability/config.yaml
content: availability.conf.j2
2 changes: 1 addition & 1 deletion service/availability-watcher.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ service:

files:
availability.conf:
path: /etc/availability/config.json
path: /etc/availability/config.yaml
content: availability.conf.j2
53 changes: 19 additions & 34 deletions service/files/availability.conf.j2
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
{
"backend": {
"type": "elastic",
"connection": [
{%- for node in elasticsearch.hosts %}
{
"host": "{{ node.host }}",
"port": {{ node.port }}
}
{%- if loop.length > 1 and not loop.last %},{% endif -%}
{%- endfor -%}
]
},
"regions": [
{%- for region in availability.regions %}
{
"name": "{{ region.name }}",
"services": [
{%- for service in region.services -%}
{
"name": "{{ service.name }}",
"url": "{{ service.url }}"
}
{%- if loop.length > 1 and not loop.last %},{% endif -%}
{%- endfor -%}
]
}
{%- if loop.length > 1 and not loop.last %},{% endif -%}
{%- endfor %}
],
backend:
type: elastic
connection:
{%- for node in elasticsearch.hosts %}
- host: {{ node.host }}
port: {{ node.port }}
{%- endfor -%}
regions:
{%- for region in availability.regions %}
- name: {{ region.name }}
services:
{%- for service in region.services -%}
- name: {{ service.name }}
url: {{ service.url }}
{%- endfor -%}
{%- endfor %}

"period": {{ availability.watcher.period }},
"connection_timeout": {{ availability.watcher.connection_timeout }},
"read_timeout": {{ availability.watcher.read_timeout }},
}
period: {{ availability.watcher.period }}
connection_timeout: {{ availability.watcher.connection_timeout }}
read_timeout: {{ availability.watcher.read_timeout }}
24 changes: 0 additions & 24 deletions tests/ci/api/config.json

This file was deleted.

23 changes: 23 additions & 0 deletions tests/ci/api/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
backend:
type: elastic
connection:
- host: 127.0.0.1
port: 9200
regions:
- name: foo_region
services:
- name: alpha
url: http://alpha.example.org/
- name: beta
url: http://beta.example.org/
- name: gamma
url: http://gamma.example.org:5555/
- name: bar_region
services:
- name: delta
url: http://example.org/delta/
- name: epsilon
url: http://example.org/epsilon/
period: 60
connection_timeout: 1
read_timeout: 10

0 comments on commit 3dde249

Please sign in to comment.