From 90e6390ceb9d70fc1d7fdcdbcc17916e0b8fe9cf Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Thu, 20 Sep 2018 13:59:43 -0700 Subject: [PATCH] Debian interface config set bond once There are bond details that apply to all the interface types. Rather than set them separately for each interface type just set them once. Change-Id: Id1abb85ab32a12adea92e337d00e2a03e877021a --- glean/cmd.py | 27 +++++-------------- .../fixtures/test/liberty.debian.network.out | 6 ++--- 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/glean/cmd.py b/glean/cmd.py index 40bda91..e4211ab 100644 --- a/glean/cmd.py +++ b/glean/cmd.py @@ -834,21 +834,8 @@ def write_debian_interfaces(interfaces, sys_interfaces): result += " vlan-raw-device {0}\n".format(vlan_raw_device) result += " hw-mac-address {0}\n".format( interface['mac_address']) - if 'bond_mode' in interface: - result += _write_debian_bond_conf(interface_name, - interface, - sys_interfaces) - elif interface['type'] == 'manual': result += "iface {0} inet manual\n".format(interface_name) - if 'bond_master' in interface: - result += " bond-master {0}\n".format( - interface['bond_master']) - if 'bond_mode' in interface: - result += _write_debian_bond_conf(interface_name, - interface, - sys_interfaces) - else: # Static ipv4 and ipv6 if interface['type'] == 'ipv6': @@ -863,13 +850,6 @@ def write_debian_interfaces(interfaces, sys_interfaces): name=interface_name, link_type=link_type) if vlan_raw_device: result += " vlan-raw-device {0}\n".format(vlan_raw_device) - if 'bond_master' in interface: - result += " bond-master {0}\n".format( - interface['bond_master']) - if 'bond_mode' in interface: - result += _write_debian_bond_conf(interface_name, - interface, - sys_interfaces) result += " address {0}\n".format(interface['ip_address']) if interface['type'] == 'ipv4': @@ -904,6 +884,13 @@ def write_debian_interfaces(interfaces, sys_interfaces): result += route_del.format( net=route['network'], mask=_netmask, gw=route['gateway'], interface=interface_name) + if 'bond_master' in interface: + result += " bond-master {0}\n".format( + interface['bond_master']) + if 'bond_mode' in interface: + result += _write_debian_bond_conf(interface_name, + interface, + sys_interfaces) files_to_write[iface_path] = result # Configure any interfaces not mentioned in the config drive data for DHCP. diff --git a/glean/tests/fixtures/test/liberty.debian.network.out b/glean/tests/fixtures/test/liberty.debian.network.out index 0e2f425..92b95b4 100644 --- a/glean/tests/fixtures/test/liberty.debian.network.out +++ b/glean/tests/fixtures/test/liberty.debian.network.out @@ -76,6 +76,9 @@ iface bond1.27 inet dhcp ### Write /etc/network/interfaces.d/bond2.cfg auto bond2 iface bond2 inet static + address 192.0.2.2 + netmask 255.255.255.0 + gateway 192.0.2.1 hwaddress bc:76:4e:05:7b:17 bond-mode 802.3ad bond-miimon 100 @@ -84,9 +87,6 @@ iface bond2 inet static bond-slaves none post-up ifenslave bond2 eth9 eth10 pre-down ifenslave -d bond2 eth9 eth10 - address 192.0.2.2 - netmask 255.255.255.0 - gateway 192.0.2.1 ### Write /etc/resolv.conf nameserver 72.3.128.241 nameserver 72.3.128.240