示例#1
0
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)