Skip to content

Commit

Permalink
High: Stonith: Implement a manual override for when nodes are known t…
Browse files Browse the repository at this point in the history
…o be safely off
  • Loading branch information
beekhof committed Oct 13, 2011
1 parent c3af486 commit 1467aef
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
26 changes: 25 additions & 1 deletion fencing/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions include/crm/stonith-ng.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
20 changes: 6 additions & 14 deletions lib/fencing/st_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1467aef

Please sign in to comment.