@@ -27,8 +27,134 @@ time_t_string(time_t when) {
2727 return buf ;
2828}
2929
30- static int
31- last_fenced_html (pcmk__output_t * out , va_list args ) {
30+ int
31+ stonith__failed_history (pcmk__output_t * out , va_list args ) {
32+ stonith_history_t * history = va_arg (args , stonith_history_t * );
33+ gboolean full_history = va_arg (args , gboolean );
34+ gboolean print_spacer = va_arg (args , gboolean );
35+
36+ int rc = pcmk_rc_no_output ;
37+
38+ for (stonith_history_t * hp = history ; hp ; hp = hp -> next ) {
39+ if (hp -> state != st_failed ) {
40+ continue ;
41+ }
42+
43+ if (rc == pcmk_rc_no_output ) {
44+ if (print_spacer ) {
45+ out -> info (out , "%s" , "" );
46+ }
47+
48+ rc = pcmk_rc_ok ;
49+ out -> begin_list (out , NULL , NULL , "Failed Fencing Actions" );
50+ }
51+
52+ out -> message (out , "stonith-event" , hp , full_history , stonith__later_succeeded (hp , history ));
53+ out -> increment_list (out );
54+ }
55+
56+ if (rc == pcmk_rc_ok ) {
57+ out -> end_list (out );
58+ }
59+
60+ return rc ;
61+ }
62+
63+ int
64+ stonith__history (pcmk__output_t * out , va_list args ) {
65+ stonith_history_t * history = va_arg (args , stonith_history_t * );
66+ gboolean full_history = va_arg (args , gboolean );
67+ gboolean print_spacer = va_arg (args , gboolean );
68+
69+ int rc = pcmk_rc_no_output ;
70+
71+ for (stonith_history_t * hp = history ; hp ; hp = hp -> next ) {
72+ if (hp -> state != st_failed ) {
73+ /* Print the header the first time we have an event to print out to
74+ * prevent printing headers with empty sections underneath.
75+ */
76+ if (rc == pcmk_rc_no_output ) {
77+ /* Add a blank line between this section and the one before it. */
78+ if (print_spacer ) {
79+ out -> info (out , "%s" , "" );
80+ }
81+
82+ rc = pcmk_rc_ok ;
83+ out -> begin_list (out , NULL , NULL , "Fencing History" );
84+ }
85+
86+ out -> message (out , "stonith-event" , hp , full_history , stonith__later_succeeded (hp , history ));
87+ out -> increment_list (out );
88+ }
89+ }
90+
91+ if (rc == pcmk_rc_ok ) {
92+ out -> end_list (out );
93+ }
94+
95+ return rc ;
96+ }
97+
98+ int
99+ stonith__full_history (pcmk__output_t * out , va_list args ) {
100+ crm_exit_t history_rc G_GNUC_UNUSED = va_arg (args , crm_exit_t );
101+ stonith_history_t * history = va_arg (args , stonith_history_t * );
102+ gboolean full_history = va_arg (args , gboolean );
103+ gboolean print_spacer = va_arg (args , gboolean );
104+
105+ int rc = pcmk_rc_no_output ;
106+
107+ for (stonith_history_t * hp = history ; hp ; hp = hp -> next ) {
108+ if (rc == pcmk_rc_no_output ) {
109+ /* Add a blank line between this section and the one before it. */
110+ if (print_spacer ) {
111+ out -> info (out , "%s" , "" );
112+ }
113+
114+ rc = pcmk_rc_ok ;
115+ out -> begin_list (out , NULL , NULL , "Fencing History" );
116+ }
117+
118+ out -> message (out , "stonith-event" , hp , full_history , stonith__later_succeeded (hp , history ));
119+ out -> increment_list (out );
120+ }
121+
122+ if (rc == pcmk_rc_ok ) {
123+ out -> end_list (out );
124+ }
125+
126+ return rc ;
127+ }
128+
129+ int
130+ stonith__full_history_xml (pcmk__output_t * out , va_list args ) {
131+ crm_exit_t history_rc = va_arg (args , crm_exit_t );
132+ stonith_history_t * history = va_arg (args , stonith_history_t * );
133+ gboolean full_history = va_arg (args , gboolean );
134+ gboolean print_spacer G_GNUC_UNUSED = va_arg (args , gboolean );
135+
136+ if (history_rc == 0 ) {
137+ out -> begin_list (out , NULL , NULL , "Fencing History" );
138+
139+ for (stonith_history_t * hp = history ; hp ; hp = hp -> next ) {
140+ out -> message (out , "stonith-event" , hp , full_history , stonith__later_succeeded (hp , history ));
141+ out -> increment_list (out );
142+ }
143+
144+ out -> end_list (out );
145+ } else {
146+ xmlNodePtr node = pcmk__output_create_xml_node (out , "fence_history" );
147+ char * rc_s = crm_itoa (history_rc );
148+
149+ xmlSetProp (node , (pcmkXmlStr ) "status" , (pcmkXmlStr ) rc_s );
150+ free (rc_s );
151+ }
152+
153+ return pcmk_rc_ok ;
154+ }
155+
156+ int
157+ stonith__last_fenced_html (pcmk__output_t * out , va_list args ) {
32158 const char * target = va_arg (args , const char * );
33159 time_t when = va_arg (args , time_t );
34160
@@ -42,8 +168,8 @@ last_fenced_html(pcmk__output_t *out, va_list args) {
42168 }
43169}
44170
45- static int
46- last_fenced_text (pcmk__output_t * out , va_list args ) {
171+ int
172+ stonith__last_fenced_text (pcmk__output_t * out , va_list args ) {
47173 const char * target = va_arg (args , const char * );
48174 time_t when = va_arg (args , time_t );
49175
@@ -56,8 +182,8 @@ last_fenced_text(pcmk__output_t *out, va_list args) {
56182 return pcmk_rc_ok ;
57183}
58184
59- static int
60- last_fenced_xml (pcmk__output_t * out , va_list args ) {
185+ int
186+ stonith__last_fenced_xml (pcmk__output_t * out , va_list args ) {
61187 const char * target = va_arg (args , const char * );
62188 time_t when = va_arg (args , time_t );
63189
@@ -75,8 +201,42 @@ last_fenced_xml(pcmk__output_t *out, va_list args) {
75201 }
76202}
77203
78- static int
79- stonith_event_html (pcmk__output_t * out , va_list args ) {
204+ int
205+ stonith__pending_actions (pcmk__output_t * out , va_list args ) {
206+ stonith_history_t * history = va_arg (args , stonith_history_t * );
207+ gboolean full_history = va_arg (args , gboolean );
208+ gboolean print_spacer = va_arg (args , gboolean );
209+
210+ int rc = pcmk_rc_no_output ;
211+
212+ for (stonith_history_t * hp = history ; hp ; hp = hp -> next ) {
213+ /* Skip the rest of the history after we see a failed/done action */
214+ if ((hp -> state == st_failed ) || (hp -> state == st_done )) {
215+ break ;
216+ }
217+
218+ if (rc == pcmk_rc_no_output ) {
219+ if (print_spacer ) {
220+ out -> info (out , "%s" , "" );
221+ }
222+
223+ rc = pcmk_rc_ok ;
224+ out -> begin_list (out , NULL , NULL , "Pending Fencing Actions" );
225+ }
226+
227+ out -> message (out , "stonith-event" , hp , full_history , stonith__later_succeeded (hp , history ));
228+ out -> increment_list (out );
229+ }
230+
231+ if (rc == pcmk_rc_ok ) {
232+ out -> end_list (out );
233+ }
234+
235+ return rc ;
236+ }
237+
238+ int
239+ stonith__event_html (pcmk__output_t * out , va_list args ) {
80240 stonith_history_t * event = va_arg (args , stonith_history_t * );
81241 gboolean full_history = va_arg (args , gboolean );
82242 gboolean later_succeeded = va_arg (args , gboolean );
@@ -122,8 +282,8 @@ stonith_event_html(pcmk__output_t *out, va_list args) {
122282 return pcmk_rc_ok ;
123283}
124284
125- static int
126- stonith_event_text (pcmk__output_t * out , va_list args ) {
285+ int
286+ stonith__event_text (pcmk__output_t * out , va_list args ) {
127287 stonith_history_t * event = va_arg (args , stonith_history_t * );
128288 gboolean full_history = va_arg (args , gboolean );
129289 gboolean later_succeeded = va_arg (args , gboolean );
@@ -159,8 +319,8 @@ stonith_event_text(pcmk__output_t *out, va_list args) {
159319 return pcmk_rc_ok ;
160320}
161321
162- static int
163- stonith_event_xml (pcmk__output_t * out , va_list args ) {
322+ int
323+ stonith__event_xml (pcmk__output_t * out , va_list args ) {
164324 xmlNodePtr node = pcmk__output_create_xml_node (out , "fence_event" );
165325 stonith_history_t * event = va_arg (args , stonith_history_t * );
166326 gboolean full_history G_GNUC_UNUSED = va_arg (args , gboolean );
@@ -204,8 +364,8 @@ stonith_event_xml(pcmk__output_t *out, va_list args) {
204364 return pcmk_rc_ok ;
205365}
206366
207- static int
208- validate_agent_html (pcmk__output_t * out , va_list args ) {
367+ int
368+ stonith__validate_agent_html (pcmk__output_t * out , va_list args ) {
209369 const char * agent = va_arg (args , const char * );
210370 const char * device = va_arg (args , const char * );
211371 char * output = va_arg (args , char * );
@@ -228,8 +388,8 @@ validate_agent_html(pcmk__output_t *out, va_list args) {
228388 return rc ;
229389}
230390
231- static int
232- validate_agent_text (pcmk__output_t * out , va_list args ) {
391+ int
392+ stonith__validate_agent_text (pcmk__output_t * out , va_list args ) {
233393 const char * agent = va_arg (args , const char * );
234394 const char * device = va_arg (args , const char * );
235395 char * output = va_arg (args , char * );
@@ -255,8 +415,8 @@ validate_agent_text(pcmk__output_t *out, va_list args) {
255415 return rc ;
256416}
257417
258- static int
259- validate_agent_xml (pcmk__output_t * out , va_list args ) {
418+ int
419+ stonith__validate_agent_xml (pcmk__output_t * out , va_list args ) {
260420 xmlNodePtr node = pcmk__output_create_xml_node (out , "validate" );
261421
262422 const char * agent = va_arg (args , const char * );
@@ -279,15 +439,34 @@ validate_agent_xml(pcmk__output_t *out, va_list args) {
279439}
280440
281441static pcmk__message_entry_t fmt_functions [] = {
282- { "last-fenced" , "html" , last_fenced_html },
283- { "last-fenced" , "text" , last_fenced_text },
284- { "last-fenced" , "xml" , last_fenced_xml },
285- { "stonith-event" , "html" , stonith_event_html },
286- { "stonith-event" , "text" , stonith_event_text },
287- { "stonith-event" , "xml" , stonith_event_xml },
288- { "validate" , "html" , validate_agent_html },
289- { "validate" , "text" , validate_agent_text },
290- { "validate" , "xml" , validate_agent_xml },
442+ { "failed-fencing-history" , "html" , stonith__failed_history },
443+ { "failed-fencing-history" , "log" , stonith__failed_history },
444+ { "failed-fencing-history" , "text" , stonith__failed_history },
445+ { "failed-fencing-history" , "xml" , stonith__failed_history },
446+ { "fencing-history" , "html" , stonith__history },
447+ { "fencing-history" , "log" , stonith__history },
448+ { "fencing-history" , "text" , stonith__history },
449+ { "fencing-history" , "xml" , stonith__history },
450+ { "full-fencing-history" , "html" , stonith__full_history },
451+ { "full-fencing-history" , "log" , stonith__full_history },
452+ { "full-fencing-history" , "text" , stonith__full_history },
453+ { "full-fencing-history" , "xml" , stonith__full_history_xml },
454+ { "last-fenced" , "html" , stonith__last_fenced_html },
455+ { "last-fenced" , "log" , stonith__last_fenced_text },
456+ { "last-fenced" , "text" , stonith__last_fenced_text },
457+ { "last-fenced" , "xml" , stonith__last_fenced_xml },
458+ { "pending-fencing-actions" , "html" , stonith__pending_actions },
459+ { "pending-fencing-actions" , "log" , stonith__pending_actions },
460+ { "pending-fencing-actions" , "text" , stonith__pending_actions },
461+ { "pending-fencing-actions" , "xml" , stonith__pending_actions },
462+ { "stonith-event" , "html" , stonith__event_html },
463+ { "stonith-event" , "log" , stonith__event_text },
464+ { "stonith-event" , "text" , stonith__event_text },
465+ { "stonith-event" , "xml" , stonith__event_xml },
466+ { "validate" , "html" , stonith__validate_agent_html },
467+ { "validate" , "log" , stonith__validate_agent_text },
468+ { "validate" , "text" , stonith__validate_agent_text },
469+ { "validate" , "xml" , stonith__validate_agent_xml },
291470
292471 { NULL , NULL , NULL }
293472};
0 commit comments