{= # # # run_schedule_exec.cfv (is called from run_schedule_start.cfv) # # include "templates.util.base_util"; include "templates.util.rbac.rbac_util"; # include "templates.util.alert.save_alert_message"; debug_message("\n\n#### run_schedule_exec.cfv START \n"); string session_id = volatile.session_id; bool is_root_admin = get_is_root_admin(); string page_token = volatile.page_token; # # Check RBAC permissions # if ((is_root_admin or get_admin_feature_permission(session_id, "scheduler", "view")) and get_is_valid_page_token(session_id, "scheduler", page_token)) then ( string run_id = volatile.run_id; node session_schedule_run = "sessions_cache." . session_id . ".scheduler_run_now." . run_id; node the_schedule = session_schedule_run{"schedule"}; debug_message("#### the_schedule:\n" . node_as_string(the_schedule) . "\n"); # # # Run the schedule (Run is complete if run_task() returns!) # # node run_info = run_task(the_schedule); debug_message("#### run_schedule_exec.cfv - run_info:\n" . node_as_string(run_info) . "\n"); # # # Check for errors # # bool is_error = false; string error_message; string error_id; node tasks = subnode_by_number(run_info, 0); debug_message("#### run_schedule_exec.cfv - tasks of run_info:\n" . node_as_string(tasks) . "\n"); node item; # KHP 19/Mar/2012 # Get the new error_id instead of saving the error message by the old save_alert_message() subroutine. # In this special case the error_id has been appended to the error message by the C++ # in the format: "[error_messages node 11399378000]" # Note, a single task may return multiple errors when the task applies # to a profile pattern or all profiles. So we collect all error_id's, separated by # a comma. foreach item tasks ( if (item?{"error_message"}) then ( # error_message .= @item{"error_message"} . "\n\n"; error_message = @item{"error_message"}; if (matches_regular_expression(error_message, "\[error_messages node ([_a-zA-Z0-9]+)\]$")) then ( # debug_message("#### match braces 0: " . $0 . "\n"); # debug_message("#### match braces 1: " . $1 . "\n"); error_id .= $1 . ","; ) else ( # Missing error_id in error_message. We just use a string # which will throw a different error when reporting it. error_id .= "no_error_id_in_error_message,"; ); is_error = true; ); ); if (is_error) then ( error_id = replace_last(error_id, ",", ""); ); debug_message("#### run_schedule_exec.cfv - is_error: " . is_error . "\n"); debug_message("#### run_schedule_exec.cfv - error_id: " . error_id . "\n"); # KHP 19/Mar/2012 - disabled because error messages are saved by C++ in logs.errors.error_messages.cfg # if (is_error) then ( # # # Save the error message to file # error_id = save_alert_message(error_message, ""); # ); # # # Set node values in session_schedule_run so that run_schedule_progress.cfv # knows that run_task() completed. # # session_schedule_run . ".is_error" = is_error; session_schedule_run . ".error_id" = error_id; session_schedule_run . ".is_complete" = true; save_node(session_schedule_run); ) else ( # No permission to access this resource (URL) display_no_permission_html(); ); debug_message("\n\n#### run_schedule_exec.cfv END \n"); =}