Esempio n. 1
0
def remove_dhcp_monitoring(iface, family):
    """
    Remove iface and family combination from DHCP IP monitoring
    :param iface: Interface name
    :param family: 4 (IPv4) or 6 (IPv6)
    """
    MonitoredItemPool.instance().remove((iface, family))
Esempio n. 2
0
def clear_monitor_pool():
    yield
    pool = MonitoredItemPool.instance()
    if not pool.is_pool_empty():
        # Some tests are not able to clear the pool
        # (without running dhcp server).
        # The same applies if the waiting for dhcp monitor times out.
        pool.clear_pool()
Esempio n. 3
0
def is_dhcp_ip_monitored(iface, family):
    """
    Check if combination of iface and family is configured for DHCP
    IP monitoring
    :param iface: Interface name
    :param family: 4 (IPv4) or 6 (IPv6)
    :return: True if the combination is monitored for DHCP IP changes
    """
    return MonitoredItemPool.instance().is_item_in_pool((iface, family))
Esempio n. 4
0
def _setup_dynamic_src_routing(networks):
    pool = MonitoredItemPool.instance()
    for net_name, net_attrs in six.viewitems(networks):
        is_remove = net_attrs.get('remove', False)
        is_dhcpv4 = net_attrs.get('bootproto') == 'dhcp'
        is_dhcpv6 = net_attrs.get('dhcpv6', False)
        iface = _get_network_iface(net_name, net_attrs)
        if is_remove:
            continue

        if is_dhcpv4:
            pool.add((iface, 4))
        if is_dhcpv6:
            pool.add((iface, 6))
Esempio n. 5
0
def add_sourceroute(iface, ip, mask, route, family=None):
    if not family:
        family = 4
    else:
        pool = MonitoredItemPool.instance()
        item = (iface, family)
        if pool.is_item_in_pool(item):
            pool.remove(item)
        else:
            logging.warning(
                f'Nic {iface} is not configured for IPv{family} monitoring.')
            return

    if family == 4:
        sourceroute.add(iface, ip, mask, route)
Esempio n. 6
0
def _wait_for_dhcp_response(timeout=5):
    _wait_for_func(MonitoredItemPool.instance().is_pool_empty, timeout)