Merge ~morphis/snappy-hwe-snaps/+git/network-manager:feature/enable-ethernet-config-item into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master

Proposed by Simon Fels
Status: Merged
Approved by: Roberto Mier Escandon
Approved revision: 742ee696683b570c6553cdab706dea4c068ff699
Merged at revision: e52b1341a936bb549c2e0edf3886225932c142ec
Proposed branch: ~morphis/snappy-hwe-snaps/+git/network-manager:feature/enable-ethernet-config-item
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:master
Diff against target: 325 lines (+169/-16)
11 files modified
docs/metadata.yaml (+2/-0)
docs/reference/configuration/ethernet_support.md (+47/-0)
docs/reference/snap-configuration/wowlan.md (+2/-0)
hooks/configure (+29/-0)
run-tests.sh (+7/-1)
snapcraft.yaml (+6/-4)
tests/lib/prepare.sh (+2/-1)
tests/lib/utilities.sh (+14/-4)
tests/main/aliases/task.yaml (+1/-6)
tests/main/conf-ethernet-support/task.yaml (+55/-0)
tests/main/set-hostname/task.yaml (+4/-0)
Reviewer Review Type Date Requested Status
Simon Fels Approve
System Enablement Bot continuous-integration Approve
Roberto Mier Escandon (community) Approve
Konrad Zapałowicz (community) code Needs Fixing
Review via email: mp+316935@code.launchpad.net

Description of the change

Add configuration item to allow users to enable ethernet support

The current implementation requires to reboot the device two times which is not really what we want but not possible to change until we have a network-setup-control interface which would allow our hook to change the netplan configuration directly.

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

Just a minor vocabulary change and it will be good.

review: Needs Fixing (code)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Simon Fels (morphis) wrote :

Ok, we need to held this back until the interface network-setup-control is merged upstream. Otherwise we don't get this past our CI. Moving the card on trello to blocked and marking this MP as disapproved.

review: Disapprove
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

Seems network-setup-control is now merged to snapd, can the landing/story be unblocked? Is it still valid?

Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

What I've tried in my rpi3:

Steps:
- install network-manager
- connect interfaces
- snap set network-manager ethernet.enable=true
- verified that
    * 'network-manager.nmcli d' shows eth0 unmanaged
    * 'snap get network-manager ethernet.enable' returns true
    * content in /etc/netplan at this moment is 00-snapd-config.yaml
- reboot
- 'network-manager.nmcli d' shows eth0 connected with connection name as 'netplan-eth0'
- content in /etc/netplan is 00-default-nm-renderer.yaml and 00-snapd-config.yaml

I thinks this is the expected behaviour. My only concern is about leaving other yaml files in /etc/netplan not related with nm. Is that intended?

in this url [1] literally says:

"If you don't want any netplan configuration files being used by NetworkManager, delete all files from /etc/netplan. Any remaining files will be considered by NetworkManager and used to configure Ethernet and wireless network devices"

[1] https://docs.ubuntu.com/core/en/stacks/network/network-manager/docs/enable-ethernet-support

review: Needs Information
Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

There is one spread test that is always failing, though I'm not sure it is related with this MP.
That one is tests/main/wifi-no-wowlan-iface-removed

https://pastebin.canonical.com/192985/

review: Needs Fixing
Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

Tested locally merging trunk, resolving conflicts and fixing failures in spread tests specific for this change. All works fine.
Please apply this patch https://pastebin.canonical.com/194037/ to be approved

review: Needs Fixing
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

Please, apply this patch to solve spread failures https://pastebin.canonical.com/196067/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 6aa9fd07140d511a21a7cc422440a663c2160e8a

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/776/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 6aa9fd07140d511a21a7cc422440a663c2160e8a

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/777/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 6aa9fd07140d511a21a7cc422440a663c2160e8a

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/781/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 6aa9fd07140d511a21a7cc422440a663c2160e8a

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/784/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Roberto Mier Escandon (rmescandon) :
review: Approve
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 0a5242cc51050c15fb754dcaf9ebd6b00d93d73e

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/829/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 0a5242cc51050c15fb754dcaf9ebd6b00d93d73e

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/830/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 0a5242cc51050c15fb754dcaf9ebd6b00d93d73e

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/831/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 0a5242cc51050c15fb754dcaf9ebd6b00d93d73e

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/828/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 3b7d25311ff11621ea77499a5707f934f869a47d

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/865/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: b2844cf8d184d9d31b0f7002095fdc5c68aa5aff

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/866/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: bf5c94e7e97d913a195c7cb1eb7201695cfeb876

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/868/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 2ba7ef87e2579e8fb55b535beadfc822b08ee127

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/869/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Successfully build documentation, rev: 742ee696683b570c6553cdab706dea4c068ff699

Generated documentation is available at https://jenkins.canonical.com/system-enablement/job/snappy-hwe-snaps-snap-docs/870/

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Simon Fels (morphis) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/docs/metadata.yaml b/docs/metadata.yaml
index 4fabdd1..82bf35f 100644
--- a/docs/metadata.yaml
+++ b/docs/metadata.yaml
@@ -27,6 +27,8 @@ navigation:
27 children:27 children:
28 - title: Snap Configuration28 - title: Snap Configuration
29 children:29 children:
30 - title: Ethernet Support
31 location: reference/configuration/ethernet_support.md
30 - title: Debug32 - title: Debug
31 location: reference/snap-configuration/debug.md33 location: reference/snap-configuration/debug.md
32 - title: Wake on WLAN34 - title: Wake on WLAN
diff --git a/docs/reference/configuration/ethernet_support.md b/docs/reference/configuration/ethernet_support.md
33new file mode 10064435new file mode 100644
index 0000000..fbc5929
--- /dev/null
+++ b/docs/reference/configuration/ethernet_support.md
@@ -0,0 +1,47 @@
1---
2title: Ethernet Support
3table_of_contents: true
4---
5
6# Ethernet Support
7
8*Available since:* 1.2.2-12
9
10The NetworkManager snap provides a configuration option to adjust
11if it should manage ethernet network connections.
12
13By default the NetworkManager snap **does not** manage ethernet network
14devices as it would conflict with the default network management in
15Ubuntu Core which is handled by [netplan](https://launchpad.net/netplan) and
16[networkd](https://www.freedesktop.org/software/systemd/man/systemd-networkd.service.html).
17
18## Enable Ethernet Support
19
20To enable management of ethernet network devices the snap provides the
21*ethernet.enable* configuration option.
22
23This configuration option accepts the following values
24
25 * **false (default):** Ethernet support is disabled. All network
26 devices matching the expression 'en*' or 'eth*' will be ignored.
27 * **true:** All ethernet devices available on the system will be
28 managed by NetworkManager. networkd will not manage any of these
29 anymore.
30
31Changing the *ethernet* configuration option needs a reboot of the
32device it's running on.
33
34After the device has rebooted ethernet support is enabled NetworkManager will
35take over management of all available ethernet network devices on the device.
36
37NetworkManager will reuse existing configurations files from */etc/netplan*
38when ethernet support is enabled. Those will marked as immutable inside
39NetworkManager and any changes need to be written manually into the relevant
40files in */etc/netplan*.
41
42Example:
43
44```
45 $ snap set network-manager ethernet.enable=true
46 $ sudo reboot
47```
diff --git a/docs/reference/snap-configuration/wowlan.md b/docs/reference/snap-configuration/wowlan.md
index d245062..2ae0791 100644
--- a/docs/reference/snap-configuration/wowlan.md
+++ b/docs/reference/snap-configuration/wowlan.md
@@ -5,6 +5,8 @@ table_of_contents: True
55
6# Wake on WLAN6# Wake on WLAN
77
8*Available since:* 1.2.2-11
9
8Wake on WLAN (called WoWLAN in the following) is a feature which allows a device10Wake on WLAN (called WoWLAN in the following) is a feature which allows a device
9to be woken up from standby power states to faciliate device management. It is based11to be woken up from standby power states to faciliate device management. It is based
10on the well well-established standard for Wake on LAN. The functionality is not entirely12on the well well-established standard for Wake on LAN. The functionality is not entirely
diff --git a/hooks/configure b/hooks/configure
index fd39ee4..386528a 100755
--- a/hooks/configure
+++ b/hooks/configure
@@ -78,6 +78,23 @@ switch_wifi_wake_on_wlan() {
78 fi78 fi
79}79}
8080
81switch_ethernet() {
82 case "$1" in
83 true)
84 cat <<EOF > /etc/netplan/00-default-nm-renderer.yaml
85network:
86 renderer: NetworkManager
87EOF
88 ;;
89 false)
90 rm -f /etc/netplan/00-default-nm-renderer.yaml
91 ;;
92 *)
93 echo "ERROR: Invalid value provided for ethernet"
94 exit 1
95 esac
96}
97
81switch_debug_enable() {98switch_debug_enable() {
82 DEBUG_FILE=$SNAP_DATA/.debug_enabled99 DEBUG_FILE=$SNAP_DATA/.debug_enabled
83 # $1 true/false for enabling/disabling debug log level in nm100 # $1 true/false for enabling/disabling debug log level in nm
@@ -115,6 +132,18 @@ else
115 switch_wifi_wake_on_wlan disabled ""132 switch_wifi_wake_on_wlan disabled ""
116fi133fi
117134
135value=`snapctl get ethernet.enable`
136if [ -n "$value" ]; then
137 switch_ethernet $value
138else
139 if [ -e /etc/netplan/00-default-nm-renderer.yaml ]; then
140 value=true
141 else
142 value=false
143 fi
144 snapctl set ethernet.enable=$value
145fi
146
118value=$(snapctl get debug.enable)147value=$(snapctl get debug.enable)
119if [ -n "$value" ]; then148if [ -n "$value" ]; then
120 switch_debug_enable $value149 switch_debug_enable $value
diff --git a/run-tests.sh b/run-tests.sh
index 4f18f03..f069bfb 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -66,5 +66,11 @@ else
66 clone_tests_extras66 clone_tests_extras
67fi67fi
6868
69# Any project-specific options for test-runner should be specified in
70# .tests_config under EXTRA_ARGS
71if [ -e ".tests_config" ]; then
72 . .tests_config
73fi
74
69echo "INFO: Executing tests runner"75echo "INFO: Executing tests runner"
70cd $TESTS_EXTRAS_PATH && ./tests-runner.sh "$@"76cd $TESTS_EXTRAS_PATH && ./tests-runner.sh "$@" "$EXTRA_ARGS"
diff --git a/snapcraft.yaml b/snapcraft.yaml
index a7c2ea9..38a7895 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -14,10 +14,6 @@ grade: stable
14slots:14slots:
15 service: network-manager15 service: network-manager
1616
17hooks:
18 configure:
19 plugs: [nmcli]
20
21plugs:17plugs:
22 nmcli: network-manager18 nmcli: network-manager
23 wpa:19 wpa:
@@ -25,6 +21,12 @@ plugs:
25 bus: system21 bus: system
26 name: fi.w1.wpa_supplicant122 name: fi.w1.wpa_supplicant1
2723
24hooks:
25 configure:
26 plugs:
27 - nmcli
28 - network-setup-control
29
28apps:30apps:
29 nmcli:31 nmcli:
30 command: usr/bin/nmcli32 command: usr/bin/nmcli
diff --git a/tests/lib/prepare.sh b/tests/lib/prepare.sh
index ffdd477..33886eb 100644
--- a/tests/lib/prepare.sh
+++ b/tests/lib/prepare.sh
@@ -28,8 +28,9 @@ rm -f /home/network-manager/nm-state.tar.gz
2828
29snap_install network-manager29snap_install network-manager
30# FIXME: Until the store snap-declaration is updated we need to connect30# FIXME: Until the store snap-declaration is updated we need to connect
31# this plug manually.31# this plugs manually.
32snap connect network-manager:firewall-control32snap connect network-manager:firewall-control
33snap connect network-manager:network-setup-control
3334
34# Snapshot of the current snapd state for a later restore35# Snapshot of the current snapd state for a later restore
35systemctl stop snapd.service snapd.socket36systemctl stop snapd.service snapd.socket
diff --git a/tests/lib/utilities.sh b/tests/lib/utilities.sh
index b82593a..10a955a 100644
--- a/tests/lib/utilities.sh
+++ b/tests/lib/utilities.sh
@@ -20,10 +20,15 @@ switch_netplan_to_network_manager() {
20 return 020 return 0
21 fi21 fi
2222
23 cat <<-EOF > /etc/netplan/00-default-nm-renderer.yaml23 # set ethernet.enable in case the snap is already installed
24 if snap list | grep -q network-manager ; then
25 snap set network-manager ethernet.enable=true
26 else
27 cat << EOF > /etc/netplan/00-default-nm-renderer.yaml
24network:28network:
25 renderer: NetworkManager29 renderer: NetworkManager
26 EOF30EOF
31 fi
27}32}
2833
29switch_netplan_to_networkd() {34switch_netplan_to_networkd() {
@@ -31,7 +36,12 @@ switch_netplan_to_networkd() {
31 return 036 return 0
32 fi37 fi
3338
34 rm /etc/netplan/00-default-nm-renderer.yaml39 # unset ethernet.enable in case the snap is already installed
40 if snap list | grep -q network-manager ; then
41 snap set network-manager ethernet.enable=false
42 else
43 rm /etc/netplan/00-default-nm-renderer.yaml
44 fi
35}45}
3646
37# waits for a service to be active. Besides that, waits enough47# waits for a service to be active. Besides that, waits enough
@@ -75,7 +85,7 @@ wait_for_network_manager() {
75}85}
7686
77stop_after_first_reboot() {87stop_after_first_reboot() {
78 if [ $SPREAD_REBOOT -eq 1 ] ; then88 if [ $SPREAD_REBOOT -gt 0 ] ; then
79 exit 089 exit 0
80 fi90 fi
81}91}
diff --git a/tests/main/aliases/task.yaml b/tests/main/aliases/task.yaml
index f3fd040..1ae0e05 100644
--- a/tests/main/aliases/task.yaml
+++ b/tests/main/aliases/task.yaml
@@ -5,12 +5,7 @@ execute: |
5 # have them approved from the store in our snap-declaration assertion.5 # have them approved from the store in our snap-declaration assertion.
6 test ! -e /snap/bin/nmcli6 test ! -e /snap/bin/nmcli
77
8 snapd_version=$(snap version | awk '/^snapd / {print $2; exit}')8 snap alias $SNAP_NAME.nmcli nmcli
9 target=$SNAP_NAME.nmcli
10 if dpkg --compare-versions $snapd_version lt 2.25 ; then
11 target=$SNAP_NAME
12 fi
13 snap alias $target nmcli
149
15 test -e /snap/bin/nmcli10 test -e /snap/bin/nmcli
1611
diff --git a/tests/main/conf-ethernet-support/task.yaml b/tests/main/conf-ethernet-support/task.yaml
17new file mode 10064412new file mode 100644
index 0000000..5816a2b
--- /dev/null
+++ b/tests/main/conf-ethernet-support/task.yaml
@@ -0,0 +1,55 @@
1summary: Verify ethernet support can be enabled via configuration option
2
3execute: |
4 . $TESTSLIB/utilities.sh
5
6 # We need to have the network-setup-control interface available as
7 # otherwise the hook can't do its job
8 snap interfaces | grep network-setup-control
9
10 case "$SPREAD_REBOOT" in
11 0)
12 # We should now have the interface available
13 snap interfaces | grep network-setup-control
14
15 # In the default setup NetworkManager doesn't take over ethernet
16 wait_for_network_manager
17
18 /snap/bin/network-manager.nmcli d | grep 'eth0.*unmanaged'
19
20 # By default ethernet is disabled
21 test "`snap get network-manager ethernet.enable`" = "false"
22
23 # Enable ethernet support requires us to reboot two times to get
24 # things into a right state.
25 snap set network-manager ethernet.enable=true
26 test "`snap get network-manager ethernet.enable`" = "true"
27
28 REBOOT
29 ;;
30 1)
31 wait_for_network_manager
32
33 # NetworkManager now controls eth0 and networkd does not
34 /snap/bin/network-manager.nmcli d | grep 'eth0.*connected'
35 # ... and we're running with the netplan configuration
36 /snap/bin/network-manager.nmcli d | grep 'netplan-eth0'
37 networkctl status eth0 | grep 'State: routable'
38
39 # Now lets switch back to network by using the configuration
40 # item again and doing another reboot.
41 snap set network-manager ethernet.enable=false
42 test "`snap get network-manager ethernet.enable`" = "false"
43 REBOOT
44 ;;
45 2)
46 wait_for_network_manager
47
48 # networkd manages eth0 and NetworkManager does not
49 networkctl | grep 'eth0.*routable'
50 /snap/bin/network-manager.nmcli d | grep 'eth0.*unmanaged'
51 ;;
52 *)
53 exit 1
54 ;;
55 esac
diff --git a/tests/main/set-hostname/task.yaml b/tests/main/set-hostname/task.yaml
index ddcabd9..69b27c8 100644
--- a/tests/main/set-hostname/task.yaml
+++ b/tests/main/set-hostname/task.yaml
@@ -1,6 +1,10 @@
1summary: Verify we can modify the hostname of the system1summary: Verify we can modify the hostname of the system
22
3execute: |3execute: |
4 . "$TESTSLIB/utilities.sh"
5
6 wait_for_network_manager
7
4 # Print out current hostname for nm and hostnamed to have a reference8 # Print out current hostname for nm and hostnamed to have a reference
5 # for debugging later.9 # for debugging later.
6 /snap/bin/network-manager.nmcli general hostname10 /snap/bin/network-manager.nmcli general hostname

Subscribers

People subscribed via source and target branches