def _setup_providers(): mainloop = nmclient.mainloop() yield if mainloop.actions_exists(): mainloop.execute_next_action() success = mainloop.run(timeout=20) if not success: raise ApplyError(mainloop.error)
def commit_profile(connection_profile, save_to_disk=True): mainloop = nmclient.mainloop() user_data = mainloop mainloop.push_action( connection_profile.commit_changes_async, save_to_disk, mainloop.cancellable, _commit_changes_callback, user_data, )
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 delete(dev): """Removes all device profiles.""" connections = dev.get_available_connections() mainloop = nmclient.mainloop() user_data = mainloop for con in connections: mainloop.push_action( con.delete_async, mainloop.cancellable, _delete_connection_callback, user_data, )
def _setup_providers(): if nm.checkpoint.has_checkpoint_capability(): checkpoint_ctx = nm.checkpoint.CheckPoint() else: checkpoint_ctx = _placeholder_ctx() with checkpoint_ctx: mainloop = nmclient.mainloop() yield if mainloop.actions_exists(): mainloop.execute_next_action() success = mainloop.run(timeout=20) if not success: raise ApplyError(mainloop.error)
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 _safe_delete_async(dev): """Removes all device profiles.""" connections = dev.get_available_connections() mainloop = nmclient.mainloop() if not connections: # No callback is expected, so we should call the next one. mainloop.execute_next_action() return user_data = mainloop for con in connections: con.delete_async( mainloop.cancellable, _delete_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 delete(dev): mainloop = nmclient.mainloop() mainloop.push_action(_safe_delete_async, dev)