def writeBonding(f, netcfg, ha_status, bonding, is_first=False): ordered_nets = tuple(bonding.nets) discard_services = any_ha(ha_status) autonomous = hasIPConfiguration(bonding, discard_services=discard_services) #autonomous=True: #always mark bonding auto writePreamble(f, netcfg, bonding, ordered_nets, autonomous=True) if is_first: addStatement(f, 'pre-up modprobe bonding') for statement in ( 'pre-up echo +%s > /sys/class/net/bonding_masters' % bonding.system_name, 'pre-down echo -%s > /sys/class/net/bonding_masters' % bonding.system_name ): addStatement(f, statement) sorted_ethernets = list(bonding.ethernets) sorted_ethernets.sort() for ethernet in sorted_ethernets: for statement in ( 'up /sbin/ifenslave %s %s' % (bonding.system_name, ethernet.system_name), 'down /sbin/ifenslave %s -d %s' % (bonding.system_name, ethernet.system_name) ): addStatement(f, statement) if autonomous: writeNets(f, ha_status, bonding, ordered_nets) writeRoutes(f, bonding) else: forceCreation(f, bonding) f.write('\n')
def iterIpNotResources(self, iface, ha_type): """ Return primary or secondary ips formatted as ***ha resources*** iface parameter must be interface_system_name """ if not any_ha(ha_type): return for ip in getHaIp(self.net, ha_type): yield self.formatIpResource(ip, iface)
def writeVlan(f, netcfg, ha_status, vlan): ordered_nets = tuple(vlan.nets) discard_services = any_ha(ha_status) autonomous = hasIPConfiguration(vlan, discard_services=discard_services) # Always add preamble and vlan-raw-device writePreamble(f, netcfg, vlan, ordered_nets) if autonomous: writeNets(f, ha_status, vlan, ordered_nets) writeRoutes(f, vlan) else: forceCreation(f, vlan) addStatement( f, 'vlan-raw-device %s' % vlan.raw_device, ignore_fail=True ) f.write('\n')