Blame SOURCES/018-crm_node-ra.patch

eae27e
From e0eb9e766dc3dd296e7a5e623bf7b10ebcdb33f7 Mon Sep 17 00:00:00 2001
eae27e
From: Ken Gaillot <kgaillot@redhat.com>
eae27e
Date: Mon, 6 Feb 2017 13:54:50 -0600
eae27e
Subject: [PATCH] Fix: libcrmcommon,pengine,tools: pass local node name to
eae27e
 resource agents
eae27e
eae27e
Preivously, crm_node -n would show the local uname on remote nodes, even when
eae27e
the node name known to the cluster was different. Now, the policy engine adds
eae27e
environment variables with the local node name and UUID before calling the
eae27e
resource agent. If crm_node detects these variables, it will use them instead
eae27e
of uname.
eae27e
eae27e
This only affects crm_node behavior when called via the cluster, not
eae27e
directly from the command line.
eae27e
eae27e
Based on patch originally provided by Andrew Beekhof <andrew@beekhof.net>
eae27e
---
eae27e
 lib/common/utils.c | 2 ++
eae27e
 pengine/graph.c    | 3 +++
eae27e
 tools/crm_node.c   | 6 +++++-
eae27e
 3 files changed, 10 insertions(+), 1 deletion(-)
eae27e
eae27e
diff --git a/lib/common/utils.c b/lib/common/utils.c
eae27e
index 83072c5..3e3abd3 100644
eae27e
--- a/lib/common/utils.c
eae27e
+++ b/lib/common/utils.c
eae27e
@@ -894,6 +894,8 @@ filter_action_parameters(xmlNode * param_set, const char *version)
eae27e
         XML_ATTR_ID,
eae27e
         XML_ATTR_CRM_VERSION,
eae27e
         XML_LRM_ATTR_OP_DIGEST,
eae27e
+        XML_LRM_ATTR_TARGET,
eae27e
+        XML_LRM_ATTR_TARGET_UUID,
eae27e
     };
eae27e
 
eae27e
     gboolean do_delete = FALSE;
eae27e
diff --git a/pengine/graph.c b/pengine/graph.c
eae27e
index 569cf6e..81d8355 100644
eae27e
--- a/pengine/graph.c
eae27e
+++ b/pengine/graph.c
eae27e
@@ -948,6 +948,9 @@ action2xml(action_t * action, gboolean as_input, pe_working_set_t *data_set)
eae27e
         if (router_node) {
eae27e
             crm_xml_add(action_xml, XML_LRM_ATTR_ROUTER_NODE, router_node->details->uname);
eae27e
         }
eae27e
+
eae27e
+        g_hash_table_insert(action->meta, strdup(XML_LRM_ATTR_TARGET), strdup(action->node->details->uname));
eae27e
+        g_hash_table_insert(action->meta, strdup(XML_LRM_ATTR_TARGET_UUID), strdup(action->node->details->id));
eae27e
     }
eae27e
 
eae27e
     /* No details if this action is only being listed in the inputs section */
eae27e
diff --git a/tools/crm_node.c b/tools/crm_node.c
eae27e
index d927f31..7092db4 100644
eae27e
--- a/tools/crm_node.c
eae27e
+++ b/tools/crm_node.c
eae27e
@@ -951,7 +951,11 @@ main(int argc, char **argv)
eae27e
     }
eae27e
 
eae27e
     if (command == 'n') {
eae27e
-        fprintf(stdout, "%s\n", get_local_node_name());
eae27e
+        const char *name = getenv("OCF_RESKEY_" CRM_META "_" XML_LRM_ATTR_TARGET);
eae27e
+        if(name == NULL) {
eae27e
+            name = get_local_node_name();
eae27e
+        }
eae27e
+        fprintf(stdout, "%s\n", name);
eae27e
         crm_exit(pcmk_ok);
eae27e
 
eae27e
     } else if (command == 'N') {
eae27e
-- 
eae27e
1.8.3.1
eae27e