Merge lp:~jacekn/charms/trusty/grafana/admin_passwd into lp:~canonical-is-sa/charms/trusty/grafana/layer-grafana

Proposed by Jacek Nykis
Status: Merged
Merged at revision: 37
Proposed branch: lp:~jacekn/charms/trusty/grafana/admin_passwd
Merge into: lp:~canonical-is-sa/charms/trusty/grafana/layer-grafana
Diff against target: 75 lines (+22/-6)
3 files modified
README.md (+10/-2)
reactive/grafana.py (+3/-4)
scripts/get_admin_password (+9/-0)
To merge this branch: bzr merge lp:~jacekn/charms/trusty/grafana/admin_passwd
Reviewer Review Type Date Requested Status
Neale Pickett (community) Approve
Review via email: mp+293794@code.launchpad.net

Description of the change

Add ability to retrieve autogenerated admin password. Fix one bug in install_file config option handling

To post a comment you must log in.
Revision history for this message
Neale Pickett (neale) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2016-02-24 19:08:53 +0000
3+++ README.md 2016-05-04 15:39:22 +0000
4@@ -5,6 +5,14 @@
5 #Usage
6
7 juju deploy grafana
8+ juju add-relation prometheus:grafana-source grafana:grafana-source
9+
10+Above will automatcially configure prometheus as grafana datasource
11+
12+If admin password is not set using configuration option it is autogenated.
13+To retried autogenerated password run:
14+ juju run --service grafana "scripts/get_admin_password"
15+
16
17 #Development
18
19@@ -15,7 +23,7 @@
20
21 Branch code to
22
23- $JUJU_REPOSITORY/layers/prometheus/
24+ $JUJU_REPOSITORY/layers/layer-grafana/
25
26 Modify
27
28@@ -25,6 +33,6 @@
29
30 #Contact Information
31
32-Author: Alvaro Uria <alvaro.uria@canonical.com>
33+Author: Alvaro Uria <alvaro.uria@canonical.com>, Jacek Nykis <jacek.nykis@canonical.com>
34 Report bugs at: http://bugs.launchpad.net/~canonical-bootstack/charms/trusty/bootstack-grafana/composer
35 Location: http://jujucharms.com/charms/trusty/bootstack-grafana
36
37=== modified file 'reactive/grafana.py'
38--- reactive/grafana.py 2016-04-29 22:11:08 +0000
39+++ reactive/grafana.py 2016-05-04 15:39:22 +0000
40@@ -38,7 +38,7 @@
41 def install_packages():
42 config = hookenv.config()
43 install_opts = ('install_sources', 'install_keys')
44- if config.changed('install_file'):
45+ if config.changed('install_file') and config.get('install_file', False):
46 hookenv.status_set('maintenance', 'Installing deb pkgs')
47 fetch.apt_install(GRAFANA_DEPS)
48 pkg_file = '/tmp/grafana.deb'
49@@ -283,9 +283,8 @@
50 passwd = config.get('admin_password', False)
51 if not passwd:
52 passwd = host.pwgen(16)
53- # TODO: Allow users to retrieve password, possibly using an action
54- # Below does not make the password visible in juju get output
55- config['admin_password'] = passwd
56+ kv = unitdata.kv()
57+ kv.set('grafana.admin_password', passwd)
58
59 try:
60 stmt = "UPDATE user SET email=?, name='BootStack Team'"
61
62=== added directory 'scripts'
63=== added file 'scripts/get_admin_password'
64--- scripts/get_admin_password 1970-01-01 00:00:00 +0000
65+++ scripts/get_admin_password 2016-05-04 15:39:22 +0000
66@@ -0,0 +1,9 @@
67+#!/usr/bin/env python3
68+
69+from charmhelpers.core import unitdata
70+
71+kv = unitdata.kv()
72+if kv.get('grafana.admin_password'):
73+ print('Admin password: {}'.format(kv.get('grafana.admin_password')))
74+else:
75+ print('ERROR! Unable to retrieve password. Was it set using config option?')

Subscribers

People subscribed via source and target branches

to all changes: