Merge ~brad-marshall/charm-grafana/+git/grafana-charm:http-proxy-install into ~prometheus-charmers/charm-grafana:master

Proposed by Brad Marshall
Status: Merged
Merged at revision: 3938ce8428471e02cea32e81675fa37af3fbeb56
Proposed branch: ~brad-marshall/charm-grafana/+git/grafana-charm:http-proxy-install
Merge into: ~prometheus-charmers/charm-grafana:master
Diff against target: 40 lines (+15/-1)
2 files modified
config.yaml (+5/-0)
reactive/grafana.py (+10/-1)
Reviewer Review Type Date Requested Status
Paul Gear (community) Approve
Review via email: mp+330050@code.launchpad.net

Description of the change

Added the ability to use a http_proxy for the install file option. I've tested this locally and ensured it went via the proxy.

To post a comment you must log in.
Revision history for this message
Paul Gear (paulgear) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/config.yaml b/config.yaml
index 60f282e..f5c4e6c 100644
--- a/config.yaml
+++ b/config.yaml
@@ -127,3 +127,8 @@ options:
127 Comma separated list of http(s) URLs where grafana plugin tarballs can be found.127 Comma separated list of http(s) URLs where grafana plugin tarballs can be found.
128 Example:128 Example:
129 install_plugins: http://my.company.com/packages/grafana/plugins/plugin-panel.tar.gz129 install_plugins: http://my.company.com/packages/grafana/plugins/plugin-panel.tar.gz
130 http_proxy:
131 default: ""
132 type: string
133 description: |
134 Proxy URL to use for install_file
diff --git a/reactive/grafana.py b/reactive/grafana.py
index 91f813f..d3b90bc 100644
--- a/reactive/grafana.py
+++ b/reactive/grafana.py
@@ -44,12 +44,21 @@ def install_packages():
44 config = hookenv.config()44 config = hookenv.config()
45 install_opts = ('install_sources', 'install_keys')45 install_opts = ('install_sources', 'install_keys')
46 hookenv.status_set('maintenance', 'Installing grafana')46 hookenv.status_set('maintenance', 'Installing grafana')
47
48 if config.get('http_proxy'):
49 proxy = {"http": config.get('http_proxy'),
50 "https": config.get('http_proxy'),
51 }
52 else:
53 proxy = {}
54
47 if config.changed('install_file') and config.get('install_file', False):55 if config.changed('install_file') and config.get('install_file', False):
48 hookenv.status_set('maintenance', 'Installing deb pkgs')56 hookenv.status_set('maintenance', 'Installing deb pkgs')
49 fetch.apt_install(GRAFANA_DEPS)57 fetch.apt_install(GRAFANA_DEPS)
50 pkg_file = '/tmp/grafana.deb'58 pkg_file = '/tmp/grafana.deb'
51 with open(pkg_file, 'wb') as f:59 with open(pkg_file, 'wb') as f:
52 r = requests.get(config.get('install_file'), stream=True)60 r = requests.get(config.get('install_file'), stream=True,
61 proxies=proxy)
53 for block in r.iter_content(1024):62 for block in r.iter_content(1024):
54 f.write(block)63 f.write(block)
55 subprocess.check_call(['dpkg', '-i', pkg_file])64 subprocess.check_call(['dpkg', '-i', pkg_file])

Subscribers

People subscribed via source and target branches