int clean_snapshots(gchar *interface, const gchar *target_property, gchar *infrastructure_expr, int keep, gchar *container, gchar *component) { /* Retrieve an array of all target machines from the infrastructure expression */ GPtrArray *target_array = create_target_array(infrastructure_expr); if(target_array == NULL) { g_printerr("[coordinator]: Error retrieving targets from infrastructure model!\n"); return 1; } else { /* Iterate over all targets and run clean snapshots operation in parallel */ int success; CleanSnapshotsData data = { keep, container, component }; ProcReact_PidIterator iterator = create_target_pid_iterator(target_array, target_property, interface, clean_snapshots_on_target, complete_clean_snapshots_on_target, &data); procreact_fork_in_parallel_and_wait(&iterator); success = target_iterator_has_succeeded(iterator.data); /* Cleanup */ destroy_target_pid_iterator(&iterator); delete_target_array(target_array); /* Return the exit status, which is 0 if everything succeeds */ return (!success); } }
int query_installed(gchar *interface, const gchar *target_property, gchar *infrastructure_expr, gchar *profile, OutputFormat format) { /* Retrieve an array of all target machines from the infrastructure expression */ GPtrArray *target_array = create_target_array(infrastructure_expr); if(target_array == NULL) { g_printerr("[coordinator]: Error retrieving targets from infrastructure model!\n"); return 1; } else { int success; /* Iterate over targets and capture their installed services */ GPtrArray *profile_manifest_target_array = g_ptr_array_new(); QueryInstalledServicesData data = { profile, profile_manifest_target_array }; ProcReact_FutureIterator iterator = create_target_future_iterator(target_array, target_property, interface, query_installed_services_on_target, complete_query_installed_services_on_target, &data); procreact_fork_in_parallel_buffer_and_wait(&iterator); success = target_iterator_has_succeeded(iterator.data); /* Print the captured configurations */ print_installed_services(&data, format); /* Cleanup */ destroy_target_future_iterator(&iterator); delete_profile_manifest_target_array(profile_manifest_target_array); delete_target_array(target_array); /* Return exit status */ return (!success); } }
static int send_snapshots(GPtrArray *snapshots_array, GPtrArray *target_array, const unsigned int max_concurrent_transfers, const int all) { int success; SendSnapshotsData data = { snapshots_array, all }; ProcReact_PidIterator iterator = create_target_iterator(target_array, send_snapshots_to_target, complete_send_snapshots_to_target, &data); procreact_fork_and_wait_in_parallel_limit(&iterator, max_concurrent_transfers); success = target_iterator_has_succeeded(&iterator); destroy_target_iterator(&iterator); return success; }