Merge ~andreserl/maas:2.3_lp1759284_fix_commissioning_ifaces_bionic into maas:2.3

Proposed by Andres Rodriguez
Status: Merged
Approved by: Andres Rodriguez
Approved revision: be96588714b7c16439a4b479f69a172f9b359f5f
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~andreserl/maas:2.3_lp1759284_fix_commissioning_ifaces_bionic
Merge into: maas:2.3
Diff against target: 129 lines (+61/-30)
2 files modified
src/provisioningserver/refresh/node_info_scripts.py (+5/-4)
src/provisioningserver/refresh/tests/test_node_info_scripts.py (+56/-26)
Reviewer Review Type Date Requested Status
Andres Rodriguez (community) Approve
Review via email: mp+343211@code.launchpad.net

Commit message

LP: #1759284 - Change the interface name gathering during commissioning

The interface names can now be larger than 8 characters before Bionic.
Bionic forward these can be much larger than that. This caused issues
where ifconfig -s would not output the whole interface name. As such,
change the mechanism in which how we discover the interfaces for the DHCP
commissioning script.

Backport: 30729b9dbd4ae82630ea01ee368fcd071c70ac06

To post a comment you must log in.
Revision history for this message
Andres Rodriguez (andreserl) wrote :

selfie!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/src/provisioningserver/refresh/node_info_scripts.py b/src/provisioningserver/refresh/node_info_scripts.py
2index 46d4140..29a01f8 100644
3--- a/src/provisioningserver/refresh/node_info_scripts.py
4+++ b/src/provisioningserver/refresh/node_info_scripts.py
5@@ -287,8 +287,8 @@ def dhcp_explore():
6
7 def get_iface_list(ifconfig_output):
8 return [
9- line.split()[0]
10- for line in ifconfig_output.splitlines()[1:]]
11+ line.split()[1].split(b':')[0].split(b'@')[0]
12+ for line in ifconfig_output.splitlines()]
13
14 def has_ipv4_address(iface):
15 output = check_output(('ip', '-4', 'addr', 'list', 'dev', iface))
16@@ -309,8 +309,9 @@ def dhcp_explore():
17 # a configured ipv6 interface, since ipv6 won't work there.
18 return no_ipv6_found
19
20- all_ifaces = get_iface_list(check_output(("ifconfig", "-s", "-a")))
21- configured_ifaces = get_iface_list(check_output(("ifconfig", "-s")))
22+ all_ifaces = get_iface_list(check_output(("ip", "-o", "link", "show")))
23+ configured_ifaces = get_iface_list(check_output(
24+ ("ip", "-o", "link", "show", "up")))
25 configured_ifaces_4 = [
26 iface for iface in configured_ifaces if has_ipv4_address(iface)]
27 configured_ifaces_6 = [
28diff --git a/src/provisioningserver/refresh/tests/test_node_info_scripts.py b/src/provisioningserver/refresh/tests/test_node_info_scripts.py
29index 3852ded..8245d26 100644
30--- a/src/provisioningserver/refresh/tests/test_node_info_scripts.py
31+++ b/src/provisioningserver/refresh/tests/test_node_info_scripts.py
32@@ -209,33 +209,63 @@ class TestLLDPScripts(MAASTestCase):
33
34
35 # The two following example outputs differ because eth2 and eth1 are not
36-# configured and thus 'ifconfig -s -a' returns a list with both 'eth1'
37-# and 'eth2' while 'ifconfig -s' does not contain them.
38-
39-# Example output of 'ifconfig -s -a':
40-ifconfig_all = b"""\
41-Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP
42-eth2 1500 0 0 0 0 0 0 0
43-eth1 1500 0 0 0 0 0 0 0
44-eth0 1500 0 1366127 0 0 0 831110 0
45-eth4 1500 0 0 0 0 0 0 0
46-eth5 1500 0 0 0 0 0 0 0
47-eth6 1500 0 0 0 0 0 0 0
48-lo 65536 0 38075 0 0 0 38075 0
49-virbr0 1500 0 0 0 0 0 0 0
50-wlan0 1500 0 2304695 0 0 0 1436049 0
51+# configured and thus 'ip -o link show' returns a list with both 'eth1'
52+# and 'eth2' while 'ip -o link show up' does not contain them.
53+
54+# Example output of 'ip -o link show':
55+ip_link_show_all = b"""\
56+1: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
57+ group default qlen 1000\\ link/ether 00:01:02:03:04:08 brd \
58+ ff:ff:ff:ff:ff:ff
59+2: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
60+ group default qlen 1000\\ link/ether 00:01:02:03:04:07 brd \
61+ ff:ff:ff:ff:ff:ff
62+3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode \
63+ DEFAULT group default qlen 1000\\ link/ether 00:01:02:03:04:03 brd \
64+ ff:ff:ff:ff:ff:ff
65+4: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
66+ group default qlen 1000\\ link/ether 00:01:02:03:04:04 brd \
67+ ff:ff:ff:ff:ff:ff
68+5: eth5: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
69+ group default qlen 1000\\ link/ether 00:01:02:03:04:06 brd \
70+ ff:ff:ff:ff:ff:ff
71+6: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
72+ group default qlen 1000\\ link/ether 00:01:02:03:04:06 brd \
73+ ff:ff:ff:ff:ff:ff
74+7: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode \
75+ DEFAULT group default qlen 1000\\ link/loopback 00:00:00:00:00:00 brd \
76+ 00:00:00:00:00:00
77+8: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
78+ group default qlen 1000\\ link/ether 00:01:02:03:04:02 brd \
79+ ff:ff:ff:ff:ff:ff
80+9: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
81+ group default qlen 1000\\ link/ether 00:01:02:03:04:05 brd \
82+ ff:ff:ff:ff:ff:ff
83 """
84
85-# Example output of 'ifconfig -s':
86-ifconfig_config = b"""\
87-Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP
88-eth0 1500 0 1366127 0 0 0 831110 0
89-eth4 1500 0 1366127 0 0 0 831110 0
90-eth5 1500 0 1366127 0 0 0 831110 0
91-eth6 1500 0 1366127 0 0 0 831110 0
92-lo 65536 0 38115 0 0 0 38115 0
93-virbr0 1500 0 0 0 0 0 0 0
94-wlan0 1500 0 2304961 0 0 0 1436319 0
95+# Example output of 'ip -o link show up':
96+ip_link_show = b"""\
97+1: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode \
98+ DEFAULT group default qlen 1000\\ link/ether 00:01:02:03:04:03 brd \
99+ ff:ff:ff:ff:ff:ff
100+2: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP mode DEFAULT \
101+ group default qlen 1000\\ link/ether 00:01:02:03:04:04 brd \
102+ ff:ff:ff:ff:ff:ff
103+3: eth5: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP mode DEFAULT \
104+ group default qlen 1000\\ link/ether 00:01:02:03:04:06 brd \
105+ ff:ff:ff:ff:ff:ff
106+4: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP mode DEFAULT \
107+ group default qlen 1000\\ link/ether 00:01:02:03:04:06 brd \
108+ ff:ff:ff:ff:ff:ff
109+5: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode \
110+ DEFAULT group default qlen 1000\\ link/loopback 00:00:00:00:00:00 \
111+ brd 00:00:00:00:00:00
112+6: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP mode DEFAULT \
113+ group default qlen 1000\\ link/ether 00:01:02:03:04:02 brd \
114+ ff:ff:ff:ff:ff:ff
115+7: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP mode DEFAULT \
116+ group default qlen 1000\\ link/ether 00:01:02:03:04:05 brd \
117+ ff:ff:ff:ff:ff:ff
118 """
119
120 # Example output of 'ip addr list dev XX':
121@@ -306,7 +336,7 @@ class TestDHCPExplore(MAASTestCase):
122 def test_calls_dhclient_on_unconfigured_interfaces(self):
123 check_output = self.patch(subprocess, "check_output")
124 check_output.side_effect = [
125- ifconfig_all, ifconfig_config,
126+ ip_link_show_all, ip_link_show,
127 ip_eth0, ip_eth4, ip_eth5, ip_eth6, ip_lo, ip_virbr0, ip_wlan0,
128 ip_eth0, ip_eth4, ip_eth5, ip_eth6, ip_lo, ip_virbr0, ip_wlan0
129 ]

Subscribers

People subscribed via source and target branches