livepatch-charmers team mailing list archive
-
livepatch-charmers team
-
Mailing list archive
-
Message #00158
[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:
Stuart Bishop (stub)
Related bugs:
Bug #1786396 in Canonical Livepatch Charm: "Allow users to install the livepatch snap from their choice of channel"
https://bugs.launchpad.net/canonical-livepatch-charm/+bug/1786396
For more details, see:
https://code.launchpad.net/~barryprice/canonical-livepatch-charm/+git/canonical-livepatch-charm/+merge/353635
--
Your team Livepatch charm developers is subscribed to branch canonical-livepatch-charm:master.
diff --git a/Makefile b/Makefile
index 630e665..e8168bf 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,7 @@ lint:
.PHONY: charmbuild
charmbuild:
+ mkdir $(BUILDDEST)
charm build --output-dir $(BUILDDEST) --report
.PHONY: test
diff --git a/config.yaml b/config.yaml
index 298611b..556aaee 100644
--- a/config.yaml
+++ b/config.yaml
@@ -29,3 +29,9 @@ options:
description: >
A comma-separated list of nagios servicegroups.
If left empty, the nagios_context will be used as the servicegroup.
+ snap_channel:
+ default: "stable"
+ type: string
+ description: |
+ Snap Store channel from which to install the Canonical Livepatch snap.
+ Most people will not need to change this.
diff --git a/icon.svg b/icon.svg
index 5fd74e4..8e1d461 100644
--- a/icon.svg
+++ b/icon.svg
@@ -1,17 +1,8 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Generator: Adobe Illustrator 14.0.0, SVG Export Plug-In -->
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
- <!ENTITY ns_flows "http://ns.adobe.com/Flows/1.0/">
-]>
-<svg version="1.1"
- xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:a="http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/"
- x="0px" y="0px" width="285px" height="285px" viewBox="-0.787 -0.867 285 285" enable-background="new -0.787 -0.867 285 285"
- xml:space="preserve">
-<defs>
-</defs>
-<path fill="#772953" d="M141.813,232.106c-49.872,0-90.298-40.414-90.298-90.298c0-49.873,40.426-90.294,90.298-90.294
- c49.873,0,90.297,40.421,90.297,90.294C232.11,191.692,191.687,232.106,141.813,232.106z"/>
-<path fill="#772953" d="M283.619,141.812c0,78.316-63.49,141.806-141.81,141.806C63.487,283.618,0,220.127,0,141.812
- C0,63.488,63.487,0,141.81,0C220.129,0,283.619,63.488,283.619,141.812z M141.81,34.495c-59.272,0-107.312,48.048-107.312,107.316
- c0,59.277,48.04,107.31,107.312,107.31c59.274,0,107.314-48.033,107.314-107.31C249.124,82.543,201.084,34.495,141.81,34.495z"/>
-</svg>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
+<svg id="Layer_1" style="enable-background:new -97 220.9 400 400" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" height="400px" viewBox="-97 220.9 400 400" width="400px" version="1.1" y="0px" x="0px" xmlns:xlink="http://www.w3.org/1999/xlink">
+<style type="text/css">
+ .st0{fill:#E95420;}
+</style>
+ <path class="st0" d="m103 220.9c-110.3 0-200 89.7-200 200s89.7 200 200 200 200-89.7 200-200-89.7-200-200-200zm0 325c-64.6 0-117.9-49.3-124.4-112.2v-0.1h-36.8c-5.1 0-9.6-3-11.5-7.7s-0.9-10.1 2.7-13.6l61.2-61.3c4.9-4.9 12.8-4.9 17.7 0l60.6 60.6c2.6 2.3 4.3 5.7 4.3 9.5 0 6.9-5.6 12.5-12.5 12.5h-35.2c6 35.4 36.9 62.4 73.9 62.4 41.4 0 75-33.6 75-75 0-41.3-33.6-75-75-75-13.8 0-25-11.2-25-25s11.2-25 25-25c68.9 0 125 56.1 125 125 0 68.8-56.1 124.9-125 124.9z"/>
+</svg>
diff --git a/layer.yaml b/layer.yaml
index ca4204e..5f1849f 100644
--- a/layer.yaml
+++ b/layer.yaml
@@ -12,8 +12,4 @@ options:
- python3-setuptools
- python3-wheel
- python3-yaml
- snap:
- canonical-livepatch:
- channel: stable
- supported-architectures: ['x86_64']
repo: lp:~livepatch-charmers/canonical-livepatch-charm/+git/canonical-livepatch-charm
diff --git a/reactive/canonical_livepatch.py b/reactive/canonical_livepatch.py
index 22152a6..7a92c20 100644
--- a/reactive/canonical_livepatch.py
+++ b/reactive/canonical_livepatch.py
@@ -1,4 +1,4 @@
-from charms import layer
+from charms.layer import snap
from charms.reactive import when, when_not, set_flag, clear_flag
from charms.reactive.flags import register_trigger
from charmhelpers.core.host import write_file, is_container
@@ -129,12 +129,11 @@ def activate_livepatch():
register_trigger(when='config.changed.livepatch_proxy', clear_flag='livepatch-proxy.configured')
-@when('snap.installed.canonical-livepatch')
+@when_not('canonical-livepatch.supported')
def livepatch_supported():
arch = uname()[4]
- opts = layer.options('snap')
- supported_archs = opts['canonical-livepatch'].pop('supported-architectures', None)
- if supported_archs and arch not in supported_archs:
+ supported_archs = ['x86_64', ]
+ if arch not in supported_archs:
hookenv.log('Livepatch does not currently support {} architecture'.format(arch))
unit_update('blocked', 'Architecture {} is not supported by livepatch'.format(arch))
elif is_container():
@@ -145,6 +144,17 @@ def livepatch_supported():
@when('canonical-livepatch.supported')
+@when_not('snap.livepatch.installed')
+def install_livepatch():
+ config = hookenv.config()
+ snap_channel = config.get('snap_channel')
+ snap.install(
+ 'canonical-livepatch',
+ **{'channel': snap_channel, }
+ )
+
+
+@when('snap.installed.canonical-livepatch')
@when_not('livepatch-proxy.configured')
def proxy_settings():
# Configure proxies early, if required - LP#1761661
Follow ups