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
This commit is contained in:
Clark Boylan 2018-09-20 13:59:43 -07:00
parent 88a4e7b3cd
commit 90e6390ceb
2 changed files with 10 additions and 23 deletions

View File

@ -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.

View File

@ -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