File pacemaker-pass-local-node-name-to-resource-agents.patch of Package pacemaker.14737

commit e0eb9e766dc3dd296e7a5e623bf7b10ebcdb33f7
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Mon Feb 6 13:54:50 2017 -0600

    Fix: libcrmcommon,pengine,tools: pass local node name to resource agents
    
    Preivously, crm_node -n would show the local uname on remote nodes, even when
    the node name known to the cluster was different. Now, the policy engine adds
    environment variables with the local node name and UUID before calling the
    resource agent. If crm_node detects these variables, it will use them instead
    of uname.
    
    This only affects crm_node behavior when called via the cluster, not
    directly from the command line.
    
    Based on patch originally provided by Andrew Beekhof <andrew@beekhof.net>

diff --git a/lib/common/utils.c b/lib/common/utils.c
index 83072c573..3e3abd396 100644
--- a/lib/common/utils.c
+++ b/lib/common/utils.c
@@ -894,6 +894,8 @@ filter_action_parameters(xmlNode * param_set, const char *version)
         XML_ATTR_ID,
         XML_ATTR_CRM_VERSION,
         XML_LRM_ATTR_OP_DIGEST,
+        XML_LRM_ATTR_TARGET,
+        XML_LRM_ATTR_TARGET_UUID,
     };
 
     gboolean do_delete = FALSE;
diff --git a/pengine/graph.c b/pengine/graph.c
index 569cf6eb6..81d8355a3 100644
--- a/pengine/graph.c
+++ b/pengine/graph.c
@@ -948,6 +948,9 @@ action2xml(action_t * action, gboolean as_input, pe_working_set_t *data_set)
         if (router_node) {
             crm_xml_add(action_xml, XML_LRM_ATTR_ROUTER_NODE, router_node->details->uname);
         }
+
+        g_hash_table_insert(action->meta, strdup(XML_LRM_ATTR_TARGET), strdup(action->node->details->uname));
+        g_hash_table_insert(action->meta, strdup(XML_LRM_ATTR_TARGET_UUID), strdup(action->node->details->id));
     }
 
     /* No details if this action is only being listed in the inputs section */
diff --git a/tools/crm_node.c b/tools/crm_node.c
index d927f3176..7092db430 100644
--- a/tools/crm_node.c
+++ b/tools/crm_node.c
@@ -951,7 +951,11 @@ main(int argc, char **argv)
     }
 
     if (command == 'n') {
-        fprintf(stdout, "%s\n", get_local_node_name());
+        const char *name = getenv("OCF_RESKEY_" CRM_META "_" XML_LRM_ATTR_TARGET);
+        if(name == NULL) {
+            name = get_local_node_name();
+        }
+        fprintf(stdout, "%s\n", name);
         crm_exit(pcmk_ok);
 
     } else if (command == 'N') {
openSUSE Build Service is sponsored by