static TransitionStatus activate_new_mappings(GPtrArray *activation_array, GPtrArray *union_array, GPtrArray *target_array, GPtrArray *old_activation_mappings, const gboolean no_rollback, const gboolean dry_run) { map_activation_mapping_function map_activation_mapping; g_print("[coordinator]: Executing activation of services:\n"); if(dry_run) map_activation_mapping = dry_run_activate_mapping; else map_activation_mapping = activate_mapping; if(traverse_activation_mappings(activation_array, union_array, target_array, traverse_inter_dependency_mappings, map_activation_mapping, complete_activation) && !interrupted) return TRANSITION_SUCCESS; else { if(interrupted) g_printerr("[coordinator]: The activation has been interrupted, reverting back to the old state...\n"); if(no_rollback) { g_printerr("[coordinator]: Activation failed, but not doing a rollback as it has been\n"); g_printerr("disabled! Please manually diagnose the errors!\n"); return TRANSITION_FAILED; } else { /* If the activation fails, perform a rollback */ g_printerr("[coordinator]: Activation failed! Doing a rollback...\n"); /* Roll back the new mappings */ if(!rollback_new_mappings(activation_array, union_array, target_array, dry_run)) { g_printerr("[coordinator]: Rollback failed!\n\n"); return TRANSITION_ROLLBACK_FAILED; // If the rollback failed, stop and notify the user to take manual action } if(old_activation_mappings == NULL) return TRANSITION_FAILED; else { /* If the new mappings have been rolled backed, roll back to the old mappings */ if(rollback_to_old_mappings(union_array, old_activation_mappings, target_array, dry_run)) return TRANSITION_FAILED; else return TRANSITION_ROLLBACK_FAILED; } } } }
static int activate_new_mappings(GPtrArray *activation_array, GPtrArray *union_array, GPtrArray *target_array, GPtrArray *old_activation_mappings, const gboolean dry_run) { g_print("[coordinator]: Executing activation of services:\n"); if(iterate_over_activation_or_deactivation_mappings(TRUE, activation_array, union_array, target_array, dry_run)) return 0; else { /* If the activation fails, perform a rollback */ g_printerr("[coordinator]: Activation failed! Doing a rollback...\n"); rollback_new_mappings(activation_array, union_array, target_array, dry_run); if(old_activation_mappings != NULL) rollback_to_old_mappings(union_array, old_activation_mappings, target_array, dry_run); return 1; } }