Merge lp:~brad-marshall/charms/trusty/thruk-master/fix-multiseries into lp:~canonical-bootstack/charms/trusty/thruk-master/trunk

Proposed by Brad Marshall
Status: Merged
Merged at revision: 21
Proposed branch: lp:~brad-marshall/charms/trusty/thruk-master/fix-multiseries
Merge into: lp:~canonical-bootstack/charms/trusty/thruk-master/trunk
Diff against target: 157 lines (+38/-16)
10 files modified
hooks/actions.py (+9/-6)
hooks/config-changed (+1/-1)
hooks/hooks.py (+1/-1)
hooks/install (+21/-0)
hooks/install.real (+1/-1)
hooks/services.py (+1/-1)
hooks/start (+1/-1)
hooks/stop (+1/-1)
hooks/thruk_helpers.py (+1/-3)
hooks/upgrade-charm (+1/-1)
To merge this branch: bzr merge lp:~brad-marshall/charms/trusty/thruk-master/fix-multiseries
Reviewer Review Type Date Requested Status
James Hebden (community) Approve
Review via email: mp+320457@code.launchpad.net

Description of the change

Fix multiseries and move to python3.

To post a comment you must log in.
Revision history for this message
James Hebden (ec0) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/actions.py'
2--- hooks/actions.py 2015-05-28 04:14:24 +0000
3+++ hooks/actions.py 2017-03-21 04:39:07 +0000
4@@ -20,8 +20,9 @@
5
6 if config.changed('source'):
7 prev_ppa = config.previous('source')
8- if prev_ppa is not None:
9- subprocess.check_call(['add-apt-repository', '--yes', '--remove', prev_ppa])
10+ if prev_ppa is not None:
11+ subprocess.check_call(['add-apt-repository',
12+ '--yes', '--remove', prev_ppa])
13 ppa = config.get('source')
14 if ppa is not None:
15 add_source(ppa)
16@@ -35,10 +36,11 @@
17 password = pwgen()
18 with open(passwd_file, 'w') as pfile:
19 pfile.write(password)
20- os.chmod(pfile.name, 0600)
21+ os.chmod(pfile.name, 0o600)
22
23- ret = subprocess.call(["/usr/bin/htpasswd", "-b", "/etc/thruk/htpasswd",
24- "thrukadmin", password])
25+ ret = subprocess.call(["/usr/bin/htpasswd",
26+ "-b", "/etc/thruk/htpasswd",
27+ "thrukadmin", password])
28 if not ret:
29 hookenv.log('WARNING: thruk htpassword reset failed!')
30 else:
31@@ -55,7 +57,8 @@
32 (hookenv.config('trusted_ssl_certlocation').rpartition('/')[2])
33
34 trusted_ssl_cert = hookenv.config('trusted_ssl_cert')
35- hookenv.log("Writing cert from trusted_ssl_cert: %s" % trusted_ssl_cert)
36+ hookenv.log("Writing cert from trusted_ssl_cert: %s"
37+ % trusted_ssl_cert)
38 with open(cert_file, 'w') as f:
39 f.write(str(base64.b64decode(trusted_ssl_cert)))
40
41
42=== modified file 'hooks/config-changed'
43--- hooks/config-changed 2015-04-09 06:46:35 +0000
44+++ hooks/config-changed 2017-03-21 04:39:07 +0000
45@@ -1,3 +1,3 @@
46-#!/usr/bin/python
47+#!/usr/bin/python3
48 import services
49 services.manage()
50
51=== modified file 'hooks/hooks.py'
52--- hooks/hooks.py 2015-04-09 06:46:35 +0000
53+++ hooks/hooks.py 2017-03-21 04:39:07 +0000
54@@ -1,3 +1,3 @@
55-#!/usr/bin/python
56+#!/usr/bin/python3
57 import services
58 services.manage()
59
60=== added file 'hooks/install'
61--- hooks/install 1970-01-01 00:00:00 +0000
62+++ hooks/install 2017-03-21 04:39:07 +0000
63@@ -0,0 +1,21 @@
64+#!/bin/bash
65+# Wrapper to deal with newer Ubuntu versions that don't have py2 installed
66+# by default.
67+
68+declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml')
69+
70+check_and_install() {
71+ pkg="${1}-${2}"
72+ if ! dpkg -s ${pkg} 2>&1 > /dev/null; then
73+ apt-get -y install ${pkg}
74+ fi
75+}
76+
77+PYTHON="python3"
78+
79+for dep in ${DEPS[@]}; do
80+ check_and_install ${PYTHON} ${dep}
81+done
82+
83+exec ./hooks/install.real
84+
85
86=== renamed file 'hooks/install' => 'hooks/install.real'
87--- hooks/install 2015-04-22 06:31:01 +0000
88+++ hooks/install.real 2017-03-21 04:39:07 +0000
89@@ -1,4 +1,4 @@
90-#!/usr/bin/python
91+#!/usr/bin/python3
92
93 import setup
94 setup.pre_install()
95
96=== modified file 'hooks/services.py'
97--- hooks/services.py 2015-06-24 00:14:14 +0000
98+++ hooks/services.py 2017-03-21 04:39:07 +0000
99@@ -44,7 +44,7 @@
100 helpers.render_template(
101 source='thruk-nrpe.j2',
102 target='/etc/nagios/nrpe.d/check_{}.cfg'.format(
103- hookenv.local_unit().replace('/', '-'),
104+ hookenv.local_unit().replace('/', '-'),
105 )
106 ),
107 helpers.render_template(
108
109=== modified file 'hooks/start'
110--- hooks/start 2015-04-09 06:46:35 +0000
111+++ hooks/start 2017-03-21 04:39:07 +0000
112@@ -1,3 +1,3 @@
113-#!/usr/bin/python
114+#!/usr/bin/python3
115 import services
116 services.manage()
117
118=== modified file 'hooks/stop'
119--- hooks/stop 2015-04-09 06:46:35 +0000
120+++ hooks/stop 2017-03-21 04:39:07 +0000
121@@ -1,3 +1,3 @@
122-#!/usr/bin/python
123+#!/usr/bin/python3
124 import services
125 services.manage()
126
127=== modified file 'hooks/thruk_helpers.py'
128--- hooks/thruk_helpers.py 2015-05-05 04:47:26 +0000
129+++ hooks/thruk_helpers.py 2017-03-21 04:39:07 +0000
130@@ -1,4 +1,4 @@
131-#!/usr/bin/python
132+#!/usr/bin/python3
133
134 from charmhelpers.core import hookenv
135 from charmhelpers.core.services import helpers
136@@ -11,7 +11,6 @@
137
138 name = 'thruk-agent'
139 interface = 'thruk-agent'
140- # required_keys = ['host', 'port', 'nagios_context', 'thruk_key', 'thruk_id']
141
142 def get_data(self):
143 """ jinja won't allow hyphens in identifiers, so we switch to
144@@ -40,4 +39,3 @@
145 if not hookenv.relation_ids(self.name):
146 return
147 self['nrpe_external_master'] = self[self.name]
148-
149
150=== modified file 'hooks/upgrade-charm'
151--- hooks/upgrade-charm 2015-04-09 06:46:35 +0000
152+++ hooks/upgrade-charm 2017-03-21 04:39:07 +0000
153@@ -1,3 +1,3 @@
154-#!/usr/bin/python
155+#!/usr/bin/python3
156 import services
157 services.manage()

Subscribers

People subscribed via source and target branches