|
|
7ebc05 |
commit 0fb13527630fd308d533110ab91b7cf00538e8da
|
|
|
7ebc05 |
Author: Andrew Beekhof <andrew@beekhof.net>
|
|
|
7ebc05 |
Date: Wed Apr 9 09:05:36 2014 +1000
|
|
|
7ebc05 |
|
|
|
7ebc05 |
Fix: fencing: Automatically switch from 'list' to 'status' to 'static-list' if those actions are not advertised in the metadata
|
|
|
7ebc05 |
|
|
|
7ebc05 |
(cherry picked from commit b87c249c7b862f6bac424e5d0bb5528e8f7b9c94)
|
|
|
7ebc05 |
|
|
|
7ebc05 |
diff --git a/fencing/commands.c b/fencing/commands.c
|
|
|
7ebc05 |
index 909dc24..14933a5 100644
|
|
|
7ebc05 |
--- a/fencing/commands.c
|
|
|
7ebc05 |
+++ b/fencing/commands.c
|
|
|
7ebc05 |
@@ -524,24 +524,24 @@ is_nodeid_required(xmlNode * xml)
|
|
|
7ebc05 |
return TRUE;
|
|
|
7ebc05 |
}
|
|
|
7ebc05 |
|
|
|
7ebc05 |
-static char *
|
|
|
7ebc05 |
-get_on_target_actions(xmlNode * xml)
|
|
|
7ebc05 |
+static void
|
|
|
7ebc05 |
+get_on_target_actions(stonith_device_t *device)
|
|
|
7ebc05 |
{
|
|
|
7ebc05 |
char *actions = NULL;
|
|
|
7ebc05 |
xmlXPathObjectPtr xpath = NULL;
|
|
|
7ebc05 |
int max = 0;
|
|
|
7ebc05 |
int lpc = 0;
|
|
|
7ebc05 |
|
|
|
7ebc05 |
- if (!xml) {
|
|
|
7ebc05 |
- return NULL;
|
|
|
7ebc05 |
+ if (device->agent_metadata == NULL) {
|
|
|
7ebc05 |
+ return;
|
|
|
7ebc05 |
}
|
|
|
7ebc05 |
|
|
|
7ebc05 |
- xpath = xpath_search(xml, "//action");
|
|
|
7ebc05 |
+ xpath = xpath_search(device->agent_metadata, "//action");
|
|
|
7ebc05 |
max = numXpathResults(xpath);
|
|
|
7ebc05 |
|
|
|
7ebc05 |
if (max <= 0) {
|
|
|
7ebc05 |
freeXpathObject(xpath);
|
|
|
7ebc05 |
- return NULL;
|
|
|
7ebc05 |
+ return;
|
|
|
7ebc05 |
}
|
|
|
7ebc05 |
|
|
|
7ebc05 |
actions = calloc(1, 512);
|
|
|
7ebc05 |
@@ -556,6 +556,12 @@ get_on_target_actions(xmlNode * xml)
|
|
|
7ebc05 |
on_target = crm_element_value(match, "on_target");
|
|
|
7ebc05 |
action = crm_element_value(match, "name");
|
|
|
7ebc05 |
|
|
|
7ebc05 |
+ if(safe_str_eq(action, "list")) {
|
|
|
7ebc05 |
+ set_bit(device->flags, st_device_supports_list);
|
|
|
7ebc05 |
+ } else if(safe_str_eq(action, "status")) {
|
|
|
7ebc05 |
+ set_bit(device->flags, st_device_supports_status);
|
|
|
7ebc05 |
+ }
|
|
|
7ebc05 |
+
|
|
|
7ebc05 |
if (action && crm_is_true(on_target)) {
|
|
|
7ebc05 |
if (strlen(actions)) {
|
|
|
7ebc05 |
g_strlcat(actions, " ", 512);
|
|
|
7ebc05 |
@@ -571,7 +577,7 @@ get_on_target_actions(xmlNode * xml)
|
|
|
7ebc05 |
actions = NULL;
|
|
|
7ebc05 |
}
|
|
|
7ebc05 |
|
|
|
7ebc05 |
- return actions;
|
|
|
7ebc05 |
+ device->on_target_actions = actions;
|
|
|
7ebc05 |
}
|
|
|
7ebc05 |
|
|
|
7ebc05 |
static stonith_device_t *
|
|
|
7ebc05 |
@@ -596,7 +602,7 @@ build_device_from_xml(xmlNode * msg)
|
|
|
7ebc05 |
device->aliases = build_port_aliases(value, &(device->targets));
|
|
|
7ebc05 |
|
|
|
7ebc05 |
device->agent_metadata = get_agent_metadata(device->agent);
|
|
|
7ebc05 |
- device->on_target_actions = get_on_target_actions(device->agent_metadata);
|
|
|
7ebc05 |
+ get_on_target_actions(device);
|
|
|
7ebc05 |
|
|
|
7ebc05 |
value = g_hash_table_lookup(device->params, "nodeid");
|
|
|
7ebc05 |
if (!value) {
|
|
|
7ebc05 |
@@ -627,8 +633,12 @@ target_list_type(stonith_device_t * dev)
|
|
|
7ebc05 |
check_type = "static-list";
|
|
|
7ebc05 |
} else if (g_hash_table_lookup(dev->params, STONITH_ATTR_HOSTMAP)) {
|
|
|
7ebc05 |
check_type = "static-list";
|
|
|
7ebc05 |
- } else {
|
|
|
7ebc05 |
+ } else if(is_set(dev->flags, st_device_supports_list)){
|
|
|
7ebc05 |
check_type = "dynamic-list";
|
|
|
7ebc05 |
+ } else if(is_set(dev->flags, st_device_supports_status)){
|
|
|
7ebc05 |
+ check_type = "status";
|
|
|
7ebc05 |
+ } else {
|
|
|
7ebc05 |
+ check_type = "none";
|
|
|
7ebc05 |
}
|
|
|
7ebc05 |
}
|
|
|
7ebc05 |
|
|
|
7ebc05 |
diff --git a/fencing/internal.h b/fencing/internal.h
|
|
|
7ebc05 |
index da510c3..4e0525c 100644
|
|
|
7ebc05 |
--- a/fencing/internal.h
|
|
|
7ebc05 |
+++ b/fencing/internal.h
|
|
|
7ebc05 |
@@ -12,6 +12,12 @@
|
|
|
7ebc05 |
*/
|
|
|
7ebc05 |
gboolean stonith_check_fence_tolerance(int tolerance, const char *target, const char *action);
|
|
|
7ebc05 |
|
|
|
7ebc05 |
+enum st_device_flags
|
|
|
7ebc05 |
+{
|
|
|
7ebc05 |
+ st_device_supports_list = 0x0001,
|
|
|
7ebc05 |
+ st_device_supports_status = 0x0002,
|
|
|
7ebc05 |
+};
|
|
|
7ebc05 |
+
|
|
|
7ebc05 |
typedef struct stonith_device_s {
|
|
|
7ebc05 |
char *id;
|
|
|
7ebc05 |
char *agent;
|
|
|
7ebc05 |
@@ -27,6 +33,8 @@ typedef struct stonith_device_s {
|
|
|
7ebc05 |
guint priority;
|
|
|
7ebc05 |
guint active_pid;
|
|
|
7ebc05 |
|
|
|
7ebc05 |
+ enum st_device_flags flags;
|
|
|
7ebc05 |
+
|
|
|
7ebc05 |
GHashTable *params;
|
|
|
7ebc05 |
GHashTable *aliases;
|
|
|
7ebc05 |
GList *pending_ops;
|