Exemplo n.º 1
0
def _apply_ifaces_state(interfaces_desired_state):
    ifaces_desired_state = _index_by_name(interfaces_desired_state)
    ifaces_current_state = _index_by_name(netinfo.interfaces())

    generate_ifaces_metadata(ifaces_desired_state, ifaces_current_state)

    with _transaction():
        with _setup_providers():
            _add_interfaces(ifaces_desired_state, ifaces_current_state)
        with _setup_providers():
            ifaces_current_state = _index_by_name(netinfo.interfaces())
            _edit_interfaces(ifaces_desired_state, ifaces_current_state)
Exemplo n.º 2
0
def apply(desired_state):
    validator.verify(desired_state)
    validator.verify_capabilities(desired_state, netinfo.capabilities())

    interfaces_current_state = netinfo.interfaces()

    _apply_ifaces_state(desired_state['interfaces'], interfaces_current_state)
Exemplo n.º 3
0
def _apply_ifaces_state(interfaces_desired_state, verify_change):
    ifaces_desired_state = _index_by_name(interfaces_desired_state)
    ifaces_current_state = _index_by_name(netinfo.interfaces())

    ifaces_desired_state = sanitize_ethernet_state(ifaces_desired_state,
                                                   ifaces_current_state)
    ifaces_desired_state = sanitize_dhcp_state(ifaces_desired_state)
    generate_ifaces_metadata(ifaces_desired_state, ifaces_current_state)

    with _transaction():
        with _setup_providers():
            _add_interfaces(ifaces_desired_state, ifaces_current_state)
        with _setup_providers():
            ifaces_current_state = _index_by_name(netinfo.interfaces())
            _edit_interfaces(ifaces_desired_state, ifaces_current_state)
        if verify_change:
            _verify_change(ifaces_desired_state)
Exemplo n.º 4
0
def _verify_change(ifaces_desired_state):
    ifaces_current_state = _index_by_name(netinfo.interfaces())
    ifaces_desired_state = _remove_absent_iface_entries(
        ifaces_desired_state)
    ifaces_desired_state = _remove_down_virt_iface_entries(
        ifaces_desired_state)
    ifaces_desired_state = remove_ifaces_metadata(ifaces_desired_state)

    assert_ifaces_state(ifaces_desired_state, ifaces_current_state)
Exemplo n.º 5
0
def _apply_ifaces_state(interfaces_desired_state, verify_change):
    ifaces_desired_state = _index_by_name(interfaces_desired_state)
    ifaces_current_state = _index_by_name(netinfo.interfaces())

    ifaces_desired_state = sanitize_ethernet_state(ifaces_desired_state)
    generate_ifaces_metadata(ifaces_desired_state, ifaces_current_state)

    with _transaction():
        with _setup_providers():
            _add_interfaces(ifaces_desired_state, ifaces_current_state)
        with _setup_providers():
            ifaces_current_state = _index_by_name(netinfo.interfaces())
            _edit_interfaces(ifaces_desired_state, ifaces_current_state)
        if verify_change:
            # FIXME: Remove this sleep after adding wait for state mechanism.
            time.sleep(2)
            ifaces_current_state = _index_by_name(netinfo.interfaces())
            ifaces_desired_state = remove_ifaces_metadata(ifaces_desired_state)
            assert_ifaces_state(ifaces_desired_state, ifaces_current_state)