workaround for ubuntu 14.04 bonding issue

The bond0 /e/n/i.d/bond0.cfg needs to be written a little differently to
account for some quirks in Ubuntu 14.04.

This patch will change the following:

1) "pre-up route add" becomes just "up route add"
2) "post-down route del" becomes just "down route del"
3) "bond-slaves eth0 eth2" becomes just "bond slaves none"
4) "post-up ifenslave bond0 eth0 eth2" added to end of config
5) "pre-down ifenslave -d bond0 eth0 eth2" added to end of config

Change-Id: I8bde314c27235546207317f6b9acfa01272dd1e5
This commit is contained in:
CullenTaylor 2016-07-07 10:20:15 -05:00
parent 36f36e01b2
commit 97f38cec88
5 changed files with 46 additions and 28 deletions

View File

@ -30,8 +30,10 @@ from glean import systemlock
log = logging.getLogger("glean")
post_up = " post-up route add -net {net} netmask {mask} gw {gw} || true\n"
pre_down = " pre-down route del -net {net} netmask {mask} gw {gw} || true\n"
route_add = " up route add -net {net} netmask {mask} gw {gw} || true\n"
route_del = " down route del -net {net} netmask {mask} gw {gw} || true\n"
slaves_add = " post-up ifenslave {0} {1}\n"
slaves_del = " pre-down ifenslave -d {0} {1}\n"
def _exists_rh_interface(name):
@ -393,7 +395,9 @@ def write_debian_interfaces(interfaces, sys_interfaces):
slave_devices = [sys_interfaces[mac]
for mac in interface['raw_macs']]
slaves = ' '.join(slave_devices)
result += " bond-slaves {0}\n".format(slaves)
result += " bond-slaves none\n"
result += slaves_add.format(interface_name, slaves)
result += slaves_del.format(interface_name, slaves)
files_to_write[iface_path] = result
continue
@ -417,7 +421,9 @@ def write_debian_interfaces(interfaces, sys_interfaces):
slave_devices = [sys_interfaces[mac]
for mac in interface['raw_macs']]
slaves = ' '.join(slave_devices)
result += " bond-slaves {0}\n".format(slaves)
result += " bond-slaves none\n"
result += slaves_add.format(interface_name, slaves)
result += slaves_del.format(interface_name, slaves)
files_to_write[iface_path] = result
continue
@ -452,17 +458,19 @@ def write_debian_interfaces(interfaces, sys_interfaces):
slave_devices = [sys_interfaces[mac]
for mac in interface['raw_macs']]
slaves = ' '.join(slave_devices)
result += " bond-slaves {0}\n".format(slaves)
result += " bond-slaves none\n"
result += slaves_add.format(interface_name, slaves)
result += slaves_del.format(interface_name, slaves)
result += " address {0}\n".format(interface['ip_address'])
result += " netmask {0}\n".format(interface['netmask'])
for route in interface['routes']:
if route['network'] == '0.0.0.0' and route['netmask'] == '0.0.0.0':
result += " gateway {0}\n".format(route['gateway'])
else:
result += post_up.format(
result += route_add.format(
net=route['network'], mask=route['netmask'],
gw=route['gateway'])
result += pre_down.format(
result += route_del.format(
net=route['network'], mask=route['netmask'],
gw=route['gateway'])
files_to_write[iface_path] = result

View File

@ -13,10 +13,10 @@ auto eth1
iface eth1 inet static
address 10.208.169.118
netmask 255.255.224.0
post-up route add -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
pre-down route del -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
post-up route add -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
pre-down route del -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
up route add -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
down route del -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
up route add -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
down route del -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
### Write /etc/network/interfaces.d/eth3.cfg
auto eth3
iface eth3 inet dhcp
@ -46,7 +46,9 @@ iface bond0 inet dhcp
bond-miimon 100
bond-lacp-rate slow
bond-xmit_hash_policy layer3+4
bond-slaves eth5 eth6
bond-slaves none
post-up ifenslave bond0 eth5 eth6
pre-down ifenslave -d bond0 eth5 eth6
### Write /etc/network/interfaces.d/eth7.cfg
auto eth7
iface eth7 inet manual
@ -63,7 +65,9 @@ iface bond1 inet manual
bond-miimon 100
bond-lacp-rate slow
bond-xmit_hash_policy layer3+4
bond-slaves eth7 eth8
bond-slaves none
post-up ifenslave bond1 eth7 eth8
pre-down ifenslave -d bond1 eth7 eth8
### Write /etc/network/interfaces.d/bond1.27.cfg
auto bond1.27
iface bond1.27 inet dhcp
@ -77,7 +81,9 @@ iface bond2 inet static
bond-miimon 100
bond-lacp-rate slow
bond-xmit_hash_policy layer3+4
bond-slaves eth9 eth10
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

View File

@ -13,10 +13,10 @@ auto eth1
iface eth1 inet static
address 10.208.169.118
netmask 255.255.224.0
post-up route add -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
pre-down route del -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
post-up route add -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
pre-down route del -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
up route add -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
down route del -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
up route add -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
down route del -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
### Write /etc/network/interfaces.d/eth3.cfg
auto eth3
iface eth3 inet dhcp
@ -46,7 +46,9 @@ iface bond0 inet dhcp
bond-miimon 100
bond-lacp-rate slow
bond-xmit_hash_policy layer3+4
bond-slaves eth5 eth6
bond-slaves none
post-up ifenslave bond0 eth5 eth6
pre-down ifenslave -d bond0 eth5 eth6
### Write /etc/network/interfaces.d/eth7.cfg
auto eth7
iface eth7 inet manual
@ -63,7 +65,9 @@ iface bond1 inet manual
bond-miimon 100
bond-lacp-rate slow
bond-xmit_hash_policy layer3+4
bond-slaves eth7 eth8
bond-slaves none
post-up ifenslave bond1 eth7 eth8
pre-down ifenslave -d bond1 eth7 eth8
### Write /etc/network/interfaces.d/bond1.27.cfg
auto bond1.27
iface bond1.27 inet dhcp

View File

@ -13,10 +13,10 @@ auto eth1
iface eth1 inet static
address 10.208.169.118
netmask 255.255.224.0
post-up route add -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
pre-down route del -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
post-up route add -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
pre-down route del -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
up route add -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
down route del -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
up route add -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
down route del -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
### Write /etc/network/interfaces.d/eth3.cfg
auto eth3
iface eth3 inet dhcp

View File

@ -13,10 +13,10 @@ auto eth1
iface eth1 inet static
address 10.208.169.118
netmask 255.255.224.0
post-up route add -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
pre-down route del -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
post-up route add -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
pre-down route del -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
up route add -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
down route del -net 10.176.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
up route add -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
down route del -net 10.208.0.0 netmask 255.240.0.0 gw 10.208.160.1 || true
### Write /etc/network/interfaces.d/eth3.cfg
auto eth3
iface eth3 inet dhcp