diff options
author | Thomas Haller <thaller@redhat.com> | 2018-03-28 08:09:56 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-04-04 14:02:13 +0200 |
commit | f67303221bdc8098cb3b6203ec777b294e412971 (patch) | |
tree | c084b9d71667d8bdb8617e36cc965ee437ee751f /libnm/nm-manager.c | |
parent | ab8312a18e8b281a62f39ce59a077fda77943187 (diff) | |
download | NetworkManager-f67303221bdc8098cb3b6203ec777b294e412971.tar.gz |
checkpoint: allow resetting the rollback timeout via D-Bus
This allows to adjust the timeout of an existing checkpoint.
The main usecase of checkpoints, is to have a fail-safe when
configuring the network remotely. By allowing to reset the timeout,
the user can perform a series of actions, and keep bumping the
timeout. That way, the entire series is still guarded by the same
checkpoint, but the user can start with short timeout, and
re-adjust the timeout as he goes along.
The libnm API only implements the async form (at least for now).
Sync methods are fundamentally wrong with D-Bus, and it's probably
not needed. Also, follow glib convenction, where the async form
doesn't have the _async name suffix. Also, accept a D-Bus path
as argument, not a NMCheckpoint instance. The libnm API should
not be more restricted than the underlying D-Bus API. It would
be cumbersome to require the user to lookup the NMCheckpoint
instance first, especially since libnm doesn't provide an efficient
or convenient lookup-by-path method. On the other hand, retrieving
the path from a NMCheckpoint instance is always possible.
Diffstat (limited to 'libnm/nm-manager.c')
-rw-r--r-- | libnm/nm-manager.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/libnm/nm-manager.c b/libnm/nm-manager.c index b8a0b9c046..57af227c23 100644 --- a/libnm/nm-manager.c +++ b/libnm/nm-manager.c @@ -1545,6 +1545,66 @@ nm_manager_checkpoint_rollback_finish (NMManager *manager, return g_simple_async_result_get_op_res_gpointer (simple); } +static void +checkpoint_adjust_rollback_timeout_cb (GObject *object, + GAsyncResult *result, + gpointer user_data) +{ + gs_unref_object GSimpleAsyncResult *simple = user_data; + GError *error = NULL; + + if (nmdbus_manager_call_checkpoint_adjust_rollback_timeout_finish (NMDBUS_MANAGER (object), + result, + &error)) + g_simple_async_result_set_op_res_gboolean (simple, TRUE); + else { + g_dbus_error_strip_remote_error (error); + g_simple_async_result_take_error (simple, error); + } + g_simple_async_result_complete (simple); +} + +void +nm_manager_checkpoint_adjust_rollback_timeout (NMManager *manager, + const char *checkpoint_path, + guint32 add_timeout, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *simple; + + g_return_if_fail (NM_IS_MANAGER (manager)); + g_return_if_fail (checkpoint_path && checkpoint_path[0] == '/'); + + simple = g_simple_async_result_new (G_OBJECT (manager), callback, user_data, + nm_manager_checkpoint_adjust_rollback_timeout); + if (cancellable) + g_simple_async_result_set_check_cancellable (simple, cancellable); + + nmdbus_manager_call_checkpoint_adjust_rollback_timeout (NM_MANAGER_GET_PRIVATE (manager)->proxy, + checkpoint_path, + add_timeout, + cancellable, + checkpoint_adjust_rollback_timeout_cb, + simple); +} + +gboolean +nm_manager_checkpoint_adjust_rollback_timeout_finish (NMManager *manager, + GAsyncResult *result, + GError **error) +{ + GSimpleAsyncResult *simple; + + g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (manager), + nm_manager_checkpoint_adjust_rollback_timeout), + FALSE); + + simple = G_SIMPLE_ASYNC_RESULT (result); + return !g_simple_async_result_propagate_error (simple, error); +} + /*****************************************************************************/ static void |