예제 #1
0
파일: netapplier.py 프로젝트: EdDev/nmstate
def _apply_ifaces_state(interfaces_desired_state, interfaces_current_state):
    # FIXME: Remove workaround when mainloop is integrated in the flow.
    nmclient.client(refresh=True)

    ifaces_desired_state = _index_by_name(interfaces_desired_state)
    ifaces_current_state = _index_by_name(interfaces_current_state)

    generate_ifaces_metadata(ifaces_desired_state, ifaces_current_state)

    with _setup_providers():
        _add_interfaces(ifaces_desired_state, ifaces_current_state)
        _edit_interfaces(ifaces_desired_state, ifaces_current_state)
예제 #2
0
def add_profile(connection_profile, save_to_disk=True):
    client = nmclient.client()
    mainloop = nmclient.mainloop()
    user_data = mainloop
    mainloop.push_action(
        client.add_connection_async,
        connection_profile,
        save_to_disk,
        mainloop.cancellable,
        _add_connection_callback,
        user_data,
    )
예제 #3
0
파일: device.py 프로젝트: EdDev/nmstate
def activate(dev):
    client = nmclient.client()
    mainloop = nmclient.mainloop()
    connection = specific_object = None
    user_data = mainloop
    mainloop.push_action(
        client.activate_connection_async,
        connection,
        dev,
        specific_object,
        mainloop.cancellable,
        _active_connection_callback,
        user_data,
    )
예제 #4
0
파일: device.py 프로젝트: EdDev/nmstate
def deactivate(dev):
    """
    Deactivating the current active connection,
    The profile itself is not removed.

    For software devices, deactivation removes the devices from the kernel.
    """
    client = nmclient.client()
    act_connection = dev.get_active_connection()
    if act_connection:
        mainloop = nmclient.mainloop()
        user_data = mainloop
        mainloop.push_action(
            client.deactivate_connection_async,
            act_connection,
            mainloop.cancellable,
            _deactivate_connection_callback,
            user_data,
        )
예제 #5
0
파일: device.py 프로젝트: EdDev/nmstate
def list_devices():
    client = nmclient.client(refresh=True)
    return client.get_devices()
예제 #6
0
파일: device.py 프로젝트: EdDev/nmstate
def get_device_by_name(devname):
    client = nmclient.client()
    return client.get_device_by_iface(devname)