import sys
import time
-sysfs_bonding_masters = "/sys/class/net/bonding_masters"
+sysfs_bonding_masters = root_prefix() + "/sys/class/net/bonding_masters"
def open_pif_ifcfg(pif):
pifrec = db().get_pif_record(pif)
interface = pif_netdev_name(pif)
log("Configuring %s (%s)" % (interface, pifrec['MAC']))
- f = ConfigurationFile("/etc/sysconfig/network-scripts/ifcfg-%s" % interface)
+ f = ConfigurationFile("%s/etc/sysconfig/network-scripts/ifcfg-%s" % (root_prefix(), interface))
f.write("# DO NOT EDIT: This file (%s) was autogenerated by %s\n" % \
(os.path.basename(f.path()), os.path.basename(sys.argv[0])))
log("Failed to load bonding driver: %s" % e)
def bonding_driver_loaded():
- lines = open("/proc/modules").read().split("\n")
+ lines = open(root_prefix() + "/proc/modules").read().split("\n")
modules = [line.split(" ")[0] for line in lines]
return "bonding" in modules
def interface_is_up(pif):
try:
interface = pif_netdev_name(pif)
- state = open("/sys/class/net/%s/operstate" % interface).read().strip()
+ state = open("%s/sys/class/net/%s/operstate" % (root_prefix(), interface)).read().strip()
return state == "up"
except:
return False # interface prolly doesn't exist
pifrec = db().get_pif_record(pif)
+ log("Configuring physical interface %s" % pifrec['device'])
+
f = open_pif_ifcfg(pif)
f.write("TYPE=Ethernet\n")
f.write("HWADDR=%(MAC)s\n" % pifrec)
- settings,offload = ethtool_settings(pifrec['other_config'])
+ settings,offload = ethtool_settings(pifrec['other_config'],
+ PIF_OTHERCONFIG_DEFAULTS)
if len(settings):
f.write("ETHTOOL_OPTS=\"%s\"\n" % str.join(" ", settings))
if len(offload):
f.write("ETHTOOL_OFFLOAD_OPTS=\"%s\"\n" % str.join(" ", offload))
- mtu = mtu_setting(pifrec['other_config'])
+ mtu = mtu_setting(pifrec['network'], "PIF", pifrec['other_config'])
if mtu:
f.write("MTU=%s\n" % mtu)
# which they were attached. The first slave attached must be the last detached since
# the bond is using its MAC address.
try:
- attached_slaves = open("/sys/class/net/%s/bonding/slaves" % pifrec['device']).readline().split()
+ attached_slaves = open("%s/sys/class/net/%s/bonding/slaves" % (root_prefix(), pifrec['device'])).readline().split()
for slave in attached_slaves:
pifs = [p for p in db().get_pifs_by_device(slave) if not pif_is_vlan(p)]
slave_pif = pifs[0]
if len(offload):
f.write("ETHTOOL_OFFLOAD_OPTS=\"%s\"\n" % str.join(" ", offload))
- mtu = mtu_setting(pifrec['other_config'])
+ mtu = mtu_setting(pifrec['network'], "Bond-PIF", pifrec['other_config'])
if mtu:
f.write("MTU=%s\n" % mtu)
"downdelay": "200",
"updelay": "31000",
"use_carrier": "1",
+ "hashing-algorithm": "src_mac",
}
# override defaults with values from other-config whose keys being with "bond-"
if len(offload):
f.write("ETHTOOL_OFFLOAD_OPTS=\"%s\"\n" % str.join(" ", offload))
- mtu = mtu_setting(pifrec['other_config'])
+ mtu = mtu_setting(pifrec['network'], "VLAN-PIF", pifrec['other_config'])
if mtu:
f.write("MTU=%s\n" % mtu)
class DatapathBridge(Datapath):
def __init__(self, pif):
+ if pif_is_tunnel(pif):
+ raise Error("Tunnel PIFs are not supported in Bridge mode")
+
Datapath.__init__(self, pif)
log("Configured for Bridge datapath")