diff --git a/fencing/commands.c b/fencing/commands.c index a3e84d7f1d1..bb1efc99656 100644 --- a/fencing/commands.c +++ b/fencing/commands.c @@ -101,6 +101,27 @@ static async_command_t *create_async_command(xmlNode *msg) return cmd; } +static int stonith_manual_ack(xmlNode *msg) +{ + struct _ProcTrack p; + async_command_t *cmd = create_async_command(msg); + xmlNode *dev = get_xpath_object("//@"F_STONITH_TARGET, msg, LOG_ERR); + + if(cmd == NULL) { + return st_err_missing; + } + + cmd->device = crm_strdup("manual_ack"); + crm_notice("Injecting manual confirmation that %s is safely down/off", + crm_element_value(dev, F_STONITH_TARGET)); + + memset(&p, 0, sizeof(struct _ProcTrack)); + p.privatedata = cmd; + + exec_child_done(&p, 0, 0, 0, FALSE); + return stonith_ok; +} + static gboolean stonith_device_execute(stonith_device_t *device) { int rc = 0; @@ -973,7 +994,10 @@ stonith_command(stonith_client_t *client, xmlNode *request, const char *remote) } else if(is_reply == FALSE && crm_str_eq(op, STONITH_OP_FENCE, TRUE)) { - if(remote || stand_alone) { + if(call_options & st_opt_manual_ack) { + rc = stonith_manual_ack(request); + + } else if(remote || stand_alone) { rc = stonith_fence(request); } else if(call_options & st_opt_local_first) { diff --git a/include/crm/stonith-ng.h b/include/crm/stonith-ng.h index e4d0f04504f..25857ebcb1f 100644 --- a/include/crm/stonith-ng.h +++ b/include/crm/stonith-ng.h @@ -33,6 +33,7 @@ enum stonith_call_options { st_opt_verbose = 0x00000001, st_opt_allow_suicide = 0x00000002, st_opt_local_first = 0x00000004, + st_opt_manual_ack = 0x00000008, st_opt_discard_reply = 0x00000010, st_opt_all_replies = 0x00000020, st_opt_scope_local = 0x00000100, diff --git a/lib/fencing/st_client.c b/lib/fencing/st_client.c index 3f773819562..cf5b1598c6e 100644 --- a/lib/fencing/st_client.c +++ b/lib/fencing/st_client.c @@ -688,20 +688,6 @@ stonith_api_device_metadata(stonith_t * stonith, int call_options, const char *a return rc; } -static int -stonith_api_confirm(stonith_t * stonith, int call_options, const char *target) -{ - int rc = 0; - xmlNode *data = NULL; - - data = create_xml_node(NULL, __FUNCTION__); - crm_xml_add(data, F_STONITH_TARGET, target); - rc = stonith_send_command(stonith, STONITH_OP_FENCE, data, NULL, call_options, 0); - free_xml(data); - - return rc; -} - static int stonith_api_query(stonith_t * stonith, int call_options, const char *target, stonith_key_value_t ** devices, int timeout) @@ -779,6 +765,12 @@ stonith_api_fence(stonith_t * stonith, int call_options, const char *node, const return rc; } +static int +stonith_api_confirm(stonith_t * stonith, int call_options, const char *target) +{ + return stonith_api_fence(stonith, call_options|st_opt_manual_ack, target, "off", 0); +} + static int stonith_api_history(stonith_t * stonith, int call_options, const char *node, stonith_history_t ** history, int timeout)