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)
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, )
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, )
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, )
def list_devices(): client = nmclient.client(refresh=True) return client.get_devices()
def get_device_by_name(devname): client = nmclient.client() return client.get_device_by_iface(devname)