Skip to content

Commit 3dde249

Browse files
committed
Use YAML instead of JSON for configuration
1 parent e4e1ee3 commit 3dde249

File tree

8 files changed

+67
-87
lines changed

8 files changed

+67
-87
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ matrix:
2525
node_js: "4.2.6"
2626
env:
2727
- PYTHONPATH=/home/travis/build/seecloud/availability
28-
- AVAILABILITY_CONF=/home/travis/build/seecloud/availability/tests/ci/api/config.json
28+
- AVAILABILITY_CONF=/home/travis/build/seecloud/availability/tests/ci/api/config.yaml
2929
services:
3030
- docker
3131
install:
3232
- wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.1.1.tar.gz -O - | tar xz
3333
- ./elasticsearch-5.1.1/bin/elasticsearch -d
3434
- docker build -t availability .
35-
- 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
35+
- 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
3636
- git clone http://github.com/cybertk/abao && cd abao && git checkout 0.5.0
3737
- npm install
3838
- cp ../tests/ci/api/abao_hooks.js hooks.js

etc/sample_config.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

etc/sample_config.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
backend:
2+
type: elastic
3+
connection:
4+
- host: 127.0.0.1
5+
port: 9200
6+
regions:
7+
- name: west-1
8+
services:
9+
- name: nova
10+
url: http://foo.example.org:1234/
11+
- name: cinder
12+
url: http://foo.example.org:4567/
13+
- name: west-2
14+
services:
15+
- name: keystone
16+
url: http://example.org/ab/
17+
- name: cinder
18+
url: http://example.org/cd/
19+
period: 60
20+
connection_timeout: 1
21+
read_timeout: 10

service/availability-api.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ service:
2525

2626
files:
2727
availability.conf:
28-
path: /etc/availability/config.json
28+
path: /etc/availability/config.yaml
2929
content: availability.conf.j2

service/availability-watcher.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ service:
1616

1717
files:
1818
availability.conf:
19-
path: /etc/availability/config.json
19+
path: /etc/availability/config.yaml
2020
content: availability.conf.j2

service/files/availability.conf.j2

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,20 @@
1-
{
2-
"backend": {
3-
"type": "elastic",
4-
"connection": [
5-
{%- for node in elasticsearch.hosts %}
6-
{
7-
"host": "{{ node.host }}",
8-
"port": {{ node.port }}
9-
}
10-
{%- if loop.length > 1 and not loop.last %},{% endif -%}
11-
{%- endfor -%}
12-
]
13-
},
14-
"regions": [
15-
{%- for region in availability.regions %}
16-
{
17-
"name": "{{ region.name }}",
18-
"services": [
19-
{%- for service in region.services -%}
20-
{
21-
"name": "{{ service.name }}",
22-
"url": "{{ service.url }}"
23-
}
24-
{%- if loop.length > 1 and not loop.last %},{% endif -%}
25-
{%- endfor -%}
26-
]
27-
}
28-
{%- if loop.length > 1 and not loop.last %},{% endif -%}
29-
{%- endfor %}
30-
],
1+
backend:
2+
type: elastic
3+
connection:
4+
{%- for node in elasticsearch.hosts %}
5+
- host: {{ node.host }}
6+
port: {{ node.port }}
7+
{%- endfor -%}
8+
regions:
9+
{%- for region in availability.regions %}
10+
- name: {{ region.name }}
11+
services:
12+
{%- for service in region.services -%}
13+
- name: {{ service.name }}
14+
url: {{ service.url }}
15+
{%- endfor -%}
16+
{%- endfor %}
3117

32-
"period": {{ availability.watcher.period }},
33-
"connection_timeout": {{ availability.watcher.connection_timeout }},
34-
"read_timeout": {{ availability.watcher.read_timeout }},
35-
}
18+
period: {{ availability.watcher.period }}
19+
connection_timeout: {{ availability.watcher.connection_timeout }}
20+
read_timeout: {{ availability.watcher.read_timeout }}

tests/ci/api/config.json

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/ci/api/config.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
backend:
2+
type: elastic
3+
connection:
4+
- host: 127.0.0.1
5+
port: 9200
6+
regions:
7+
- name: foo_region
8+
services:
9+
- name: alpha
10+
url: http://alpha.example.org/
11+
- name: beta
12+
url: http://beta.example.org/
13+
- name: gamma
14+
url: http://gamma.example.org:5555/
15+
- name: bar_region
16+
services:
17+
- name: delta
18+
url: http://example.org/delta/
19+
- name: epsilon
20+
url: http://example.org/epsilon/
21+
period: 60
22+
connection_timeout: 1
23+
read_timeout: 10

0 commit comments

Comments
 (0)