Blame SOURCES/bz996576-pcmk-observe_pcmk_host_list_during_automatic_unfencing.patch

ed0026
commit dde47a0eca301ca97dbe03fc9a1f6328e3b127a3
ed0026
Author: Andrew Beekhof <andrew@beekhof.net>
ed0026
Date:   Mon Sep 23 09:23:45 2013 +1000
ed0026
ed0026
    Fix: Fencing: Observe pcmk_host_list during automatic unfencing
ed0026
ed0026
diff --git a/fencing/commands.c b/fencing/commands.c
ed0026
index 73a7fc1..7d04952 100644
ed0026
--- a/fencing/commands.c
ed0026
+++ b/fencing/commands.c
ed0026
@@ -665,7 +665,7 @@ schedule_internal_command(const char *origin,
ed0026
     schedule_stonith_command(cmd, device);
ed0026
 }
ed0026
 
ed0026
-static gboolean
ed0026
+gboolean
ed0026
 string_in_list(GListPtr list, const char *item)
ed0026
 {
ed0026
     int lpc = 0;
ed0026
diff --git a/fencing/internal.h b/fencing/internal.h
ed0026
index 9a8b096..11a8c58 100644
ed0026
--- a/fencing/internal.h
ed0026
+++ b/fencing/internal.h
ed0026
@@ -164,6 +164,8 @@ int stonith_manual_ack(xmlNode * msg, remote_fencing_op_t * op);
ed0026
 
ed0026
 void unfence_cb(GPid pid, int rc, const char *output, gpointer user_data);
ed0026
 
ed0026
+gboolean string_in_list(GListPtr list, const char *item);
ed0026
+
ed0026
 void
ed0026
 schedule_internal_command(const char *origin,
ed0026
                           stonith_device_t * device,
ed0026
diff --git a/fencing/main.c b/fencing/main.c
ed0026
index 6401f2f..a90c43b 100644
ed0026
--- a/fencing/main.c
ed0026
+++ b/fencing/main.c
ed0026
@@ -669,12 +669,24 @@ static void cib_device_update(resource_t *rsc, pe_working_set_t *data_set)
ed0026
         if(have_fence_scsi == FALSE && safe_str_eq(agent, "fence_scsi")) {
ed0026
             stonith_device_t *device = g_hash_table_lookup(device_list, rsc->id);
ed0026
 
ed0026
-            if(device) {
ed0026
-                have_fence_scsi = TRUE;
ed0026
-                crm_notice("Unfencing ourselves with %s (%s)", agent, device->id);
ed0026
-                schedule_internal_command(__FUNCTION__, device, "on", stonith_our_uname, 0, NULL, unfence_cb);
ed0026
+            if(stonith_our_uname == NULL) {
ed0026
+                crm_trace("Cannot unfence ourselves: no local host name");
ed0026
+
ed0026
+            } else if(device == NULL) {
ed0026
+                crm_err("Cannot unfence ourselves: no such device '%s'", rsc->id);
ed0026
+
ed0026
             } else {
ed0026
-                crm_err("Device %s does not exist", rsc->id);
ed0026
+                const char *alias = g_hash_table_lookup(device->aliases, stonith_our_uname);
ed0026
+
ed0026
+                if (!alias) {
ed0026
+                    alias = stonith_our_uname;
ed0026
+                }
ed0026
+
ed0026
+                if (device->targets && string_in_list(device->targets, alias)) {
ed0026
+                    have_fence_scsi = TRUE;
ed0026
+                    crm_notice("Unfencing ourselves with %s (%s)", agent, device->id);
ed0026
+                    schedule_internal_command(__FUNCTION__, device, "on", stonith_our_uname, 0, NULL, unfence_cb);
ed0026
+                }
ed0026
             }
ed0026
         }
ed0026