File bsc#1171372-0001-Refactor-libstonithd-functionize-fudging-metadata-of.patch of Package pacemaker.26927
From 5390c9147e6afdfc3d3a4e5aedf705284e426b13 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Wed, 15 Apr 2020 17:19:32 +0200
Subject: [PATCH 1/2] Refactor: libstonithd: functionize fudging metadata of
RHCS-style agent to make specific parameter non-required
The parameter `port` of RHCS-style fence-agents is fudged to be shown as
`required="0"` in the metadata output by `stonith_admin --metadata` or
`crm_resource --show-metadata`. So that users know they don't have to
configure it. Pacemaker handles and passes the parameter to the agent
when executing it.
---
lib/fencing/st_client.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
Index: pacemaker-1.1.18+20180430.b12c320f5/lib/fencing/st_client.c
===================================================================
--- pacemaker-1.1.18+20180430.b12c320f5.orig/lib/fencing/st_client.c
+++ pacemaker-1.1.18+20180430.b12c320f5/lib/fencing/st_client.c
@@ -1138,6 +1138,28 @@ stonith_plugin(int priority, const char
}
#endif
+static void
+stonith_rhcs_parameter_not_required(xmlNode *metadata, const char *parameter)
+{
+ char *xpath = NULL;
+ xmlXPathObject *xpathObj = NULL;
+
+ CRM_CHECK(metadata != NULL, return);
+ CRM_CHECK(parameter != NULL, return);
+
+ xpath = crm_strdup_printf("//parameter[@name='%s']", parameter);
+ /* Fudge metadata so that the parameter isn't required in config
+ * Pacemaker handles and adds it */
+ xpathObj = xpath_search(metadata, xpath);
+ if (numXpathResults(xpathObj) > 0) {
+ xmlNode *tmp = getXpathResult(xpathObj, 0);
+
+ crm_xml_add(tmp, "required", "0");
+ }
+ freeXpathObject(xpathObj);
+ free(xpath);
+}
+
static int
stonith_api_device_metadata(stonith_t * stonith, int call_options, const char *agent,
const char *namespace, char **output, int timeout)
@@ -1198,15 +1220,7 @@ stonith_api_device_metadata(stonith_t *
freeXpathObject(xpathObj);
/* Now fudge the metadata so that the port isn't required in the configuration */
- xpathObj = xpath_search(xml, "//parameter[@name='port']");
- if (numXpathResults(xpathObj) > 0) {
- /* We'll fill this in */
- xmlNode *tmp = getXpathResult(xpathObj, 0);
-
- crm_xml_add(tmp, "required", "0");
- }
-
- freeXpathObject(xpathObj);
+ stonith_rhcs_parameter_not_required(xml, "port");
free(buffer);
buffer = dump_xml_formatted_with_text(xml);
free_xml(xml);