Merge ~alfonsosanchezbeato/network-manager:add-connectivity-check into network-manager:snap-1.10

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Tony Espy
Approved revision: 0f982b528c0173bf44afbc1b9fd8bf30542d537f
Merged at revision: dbce8fd2b1c66678dfafffe84b1a88fd14a0482d
Proposed branch: ~alfonsosanchezbeato/network-manager:add-connectivity-check
Merge into: network-manager:snap-1.10
Diff against target: 264 lines (+52/-19)
7 files modified
dev/null (+0/-11)
snap-common/bin/networkmanager (+9/-0)
snap-common/bin/snap-config.sh (+25/-0)
snap-common/bin/snap-prop.sh (+6/-0)
snap-common/etc/NetworkManager/NetworkManager.conf (+3/-2)
snap/hooks/configure (+9/-0)
snap/snapcraft.yaml (+0/-6)
Reviewer Review Type Date Requested Status
Tony Espy Approve
Network-manager Pending
Review via email: mp+361245@code.launchpad.net

Commit message

* Remove duplicated configure hook
* Adapt dns options to UC series
* Allow installation on UC16 as dns is not an issue anymore
* Add support for connectivity check via ubuntu core options
* Disable MAC randomization feature
* Remove obsoleted no-system-libraries attribute from snapcraft.yaml

Description of the change

* Remove duplicated configure hook
* Adapt dns options to UC series
* Allow installation on UC16 as dns is not an issue anymore
* Add support for connectivity check via ubuntu core options
* Disable MAC randomization feature
* Remove obsoleted no-system-libraries attribute from snapcraft.yaml

To post a comment you must log in.
Revision history for this message
Tony Espy (awe) :
review: Needs Fixing
Revision history for this message
Tony Espy (awe) :
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

@Tony, thanks for the review! See my comments below.

Revision history for this message
Tony Espy (awe) wrote :

LGTM

review: Approve
Revision history for this message
Tony Espy (awe) wrote :

Note, I'm not able to successfully build this version using the latest stable version of snapcraft. This may be due to virtualization, as I'm building from Ubuntu running under Parallels w/nested virtualization enabled (to allow multipass to run). Perhaps this is because the Parallels VM instance itself isn't configured in a way which allow all of the test cases to be run?

Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

@Tony, it is probably that - I have come also into trouble when trying to build in a virtualized environment. Probably we should run the unit tests in CI only and not in snapcraft's build stage.

Revision history for this message
Tony Espy (awe) wrote :

@Alfonso

To do so would mean we need to add CI support for the NM 1.10 snap. We'll talk about it during the product sprint this week, and can follow up at our sprint next week.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hooks/configure b/hooks/configure
2deleted file mode 100755
3index 4f0fe5b..0000000
4--- a/hooks/configure
5+++ /dev/null
6@@ -1,62 +0,0 @@
7-#!/bin/sh -ex
8-# Copyright (C) 2016-2018 Canonical Ltd
9-#
10-# This program is free software; you can redistribute it and/or modify
11-# it under the terms of the GNU General Public License as published by
12-# the Free Software Foundation; either version 2 of the License, or
13-# (at your option) any later version.
14-#
15-# This program is distributed in the hope that it will be useful,
16-# but WITHOUT ANY WARRANTY; without even the implied warranty of
17-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18-# GNU General Public License for more details.
19-#
20-# You should have received a copy of the GNU General Public License
21-# along with this program. If not, see <http://www.gnu.org/licenses/>.
22-
23-# Configure hook has two missions:
24-# 1. Set properties defaults on installation, so users can see them
25-# 2. Re-start daemon if a property has changed
26-
27-. "$SNAP"/bin/snap-prop.sh
28-
29-props_file="$SNAP_DATA"/current_snap_props
30-
31-_create_props_content() {
32- printf "wifi_powersave=%s\n" "$wifi_powersave"
33- printf "wifi_wake_on_wlan=%s\n" "$wifi_wake_on_wlan"
34- printf "wifi_wake_on_password=%s\n" "$wifi_wake_on_password"
35- printf "ethernet_enable=%s\n" "$ethernet_enable"
36- printf "debug_enable=%s\n" "$debug_enable"
37-}
38-
39-wifi_powersave=$(get_wifi_powersave)
40-wifi_wake_on_wlan=$(get_wifi_wake_on_wlan)
41-wifi_wake_on_password=$(get_wifi_wake_on_password)
42-ethernet_enable=$(get_ethernet_enable)
43-debug_enable=$(get_debug_enable)
44-
45-# Store always, so we show defaults when properties are set to empty strings
46-snapctl set wifi.powersave="$wifi_powersave"
47-snapctl set wifi.wake-on-wlan="$wifi_wake_on_wlan"
48-snapctl set wifi.wake-on-wlan-password="$wifi_wake_on_password"
49-snapctl set ethernet.enable="$ethernet_enable"
50-snapctl set debug.enable="$debug_enable"
51-
52-content=$(_create_props_content)
53-
54-if [ ! -e "$props_file" ]; then
55- # Installation or refresh from old snap. Assign defaults.
56- echo "$content" > "$props_file"
57- return 0
58-fi
59-
60-old_content=$(cat "$props_file")
61-if [ "$content" = "$old_content" ]; then
62- # No change in properties, this must be a snap refresh
63- return 0
64-fi
65-
66-# Some property changed, store new values and re-start daemon to apply changes
67-echo "$content" > "$props_file"
68-snapctl restart "$SNAP_NAME"
69diff --git a/snap-common/bin/networkmanager b/snap-common/bin/networkmanager
70index bec5f63..be4ca09 100755
71--- a/snap-common/bin/networkmanager
72+++ b/snap-common/bin/networkmanager
73@@ -44,6 +44,15 @@ if [ -e "$SNAP_DATA"/NetworkManager.conf ]; then
74 NM_CONF=$SNAP_DATA/NetworkManager.conf
75 fi
76
77+# Use right DNS settings depending on UC series
78+. "$SNAP"/bin/utils.sh
79+dns_conf_file="$SNAP_DATA"/conf.d/10-dns.conf
80+if [ "$(get_target_system)" = "16" ]; then
81+ printf "[main]\ndns=default\nrc-manager=resolvconf\n" > "$dns_conf_file"
82+else
83+ printf "[main]\ndns=systemd-resolved\n" > "$dns_conf_file"
84+fi
85+
86 # If netplan is not configured to render by default to NetworkManager
87 # configuration files we disable management of any ethernet device
88 # as this will clash with any configuration netplan puts in place
89diff --git a/snap-common/bin/snap-config.sh b/snap-common/bin/snap-config.sh
90index da60892..7ca830a 100644
91--- a/snap-common/bin/snap-config.sh
92+++ b/snap-common/bin/snap-config.sh
93@@ -149,6 +149,28 @@ _switch_debug_enable() {
94 fi
95 }
96
97+# Enable/disable connectivity check
98+# $1: uri
99+# $2: interval
100+# $3: response
101+_switch_connectivity_check() {
102+ path=$SNAP_DATA/conf.d/connectivity.conf
103+ if [ -z "$1" ]; then
104+ rm -f "$path"
105+ return
106+ fi
107+
108+ content=$(printf "[connectivity]\nuri=%s" "$1")
109+ if [ -n "$2" ]; then
110+ content=$(printf "%s\ninterval=%s" "$content" "$2")
111+ fi
112+ if [ -n "$3" ]; then
113+ content=$(printf "%s\nresponse=%s" "$content" "$3")
114+ fi
115+
116+ _replace_file_if_diff "$path" "$content"
117+}
118+
119 . "$SNAP"/bin/snap-prop.sh
120
121 apply_snap_config() {
122@@ -156,4 +178,7 @@ apply_snap_config() {
123 _switch_wifi_wake_on_wlan "$(get_wifi_wake_on_wlan)" "$(get_wifi_wake_on_password)"
124 _switch_ethernet "$(get_ethernet_enable)"
125 _switch_debug_enable "$(get_debug_enable)"
126+ _switch_connectivity_check "$(get_property connectivity.uri)" \
127+ "$(get_property connectivity.interval)" \
128+ "$(get_property connectivity.response)"
129 }
130diff --git a/snap-common/bin/snap-prop.sh b/snap-common/bin/snap-prop.sh
131index 3615660..3a0ec11 100644
132--- a/snap-common/bin/snap-prop.sh
133+++ b/snap-common/bin/snap-prop.sh
134@@ -16,6 +16,12 @@
135
136 # Getters for snap properties. They write the current value to stdout.
137
138+# Generic one, that sets no defaults
139+# $1: property name
140+get_property() {
141+ snapctl get "$1"
142+}
143+
144 get_wifi_powersave() {
145 value=$(snapctl get wifi.powersave) || true
146 if [ -z "$value" ]; then
147diff --git a/snap/hooks/utils.sh b/snap-common/bin/utils.sh
148similarity index 100%
149rename from snap/hooks/utils.sh
150rename to snap-common/bin/utils.sh
151old mode 100755
152new mode 100644
153diff --git a/snap-common/etc/NetworkManager/NetworkManager.conf b/snap-common/etc/NetworkManager/NetworkManager.conf
154index e332099..c43397e 100644
155--- a/snap-common/etc/NetworkManager/NetworkManager.conf
156+++ b/snap-common/etc/NetworkManager/NetworkManager.conf
157@@ -2,8 +2,6 @@
158 plugins=ifupdown,keyfile
159 # Not using dnsmasq yet. Need to get it properly integrated
160 # into the snap or reuse the one shiped with the OS snap.
161-dns=systemd-resolved
162-
163
164 # Use internal DHCP stack which is based on the systemd
165 # implementation and is enough for our purpose until we
166@@ -12,3 +10,6 @@ dhcp=internal
167
168 [ifupdown]
169 managed=false
170+
171+[device]
172+wifi.scan-rand-mac-address=no
173diff --git a/snap/hooks/configure b/snap/hooks/configure
174index 4f0fe5b..34b41a6 100755
175--- a/snap/hooks/configure
176+++ b/snap/hooks/configure
177@@ -28,6 +28,9 @@ _create_props_content() {
178 printf "wifi_wake_on_password=%s\n" "$wifi_wake_on_password"
179 printf "ethernet_enable=%s\n" "$ethernet_enable"
180 printf "debug_enable=%s\n" "$debug_enable"
181+ printf "connectivity_uri=%s\n" "$connectivity_uri"
182+ printf "connectivity_interval=%s\n" "$connectivity_interval"
183+ printf "connectivity_response=%s\n" "$connectivity_response"
184 }
185
186 wifi_powersave=$(get_wifi_powersave)
187@@ -35,6 +38,9 @@ wifi_wake_on_wlan=$(get_wifi_wake_on_wlan)
188 wifi_wake_on_password=$(get_wifi_wake_on_password)
189 ethernet_enable=$(get_ethernet_enable)
190 debug_enable=$(get_debug_enable)
191+connectivity_uri=$(get_property "connectivity.uri")
192+connectivity_interval=$(get_property "connectivity.interval")
193+connectivity_response=$(get_property "connectivity.response")
194
195 # Store always, so we show defaults when properties are set to empty strings
196 snapctl set wifi.powersave="$wifi_powersave"
197@@ -42,6 +48,9 @@ snapctl set wifi.wake-on-wlan="$wifi_wake_on_wlan"
198 snapctl set wifi.wake-on-wlan-password="$wifi_wake_on_password"
199 snapctl set ethernet.enable="$ethernet_enable"
200 snapctl set debug.enable="$debug_enable"
201+snapctl set connectivity.uri="$connectivity_uri"
202+snapctl set connectivity.interval="$connectivity_interval"
203+snapctl set connectivity.response="$connectivity_response"
204
205 content=$(_create_props_content)
206
207diff --git a/snap/hooks/install b/snap/hooks/install
208deleted file mode 100755
209index 8f4e7ca..0000000
210--- a/snap/hooks/install
211+++ /dev/null
212@@ -1,11 +0,0 @@
213-#!/bin/sh -e
214-
215-. "$SNAP"/meta/hooks/utils.sh
216-
217-target=$(get_target_system)
218-
219-if [ "$target" != "18" ] ; then
220- echo "This snap is only supported on Ubuntu Core 18."
221- exit 1
222-fi
223-
224diff --git a/snap/hooks/post-refresh b/snap/hooks/post-refresh
225deleted file mode 100755
226index 8f4e7ca..0000000
227--- a/snap/hooks/post-refresh
228+++ /dev/null
229@@ -1,11 +0,0 @@
230-#!/bin/sh -e
231-
232-. "$SNAP"/meta/hooks/utils.sh
233-
234-target=$(get_target_system)
235-
236-if [ "$target" != "18" ] ; then
237- echo "This snap is only supported on Ubuntu Core 18."
238- exit 1
239-fi
240-
241diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
242index e43dea0..d9e1363 100644
243--- a/snap/snapcraft.yaml
244+++ b/snap/snapcraft.yaml
245@@ -52,11 +52,6 @@ apps:
246 slots: [service]
247 plugs: [modem-manager, ppp, network-setup-observe, wpa, firewall-control, hardware-observe]
248 parts:
249- hooks:
250- plugin: dump
251- source: hooks
252- organize:
253- configure: meta/hooks/configure
254 networkmanager-common:
255 plugin: dump
256 source: snap-common
257@@ -85,7 +80,6 @@ parts:
258 networkmanager:
259 plugin: autotools
260 source: .
261- build-attributes: [no-system-libraries]
262 build-packages:
263 - intltool
264 - libdbus-glib-1-dev

Subscribers

People subscribed via source and target branches