livepatch-charmers team mailing list archive
-
livepatch-charmers team
-
Mailing list archive
-
Message #00037
[Merge] ~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm:master into canonical-livepatch-charm:master
Barry Price has proposed merging ~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm:master into canonical-livepatch-charm:master.
Requested reviews:
Livepatch charm developers (livepatch-charmers)
For more details, see:
https://code.launchpad.net/~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm/+merge/331851
--
Your team Livepatch charm developers is requested to review the proposed merge of ~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm:master into canonical-livepatch-charm:master.
diff --git a/reactive/canonical_livepatch.py b/reactive/canonical_livepatch.py
index bb9d547..942c3c9 100644
--- a/reactive/canonical_livepatch.py
+++ b/reactive/canonical_livepatch.py
@@ -7,7 +7,6 @@ from subprocess import check_call, check_output, CalledProcessError
from time import sleep
from os import path, uname
from yaml import load, dump
-from platform import release
from distutils.version import LooseVersion
@@ -57,37 +56,44 @@ def unit_update(status=None, message=None):
if status and message:
hookenv.status_set(status, message)
else:
- hookenv.status_set('active', 'Effective kernel {}'.format(
- get_equiv_kernel_version())
+ hookenv.status_set('active', 'Kernel {} is {} ({})'.format(
+ get_patch_details())
)
-def get_equiv_kernel_version():
- # default to actual running kernel
- version_string = release()
- livepatch_status = ''
+def get_patch_details():
+ kernel = 'unknown'
+ patch_status = 'not fully patched'
+ version = 'unknown'
cmd = ['/snap/bin/canonical-livepatch', 'status']
try:
livepatch_status = check_output(cmd, universal_newlines=True)
except CalledProcessError as e:
hookenv.log('Unable to get status: {}'.format(str(e)))
- return version_string
+ return(kernel, patch_status, version)
# status will usually pass YAML (but not always!)
try:
status_yaml = load(livepatch_status)
except Exception:
hookenv.log('Unable to parse status yaml')
- return version_string
+ return(kernel, patch_status, version)
# even if we got YAML, be paranoid
try:
- version_string = status_yaml['kernel']
+ kernel = status_yaml['kernel']
+ fully_patched = status_yaml['fully-patched']
+ version = status_yaml['version']
except Exception:
- hookenv.log('Unable to find kernel line in status yaml')
+ hookenv.log('Unable to find patching details in status yaml')
- return version_string
+ patch_status = 'not fully patched'
+
+ if fully_patched == 'true':
+ patch_status = 'fully patched'
+
+ return(kernel, patch_status, version)
def get_yaml_if_exists(path_to_yaml):
References