Merge ~barryprice/charm-canonical-livepatch/+git/canonical-livepatch-charm:master into ~livepatch-charmers/charm-canonical-livepatch:master

Proposed by Barry Price
Status: Merged
Merged at revision: c523178f3ef316762529ce17c882ae555cad48f2
Proposed branch: ~barryprice/charm-canonical-livepatch/+git/canonical-livepatch-charm:master
Merge into: ~livepatch-charmers/charm-canonical-livepatch:master
Diff against target: 60 lines (+10/-8)
2 files modified
files/check_canonical-livepatch.py (+2/-2)
reactive/canonical_livepatch.py (+8/-6)
Reviewer Review Type Date Requested Status
Livepatch charm developers Pending
Review via email: mp+314314@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/files/check_canonical-livepatch.py b/files/check_canonical-livepatch.py
index 3953661..27c9f69 100644
--- a/files/check_canonical-livepatch.py
+++ b/files/check_canonical-livepatch.py
@@ -4,7 +4,7 @@
44
5import os5import os
6import nagios_plugin6import nagios_plugin
7from subprocess import check_call, check_output7from subprocess import check_output
88
99
10################################################################################10################################################################################
@@ -12,7 +12,7 @@ from subprocess import check_call, check_output
12def check_package_installed():12def check_package_installed():
13 cmd = ['snap', 'list', 'canonical-livepatch']13 cmd = ['snap', 'list', 'canonical-livepatch']
14 try:14 try:
15 res = check_output(cmd, universal_newlines=True)15 check_output(cmd, universal_newlines=True)
16 except:16 except:
17 raise nagios_plugin.CriticalError("canonical-livepatch snap is not installed")17 raise nagios_plugin.CriticalError("canonical-livepatch snap is not installed")
1818
diff --git a/reactive/canonical_livepatch.py b/reactive/canonical_livepatch.py
index ce47d43..102df07 100644
--- a/reactive/canonical_livepatch.py
+++ b/reactive/canonical_livepatch.py
@@ -149,14 +149,14 @@ def update_key():
149 cmd = ['/snap/bin/canonical-livepatch', 'disable']149 cmd = ['/snap/bin/canonical-livepatch', 'disable']
150 hookenv.log('Disabling canonical-livepatch ahead of key change to work around LP#1628823')150 hookenv.log('Disabling canonical-livepatch ahead of key change to work around LP#1628823')
151 try:151 try:
152 __ = check_output(cmd, universal_newlines=True)152 check_output(cmd, universal_newlines=True)
153 except CalledProcessError as e:153 except CalledProcessError as e:
154 hookenv.log('Unable to deactivate: {}'.format(str(e)))154 hookenv.log('Unable to deactivate: {}'.format(str(e)))
155155
156 cmd = ['/snap/bin/canonical-livepatch', 'enable', '{}'.format(livepatch_key.strip())]156 cmd = ['/snap/bin/canonical-livepatch', 'enable', '{}'.format(livepatch_key.strip())]
157 hookenv.log('Activating canonical-livepatch with your key')157 hookenv.log('Activating canonical-livepatch with your key')
158 try:158 try:
159 __ = check_output(cmd, universal_newlines=True)159 check_output(cmd, universal_newlines=True)
160 except CalledProcessError as e:160 except CalledProcessError as e:
161 hookenv.log('Unable to activate: {}'.format(str(e)))161 hookenv.log('Unable to activate: {}'.format(str(e)))
162 hookenv.status_set('blocked', 'Activation failed')162 hookenv.status_set('blocked', 'Activation failed')
@@ -212,10 +212,12 @@ def init_nagios_checks(nagios):
212 'files/check_canonical-livepatch.py',212 'files/check_canonical-livepatch.py',
213 '/usr/lib/nagios/plugins/check_canonical-livepatch.py',213 '/usr/lib/nagios/plugins/check_canonical-livepatch.py',
214 )214 )
215 file_to_units(215 # don't overwrite an existing status file
216 'files/canonical-livepatch-status.txt',216 if not path.exists('/var/lib/nagios/canonical-livepatch-status.txt'):
217 '/var/lib/nagios/canonical-livepatch-status.txt',217 file_to_units(
218 )218 'files/canonical-livepatch-status.txt',
219 '/var/lib/nagios/canonical-livepatch-status.txt',
220 )
219221
220 # use the interface to create the check222 # use the interface to create the check
221 nagios.add_check(["/usr/lib/nagios/plugins/check_canonical-livepatch.py", ],223 nagios.add_check(["/usr/lib/nagios/plugins/check_canonical-livepatch.py", ],

Subscribers

People subscribed via source and target branches