Merge ~paulgear/influxdb-charm/+git/influxdb-charm:master into influxdb-charm:master

Proposed by Paul Gear
Status: Merged
Merged at revision: 2d8533e9b9e72a39eee877dea01440415bd7cab2
Proposed branch: ~paulgear/influxdb-charm/+git/influxdb-charm:master
Merge into: influxdb-charm:master
Diff against target: 101 lines (+34/-31)
2 files modified
layer.yaml (+1/-1)
reactive/influxdb.py (+33/-30)
Reviewer Review Type Date Requested Status
Haw Loeung Approve
Review via email: mp+332167@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Haw Loeung (hloeung) wrote :

LGTM, +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/layer.yaml b/layer.yaml
index fec7bfa..37d19f1 100644
--- a/layer.yaml
+++ b/layer.yaml
@@ -1,4 +1,4 @@
1repo: https://github.com/ChrisMacNaughton/charm-influx1repo: https://git.launchpad.net/influxdb-charm
2includes:2includes:
3 - layer:basic3 - layer:basic
4 - layer:apt4 - layer:apt
diff --git a/reactive/influxdb.py b/reactive/influxdb.py
index 126258b..56e7a22 100644
--- a/reactive/influxdb.py
+++ b/reactive/influxdb.py
@@ -2,9 +2,8 @@ from charmhelpers.core import hookenv
2from charmhelpers.core.host import service_start, service_stop2from charmhelpers.core.host import service_start, service_stop
3from charmhelpers.core.templating import render3from charmhelpers.core.templating import render
4from charms.reactive import when, when_not4from charms.reactive import when, when_not
5from charms.reactive import set_state, remove_state5from charms.reactive import set_state
66
7from subprocess import check_call, CalledProcessError
87
9@when('admin.available')8@when('admin.available')
10def configure_website(website):9def configure_website(website):
@@ -12,43 +11,47 @@ def configure_website(website):
12 port = config.get('bind_port')11 port = config.get('bind_port')
13 website.configure(port=port)12 website.configure(port=port)
1413
14
15@when_not('influxdb.configured')15@when_not('influxdb.configured')
16@when('apt.installed.influxdb')16@when('apt.installed.influxdb')
17def install_influx():17def install_influx():
18 config = hookenv.config()18 config = hookenv.config()
19 port = config.get('bind_port')19 port = config.get('bind_port')
20 hookenv.open_port(8083)20 hookenv.open_port(8083)
21 hookenv.open_port(port)21 hookenv.open_port(port)
22 config_changed()22 config_changed()
23 service_start('influxdb')23 service_start('influxdb')
24 hookenv.status_set('active', '')24 hookenv.status_set('active', '')
25 set_state('influxdb.configured')25 set_state('influxdb.configured')
26
2627
27@when('config.changed')28@when('config.changed')
28def config_changed():29def config_changed():
29 config = hookenv.config()30 config = hookenv.config()
30 port = config.get('bind_port')31 port = config.get('bind_port')
31 ip_address = config.get('ip_address')32 ip_address = config.get('ip_address')
32 render(source='influxdb.conf',33 render(source='influxdb.conf',
33 target='/etc/influxdb/influxdb.conf',34 target='/etc/influxdb/influxdb.conf',
34 owner='root',35 owner='root',
35 perms=0o644,36 perms=0o644,
36 context={37 context={
37 'admin': 'true',38 'admin': 'true',
38 'bind_port': port,39 'bind_port': port,
39 'ip_address': ip_address,40 'ip_address': ip_address,
40 })41 })
41 service_stop('influxdb')42 service_stop('influxdb')
42 service_start('influxdb')43 service_start('influxdb')
44
4345
44@when('query.api.available')46@when('query.api.available')
45def query_available(query):47def query_available(query):
46 config = hookenv.config()48 config = hookenv.config()
47 port = config.get('bind_port')49 port = config.get('bind_port')
48 query.configure(port=port)50 query.configure(port=port)
51
4952
50@when('grafana-source.available')53@when('grafana-source.available')
51def configure_grafana(grafana):54def configure_grafana(grafana):
52 config = hookenv.config()55 config = hookenv.config()
53 port = config.get('bind_port')56 port = config.get('bind_port')
54 grafana.provide('influxdb', port, 'Juju generated source')57 grafana.provide('influxdb', port, 'Juju generated source')

Subscribers

People subscribed via source and target branches

to all changes: