def writeNets(fd, ha_status, interface, ordered_nets): for phase in ('pre-up pre-down'.split()): fd.write(' %s ip addr flush dev %s ||:\n' % (phase, interface.system_name)) for net_index, net in enumerate(ordered_nets): if EDENWALL: ips = getHaIp(net, ha_status) else: ips = net.ip_addrs for ip_index, ip in enumerate(ips): if net.net.version() == 6: netmask = net.net.prefixlen() else: netmask = net.net.netmask() broadcast = net.net.broadcast() address = unicode(ip) if net_index + ip_index == 0: fd.write(' address %s\n' % address) fd.write(' netmask %s\n' % netmask) fd.write(' broadcast %s\n' % broadcast) else: prefix_len = net.net.prefixlen() fd.write(' post-up ip addr add dev %s %s/%s broadcast %s ||:\n' % (interface.system_name, address, prefix_len, broadcast))
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)