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
=== modified file 'hooks/actions.py'
--- hooks/actions.py 2015-05-28 04:14:24 +0000
+++ hooks/actions.py 2017-03-21 04:39:07 +0000
@@ -20,8 +20,9 @@
2020
21 if config.changed('source'):21 if config.changed('source'):
22 prev_ppa = config.previous('source')22 prev_ppa = config.previous('source')
23 if prev_ppa is not None:23 if prev_ppa is not None:
24 subprocess.check_call(['add-apt-repository', '--yes', '--remove', prev_ppa])24 subprocess.check_call(['add-apt-repository',
25 '--yes', '--remove', prev_ppa])
25 ppa = config.get('source')26 ppa = config.get('source')
26 if ppa is not None:27 if ppa is not None:
27 add_source(ppa)28 add_source(ppa)
@@ -35,10 +36,11 @@
35 password = pwgen()36 password = pwgen()
36 with open(passwd_file, 'w') as pfile:37 with open(passwd_file, 'w') as pfile:
37 pfile.write(password)38 pfile.write(password)
38 os.chmod(pfile.name, 0600)39 os.chmod(pfile.name, 0o600)
3940
40 ret = subprocess.call(["/usr/bin/htpasswd", "-b", "/etc/thruk/htpasswd",41 ret = subprocess.call(["/usr/bin/htpasswd",
41 "thrukadmin", password])42 "-b", "/etc/thruk/htpasswd",
43 "thrukadmin", password])
42 if not ret:44 if not ret:
43 hookenv.log('WARNING: thruk htpassword reset failed!')45 hookenv.log('WARNING: thruk htpassword reset failed!')
44 else:46 else:
@@ -55,7 +57,8 @@
55 (hookenv.config('trusted_ssl_certlocation').rpartition('/')[2])57 (hookenv.config('trusted_ssl_certlocation').rpartition('/')[2])
5658
57 trusted_ssl_cert = hookenv.config('trusted_ssl_cert')59 trusted_ssl_cert = hookenv.config('trusted_ssl_cert')
58 hookenv.log("Writing cert from trusted_ssl_cert: %s" % trusted_ssl_cert)60 hookenv.log("Writing cert from trusted_ssl_cert: %s"
61 % trusted_ssl_cert)
59 with open(cert_file, 'w') as f:62 with open(cert_file, 'w') as f:
60 f.write(str(base64.b64decode(trusted_ssl_cert)))63 f.write(str(base64.b64decode(trusted_ssl_cert)))
6164
6265
=== modified file 'hooks/config-changed'
--- hooks/config-changed 2015-04-09 06:46:35 +0000
+++ hooks/config-changed 2017-03-21 04:39:07 +0000
@@ -1,3 +1,3 @@
1#!/usr/bin/python1#!/usr/bin/python3
2import services2import services
3services.manage()3services.manage()
44
=== modified file 'hooks/hooks.py'
--- hooks/hooks.py 2015-04-09 06:46:35 +0000
+++ hooks/hooks.py 2017-03-21 04:39:07 +0000
@@ -1,3 +1,3 @@
1#!/usr/bin/python1#!/usr/bin/python3
2import services2import services
3services.manage()3services.manage()
44
=== added file 'hooks/install'
--- hooks/install 1970-01-01 00:00:00 +0000
+++ hooks/install 2017-03-21 04:39:07 +0000
@@ -0,0 +1,21 @@
1#!/bin/bash
2# Wrapper to deal with newer Ubuntu versions that don't have py2 installed
3# by default.
4
5declare -a DEPS=('apt' 'netaddr' 'netifaces' 'pip' 'yaml')
6
7check_and_install() {
8 pkg="${1}-${2}"
9 if ! dpkg -s ${pkg} 2>&1 > /dev/null; then
10 apt-get -y install ${pkg}
11 fi
12}
13
14PYTHON="python3"
15
16for dep in ${DEPS[@]}; do
17 check_and_install ${PYTHON} ${dep}
18done
19
20exec ./hooks/install.real
21
022
=== renamed file 'hooks/install' => 'hooks/install.real'
--- hooks/install 2015-04-22 06:31:01 +0000
+++ hooks/install.real 2017-03-21 04:39:07 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/python1#!/usr/bin/python3
22
3import setup3import setup
4setup.pre_install()4setup.pre_install()
55
=== modified file 'hooks/services.py'
--- hooks/services.py 2015-06-24 00:14:14 +0000
+++ hooks/services.py 2017-03-21 04:39:07 +0000
@@ -44,7 +44,7 @@
44 helpers.render_template(44 helpers.render_template(
45 source='thruk-nrpe.j2',45 source='thruk-nrpe.j2',
46 target='/etc/nagios/nrpe.d/check_{}.cfg'.format(46 target='/etc/nagios/nrpe.d/check_{}.cfg'.format(
47 hookenv.local_unit().replace('/', '-'),47 hookenv.local_unit().replace('/', '-'),
48 )48 )
49 ),49 ),
50 helpers.render_template(50 helpers.render_template(
5151
=== modified file 'hooks/start'
--- hooks/start 2015-04-09 06:46:35 +0000
+++ hooks/start 2017-03-21 04:39:07 +0000
@@ -1,3 +1,3 @@
1#!/usr/bin/python1#!/usr/bin/python3
2import services2import services
3services.manage()3services.manage()
44
=== modified file 'hooks/stop'
--- hooks/stop 2015-04-09 06:46:35 +0000
+++ hooks/stop 2017-03-21 04:39:07 +0000
@@ -1,3 +1,3 @@
1#!/usr/bin/python1#!/usr/bin/python3
2import services2import services
3services.manage()3services.manage()
44
=== modified file 'hooks/thruk_helpers.py'
--- hooks/thruk_helpers.py 2015-05-05 04:47:26 +0000
+++ hooks/thruk_helpers.py 2017-03-21 04:39:07 +0000
@@ -1,4 +1,4 @@
1#!/usr/bin/python1#!/usr/bin/python3
22
3from charmhelpers.core import hookenv3from charmhelpers.core import hookenv
4from charmhelpers.core.services import helpers4from charmhelpers.core.services import helpers
@@ -11,7 +11,6 @@
1111
12 name = 'thruk-agent'12 name = 'thruk-agent'
13 interface = 'thruk-agent'13 interface = 'thruk-agent'
14 # required_keys = ['host', 'port', 'nagios_context', 'thruk_key', 'thruk_id']
1514
16 def get_data(self):15 def get_data(self):
17 """ jinja won't allow hyphens in identifiers, so we switch to16 """ jinja won't allow hyphens in identifiers, so we switch to
@@ -40,4 +39,3 @@
40 if not hookenv.relation_ids(self.name):39 if not hookenv.relation_ids(self.name):
41 return40 return
42 self['nrpe_external_master'] = self[self.name]41 self['nrpe_external_master'] = self[self.name]
43
4442
=== modified file 'hooks/upgrade-charm'
--- hooks/upgrade-charm 2015-04-09 06:46:35 +0000
+++ hooks/upgrade-charm 2017-03-21 04:39:07 +0000
@@ -1,3 +1,3 @@
1#!/usr/bin/python1#!/usr/bin/python3
2import services2import services
3services.manage()3services.manage()

Subscribers

People subscribed via source and target branches