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
diff --git a/src/provisioningserver/refresh/node_info_scripts.py b/src/provisioningserver/refresh/node_info_scripts.py
index 46d4140..29a01f8 100644
--- a/src/provisioningserver/refresh/node_info_scripts.py
+++ b/src/provisioningserver/refresh/node_info_scripts.py
@@ -287,8 +287,8 @@ def dhcp_explore():
287287
288 def get_iface_list(ifconfig_output):288 def get_iface_list(ifconfig_output):
289 return [289 return [
290 line.split()[0]290 line.split()[1].split(b':')[0].split(b'@')[0]
291 for line in ifconfig_output.splitlines()[1:]]291 for line in ifconfig_output.splitlines()]
292292
293 def has_ipv4_address(iface):293 def has_ipv4_address(iface):
294 output = check_output(('ip', '-4', 'addr', 'list', 'dev', iface))294 output = check_output(('ip', '-4', 'addr', 'list', 'dev', iface))
@@ -309,8 +309,9 @@ def dhcp_explore():
309 # a configured ipv6 interface, since ipv6 won't work there.309 # a configured ipv6 interface, since ipv6 won't work there.
310 return no_ipv6_found310 return no_ipv6_found
311311
312 all_ifaces = get_iface_list(check_output(("ifconfig", "-s", "-a")))312 all_ifaces = get_iface_list(check_output(("ip", "-o", "link", "show")))
313 configured_ifaces = get_iface_list(check_output(("ifconfig", "-s")))313 configured_ifaces = get_iface_list(check_output(
314 ("ip", "-o", "link", "show", "up")))
314 configured_ifaces_4 = [315 configured_ifaces_4 = [
315 iface for iface in configured_ifaces if has_ipv4_address(iface)]316 iface for iface in configured_ifaces if has_ipv4_address(iface)]
316 configured_ifaces_6 = [317 configured_ifaces_6 = [
diff --git a/src/provisioningserver/refresh/tests/test_node_info_scripts.py b/src/provisioningserver/refresh/tests/test_node_info_scripts.py
index 3852ded..8245d26 100644
--- a/src/provisioningserver/refresh/tests/test_node_info_scripts.py
+++ b/src/provisioningserver/refresh/tests/test_node_info_scripts.py
@@ -209,33 +209,63 @@ class TestLLDPScripts(MAASTestCase):
209209
210210
211# The two following example outputs differ because eth2 and eth1 are not211# The two following example outputs differ because eth2 and eth1 are not
212# configured and thus 'ifconfig -s -a' returns a list with both 'eth1'212# configured and thus 'ip -o link show' returns a list with both 'eth1'
213# and 'eth2' while 'ifconfig -s' does not contain them.213# and 'eth2' while 'ip -o link show up' does not contain them.
214214
215# Example output of 'ifconfig -s -a':215# Example output of 'ip -o link show':
216ifconfig_all = b"""\216ip_link_show_all = b"""\
217Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP2171: eth2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
218eth2 1500 0 0 0 0 0 0 0218 group default qlen 1000\\ link/ether 00:01:02:03:04:08 brd \
219eth1 1500 0 0 0 0 0 0 0219 ff:ff:ff:ff:ff:ff
220eth0 1500 0 1366127 0 0 0 831110 02202: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
221eth4 1500 0 0 0 0 0 0 0221 group default qlen 1000\\ link/ether 00:01:02:03:04:07 brd \
222eth5 1500 0 0 0 0 0 0 0222 ff:ff:ff:ff:ff:ff
223eth6 1500 0 0 0 0 0 0 02233: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode \
224lo 65536 0 38075 0 0 0 38075 0224 DEFAULT group default qlen 1000\\ link/ether 00:01:02:03:04:03 brd \
225virbr0 1500 0 0 0 0 0 0 0225 ff:ff:ff:ff:ff:ff
226wlan0 1500 0 2304695 0 0 0 1436049 02264: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
227 group default qlen 1000\\ link/ether 00:01:02:03:04:04 brd \
228 ff:ff:ff:ff:ff:ff
2295: eth5: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
230 group default qlen 1000\\ link/ether 00:01:02:03:04:06 brd \
231 ff:ff:ff:ff:ff:ff
2326: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
233 group default qlen 1000\\ link/ether 00:01:02:03:04:06 brd \
234 ff:ff:ff:ff:ff:ff
2357: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode \
236 DEFAULT group default qlen 1000\\ link/loopback 00:00:00:00:00:00 brd \
237 00:00:00:00:00:00
2388: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
239 group default qlen 1000\\ link/ether 00:01:02:03:04:02 brd \
240 ff:ff:ff:ff:ff:ff
2419: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT \
242 group default qlen 1000\\ link/ether 00:01:02:03:04:05 brd \
243 ff:ff:ff:ff:ff:ff
227"""244"""
228245
229# Example output of 'ifconfig -s':246# Example output of 'ip -o link show up':
230ifconfig_config = b"""\247ip_link_show = b"""\
231Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP2481: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode \
232eth0 1500 0 1366127 0 0 0 831110 0249 DEFAULT group default qlen 1000\\ link/ether 00:01:02:03:04:03 brd \
233eth4 1500 0 1366127 0 0 0 831110 0250 ff:ff:ff:ff:ff:ff
234eth5 1500 0 1366127 0 0 0 831110 02512: eth4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP mode DEFAULT \
235eth6 1500 0 1366127 0 0 0 831110 0252 group default qlen 1000\\ link/ether 00:01:02:03:04:04 brd \
236lo 65536 0 38115 0 0 0 38115 0253 ff:ff:ff:ff:ff:ff
237virbr0 1500 0 0 0 0 0 0 02543: eth5: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP mode DEFAULT \
238wlan0 1500 0 2304961 0 0 0 1436319 0255 group default qlen 1000\\ link/ether 00:01:02:03:04:06 brd \
256 ff:ff:ff:ff:ff:ff
2574: eth6: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP mode DEFAULT \
258 group default qlen 1000\\ link/ether 00:01:02:03:04:06 brd \
259 ff:ff:ff:ff:ff:ff
2605: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode \
261 DEFAULT group default qlen 1000\\ link/loopback 00:00:00:00:00:00 \
262 brd 00:00:00:00:00:00
2636: virbr0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP mode DEFAULT \
264 group default qlen 1000\\ link/ether 00:01:02:03:04:02 brd \
265 ff:ff:ff:ff:ff:ff
2667: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state UP mode DEFAULT \
267 group default qlen 1000\\ link/ether 00:01:02:03:04:05 brd \
268 ff:ff:ff:ff:ff:ff
239"""269"""
240270
241# Example output of 'ip addr list dev XX':271# Example output of 'ip addr list dev XX':
@@ -306,7 +336,7 @@ class TestDHCPExplore(MAASTestCase):
306 def test_calls_dhclient_on_unconfigured_interfaces(self):336 def test_calls_dhclient_on_unconfigured_interfaces(self):
307 check_output = self.patch(subprocess, "check_output")337 check_output = self.patch(subprocess, "check_output")
308 check_output.side_effect = [338 check_output.side_effect = [
309 ifconfig_all, ifconfig_config,339 ip_link_show_all, ip_link_show,
310 ip_eth0, ip_eth4, ip_eth5, ip_eth6, ip_lo, ip_virbr0, ip_wlan0,340 ip_eth0, ip_eth4, ip_eth5, ip_eth6, ip_lo, ip_virbr0, ip_wlan0,
311 ip_eth0, ip_eth4, ip_eth5, ip_eth6, ip_lo, ip_virbr0, ip_wlan0341 ip_eth0, ip_eth4, ip_eth5, ip_eth6, ip_lo, ip_virbr0, ip_wlan0
312 ]342 ]

Subscribers

People subscribed via source and target branches