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

Proposed by Jacek Nykis
Status: Merged
Merged at revision: 35
Proposed branch: lp:~jacekn/charms/trusty/grafana/grafana-url
Merge into: lp:~canonical-is-sa/charms/trusty/grafana/layer-grafana
Diff against target: 72 lines (+28/-8)
2 files modified
config.yaml (+11/-2)
reactive/grafana.py (+17/-6)
To merge this branch: bzr merge lp:~jacekn/charms/trusty/grafana/grafana-url
Reviewer Review Type Date Requested Status
Neale Pickett (community) Approve
Review via email: mp+293147@code.launchpad.net

Description of the change

Allow grafana to be installed from http URL, needed until we package it

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 'config.yaml'
--- config.yaml 2016-03-16 17:22:22 +0000
+++ config.yaml 2016-04-27 16:52:58 +0000
@@ -22,13 +22,22 @@
22 install_keys: |22 install_keys: |
23 - ""23 - ""
24 - ""24 - ""
25 install_file:
26 default: ""
27 type: string
28 description: |
29 Location where grafana .deb file can be found. If set install_sources and
30 install_keys options are ignored. Example:
31 install_file: http://my.company.com/packages/grafana/grafana_3.0.0_amd64.deb
25 app_mode:32 app_mode:
26 default: 'production'33 default: 'production'
27 type: string34 type: string
28 description: 'production or development'35 description: 'production or development'
29 datasources:36 datasources:
30 default: |37 default: ""
31 - 'prometheus,BootStack Prometheus,proxy,http://localhost:9090,,,'38 description: |
39 List of datasources in format:
40 - 'prometheus,BootStack Prometheus,proxy,http://localhost:9090,,,'
32 type: string41 type: string
33 description: |42 description: |
34 - type,name,access,url,password,user,database43 - type,name,access,url,password,user,database
3544
=== modified file 'reactive/grafana.py'
--- reactive/grafana.py 2016-04-27 15:09:30 +0000
+++ reactive/grafana.py 2016-04-27 16:52:58 +0000
@@ -3,6 +3,8 @@
3import glob3import glob
4import hashlib4import hashlib
5import datetime5import datetime
6import requests
7import subprocess
6from time import sleep8from time import sleep
7from charmhelpers import fetch9from charmhelpers import fetch
8from charmhelpers.core import host, hookenv, unitdata10from charmhelpers.core import host, hookenv, unitdata
@@ -30,17 +32,26 @@
30SVCNAME = 'grafana-server'32SVCNAME = 'grafana-server'
31GRAFANA_INI = '/etc/grafana/grafana.ini'33GRAFANA_INI = '/etc/grafana/grafana.ini'
32GRAFANA_INI_TMPL = 'grafana.ini.j2'34GRAFANA_INI_TMPL = 'grafana.ini.j2'
35GRAFANA_DEPS = ['libfontconfig1']
3336
3437
35def install_packages():38def install_packages():
36 config = hookenv.config()39 config = hookenv.config()
37 install_opts = ('install_sources', 'install_keys')40 install_opts = ('install_sources', 'install_keys')
38 if not any(config.changed(opt) for opt in install_opts):41 if config.changed('install_file'):
39 return42 hookenv.status_set('maintenance', 'Installing deb pkgs')
40 hookenv.status_set('maintenance', 'Installing deb pkgs')43 fetch.apt_install(GRAFANA_DEPS)
41 packages = ['grafana']44 pkg_file = '/tmp/grafana.deb'
42 fetch.configure_sources(update=True)45 with open(pkg_file, 'wb') as f:
43 fetch.apt_install(packages)46 r = requests.get(config.get('install_file'), stream=True)
47 for block in r.iter_content(1024):
48 f.write(block)
49 subprocess.check_call(['dpkg', '-i', pkg_file])
50 elif any(config.changed(opt) for opt in install_opts):
51 hookenv.status_set('maintenance', 'Installing deb pkgs')
52 packages = ['grafana']
53 fetch.configure_sources(update=True)
54 fetch.apt_install(packages)
44 hookenv.status_set('maintenance', 'Waiting for start')55 hookenv.status_set('maintenance', 'Waiting for start')
4556
4657

Subscribers

People subscribed via source and target branches

to all changes: