def _expected_events(nic, address, cidr): events_add = [ {'event': 'new_link', 'name': nic}, {'event': 'new_link', 'name': nic}, ] events_del = [{'event': 'del_link', 'name': nic}] events_add_ipv4 = [ {'event': 'new_addr', 'address': address + '/' + cidr} ] events_add_ipv6 = [{'event': 'new_addr', 'family': 'inet6'}] events_del_ipv4 = [ {'address': address + '/' + cidr, 'event': 'del_addr'}, {'destination': address, 'event': 'del_route'}, ] events_del_ipv6 = [{'event': 'del_addr', 'family': 'inet6'}] if is_disabled_ipv6(): return deque( events_add + events_add_ipv4 + events_del_ipv4 + events_del ) else: return deque( events_add + events_add_ipv6 + events_add_ipv4 + events_del_ipv6 + events_del_ipv4 + events_del )
def add(iface, ipv4, ipv6): if ipv4: _add_ipv4_address(iface, ipv4) if ipv6: if sysctl.is_disabled_ipv6(iface): sysctl.enable_ipv6(iface) _add_ipv6_address(iface, ipv6) elif ipv6_supported(): sysctl.disable_ipv6(iface)
def add(iface, ipv4, ipv6): if ipv4: _add_ipv4_address(iface, ipv4) if ipv6: if sysctl.is_disabled_ipv6(iface): sysctl.enable_ipv6(iface) _add_ipv6_address(iface, ipv6) elif ipv6_supported(): sysctl.disable_ipv6(iface)
def _expected_events(nic, address, cidr): events_add = [ {'event': 'new_link', 'name': nic}, {'event': 'new_addr', 'address': address + '/' + cidr}, {'event': 'new_link', 'name': nic}] events_del = [ {'address': address + '/' + cidr, 'event': 'del_addr'}, {'destination': address, 'event': 'del_route'}, {'event': 'del_link', 'name': nic}] events_ipv6 = [ {'event': 'new_addr', 'family': 'inet6'}, {'event': 'del_addr', 'family': 'inet6'}] if is_disabled_ipv6(): return deque(events_add + events_del) else: return deque(events_add + events_ipv6 + events_del)