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
=== modified file 'README.md'
--- README.md 2016-02-24 19:08:53 +0000
+++ README.md 2016-05-04 15:39:22 +0000
@@ -5,6 +5,14 @@
5#Usage5#Usage
66
7 juju deploy grafana7 juju deploy grafana
8 juju add-relation prometheus:grafana-source grafana:grafana-source
9
10Above will automatcially configure prometheus as grafana datasource
11
12If admin password is not set using configuration option it is autogenated.
13To retried autogenerated password run:
14 juju run --service grafana "scripts/get_admin_password"
15
816
9#Development17#Development
1018
@@ -15,7 +23,7 @@
1523
16Branch code to24Branch code to
1725
18 $JUJU_REPOSITORY/layers/prometheus/26 $JUJU_REPOSITORY/layers/layer-grafana/
1927
20Modify28Modify
2129
@@ -25,6 +33,6 @@
2533
26#Contact Information34#Contact Information
2735
28Author: Alvaro Uria <alvaro.uria@canonical.com>36Author: Alvaro Uria <alvaro.uria@canonical.com>, Jacek Nykis <jacek.nykis@canonical.com>
29Report bugs at: http://bugs.launchpad.net/~canonical-bootstack/charms/trusty/bootstack-grafana/composer37Report bugs at: http://bugs.launchpad.net/~canonical-bootstack/charms/trusty/bootstack-grafana/composer
30Location: http://jujucharms.com/charms/trusty/bootstack-grafana38Location: http://jujucharms.com/charms/trusty/bootstack-grafana
3139
=== modified file 'reactive/grafana.py'
--- reactive/grafana.py 2016-04-29 22:11:08 +0000
+++ reactive/grafana.py 2016-05-04 15:39:22 +0000
@@ -38,7 +38,7 @@
38def install_packages():38def install_packages():
39 config = hookenv.config()39 config = hookenv.config()
40 install_opts = ('install_sources', 'install_keys')40 install_opts = ('install_sources', 'install_keys')
41 if config.changed('install_file'):41 if config.changed('install_file') and config.get('install_file', False):
42 hookenv.status_set('maintenance', 'Installing deb pkgs')42 hookenv.status_set('maintenance', 'Installing deb pkgs')
43 fetch.apt_install(GRAFANA_DEPS)43 fetch.apt_install(GRAFANA_DEPS)
44 pkg_file = '/tmp/grafana.deb'44 pkg_file = '/tmp/grafana.deb'
@@ -283,9 +283,8 @@
283 passwd = config.get('admin_password', False)283 passwd = config.get('admin_password', False)
284 if not passwd:284 if not passwd:
285 passwd = host.pwgen(16)285 passwd = host.pwgen(16)
286 # TODO: Allow users to retrieve password, possibly using an action286 kv = unitdata.kv()
287 # Below does not make the password visible in juju get output287 kv.set('grafana.admin_password', passwd)
288 config['admin_password'] = passwd
289288
290 try:289 try:
291 stmt = "UPDATE user SET email=?, name='BootStack Team'"290 stmt = "UPDATE user SET email=?, name='BootStack Team'"
292291
=== added directory 'scripts'
=== added file 'scripts/get_admin_password'
--- scripts/get_admin_password 1970-01-01 00:00:00 +0000
+++ scripts/get_admin_password 2016-05-04 15:39:22 +0000
@@ -0,0 +1,9 @@
1#!/usr/bin/env python3
2
3from charmhelpers.core import unitdata
4
5kv = unitdata.kv()
6if kv.get('grafana.admin_password'):
7 print('Admin password: {}'.format(kv.get('grafana.admin_password')))
8else:
9 print('ERROR! Unable to retrieve password. Was it set using config option?')

Subscribers

People subscribed via source and target branches

to all changes: