Blame SOURCES/004-feature-set.patch

23c78e
From 9faa62f0701801f1d420462025e863d8ca3d6a06 Mon Sep 17 00:00:00 2001
23c78e
From: Chris Lumens <clumens@redhat.com>
23c78e
Date: Mon, 21 Sep 2020 14:19:19 -0400
23c78e
Subject: [PATCH 1/6] Fix: libcrmcommon: Automatically lower case XML list
23c78e
 names.
23c78e
23c78e
---
23c78e
 lib/common/output_xml.c | 10 ++++------
23c78e
 1 file changed, 4 insertions(+), 6 deletions(-)
23c78e
23c78e
diff --git a/lib/common/output_xml.c b/lib/common/output_xml.c
23c78e
index 1710fac..6a6ed6e 100644
23c78e
--- a/lib/common/output_xml.c
23c78e
+++ b/lib/common/output_xml.c
23c78e
@@ -50,7 +50,6 @@ typedef struct subst_s {
23c78e
 } subst_t;
23c78e
 
23c78e
 static subst_t substitutions[] = {
23c78e
-    { "Attributes",                     "attributes" },
23c78e
     { "Active Resources",               "resources" },
23c78e
     { "Full List of Resources",         "resources" },
23c78e
     { "Inactive Resources",             "resources" },
23c78e
@@ -61,8 +60,6 @@ static subst_t substitutions[] = {
23c78e
     { "Operations",                     "node_history" },
23c78e
     { "Negative Location Constraints",  "bans" },
23c78e
     { "Node Attributes",                "node_attributes" },
23c78e
-    { "Resources",                      "resources" },
23c78e
-    { "Tickets",                        "tickets" },
23c78e
 
23c78e
     { NULL, NULL }
23c78e
 };
23c78e
@@ -288,7 +285,7 @@ static void
23c78e
 xml_begin_list(pcmk__output_t *out, const char *singular_noun, const char *plural_noun,
23c78e
                const char *format, ...) {
23c78e
     va_list ap;
23c78e
-    const char *name = NULL;
23c78e
+    char *name = NULL;
23c78e
     char *buf = NULL;
23c78e
     int len;
23c78e
 
23c78e
@@ -300,14 +297,14 @@ xml_begin_list(pcmk__output_t *out, const char *singular_noun, const char *plura
23c78e
     if (substitute) {
23c78e
         for (subst_t *s = substitutions; s->from != NULL; s++) {
23c78e
             if (!strcmp(s->from, buf)) {
23c78e
-                name = s->to;
23c78e
+                name = g_strdup(s->to);
23c78e
                 break;
23c78e
             }
23c78e
         }
23c78e
     }
23c78e
 
23c78e
     if (name == NULL) {
23c78e
-        name = buf;
23c78e
+        name = g_ascii_strdown(buf, -1);
23c78e
     }
23c78e
 
23c78e
     if (legacy_xml || simple_list) {
23c78e
@@ -319,6 +316,7 @@ xml_begin_list(pcmk__output_t *out, const char *singular_noun, const char *plura
23c78e
         xmlSetProp(list_node, (pcmkXmlStr) "name", (pcmkXmlStr) name);
23c78e
     }
23c78e
 
23c78e
+    g_free(name);
23c78e
     free(buf);
23c78e
 }
23c78e
 
23c78e
-- 
23c78e
1.8.3.1
23c78e
23c78e
23c78e
From 7a77441ae8d3ab943dfafebfc06b63402be323e1 Mon Sep 17 00:00:00 2001
23c78e
From: Chris Lumens <clumens@redhat.com>
23c78e
Date: Tue, 27 Oct 2020 12:49:45 -0400
23c78e
Subject: [PATCH 2/6] Feature: xml: Move resource-related XML schema into its
23c78e
 own file.
23c78e
23c78e
This allows it to be shared between the crm_mon and crm_resource
23c78e
schemas.  Also, this adds support for resource XML to crm_mon given that
23c78e
this is now technically possible as part of the library output.
23c78e
---
23c78e
 xml/Makefile.am           |   2 +-
23c78e
 xml/api/crm_mon-2.4.rng   | 311 ++++++++++++++++++++++++++++++++++++++++++++++
23c78e
 xml/api/resources-2.4.rng | 109 ++++++++++++++++
23c78e
 3 files changed, 421 insertions(+), 1 deletion(-)
23c78e
 create mode 100644 xml/api/crm_mon-2.4.rng
23c78e
 create mode 100644 xml/api/resources-2.4.rng
23c78e
23c78e
diff --git a/xml/Makefile.am b/xml/Makefile.am
23c78e
index 892c811..79ce900 100644
23c78e
--- a/xml/Makefile.am
23c78e
+++ b/xml/Makefile.am
23c78e
@@ -51,7 +51,7 @@ API_request_base	= command-output crm_mon crmadmin stonith_admin version
23c78e
 CIB_cfg_base		= options nodes resources constraints fencing acls tags alerts
23c78e
 
23c78e
 # Names of all schemas (including top level and those included by others)
23c78e
-API_base		= $(API_request_base) fence-event item status
23c78e
+API_base		= $(API_request_base) fence-event item resources status
23c78e
 CIB_base		= cib $(CIB_cfg_base) status score rule nvset
23c78e
 
23c78e
 # Static schema files and transforms (only CIB has transforms)
23c78e
diff --git a/xml/api/crm_mon-2.4.rng b/xml/api/crm_mon-2.4.rng
23c78e
new file mode 100644
23c78e
index 0000000..88973a4
23c78e
--- /dev/null
23c78e
+++ b/xml/api/crm_mon-2.4.rng
23c78e
@@ -0,0 +1,311 @@
23c78e
+
23c78e
+
23c78e
+         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
23c78e
+
23c78e
+    <start>
23c78e
+        <ref name="element-crm-mon"/>
23c78e
+    </start>
23c78e
+
23c78e
+    <define name="element-crm-mon">
23c78e
+        <optional>
23c78e
+            <ref name="element-summary" />
23c78e
+        </optional>
23c78e
+        <optional>
23c78e
+            <ref name="nodes-list" />
23c78e
+        </optional>
23c78e
+        <optional>
23c78e
+            <ref name="resources-list" />
23c78e
+        </optional>
23c78e
+        <optional>
23c78e
+            <ref name="node-attributes-list" />
23c78e
+        </optional>
23c78e
+        <optional>
23c78e
+            <ref name="node-history-list" />
23c78e
+        </optional>
23c78e
+        <optional>
23c78e
+            <ref name="failures-list" />
23c78e
+        </optional>
23c78e
+        <optional>
23c78e
+            <ref name="fence-event-list" />
23c78e
+        </optional>
23c78e
+        <optional>
23c78e
+            <ref name="tickets-list" />
23c78e
+        </optional>
23c78e
+        <optional>
23c78e
+            <ref name="bans-list" />
23c78e
+        </optional>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-summary">
23c78e
+        <element name="summary">
23c78e
+            <optional>
23c78e
+                <element name="stack">
23c78e
+                    <attribute name="type"> <text /> </attribute>
23c78e
+                </element>
23c78e
+            </optional>
23c78e
+            <optional>
23c78e
+                <element name="current_dc">
23c78e
+                    <attribute name="present"> <data type="boolean" /> </attribute>
23c78e
+                    <optional>
23c78e
+                        <group>
23c78e
+                            <attribute name="version"> <text /> </attribute>
23c78e
+                            <attribute name="name"> <text /> </attribute>
23c78e
+                            <attribute name="id"> <text /> </attribute>
23c78e
+                            <attribute name="with_quorum"> <data type="boolean" /> </attribute>
23c78e
+                        </group>
23c78e
+                    </optional>
23c78e
+                </element>
23c78e
+            </optional>
23c78e
+            <optional>
23c78e
+                <element name="last_update">
23c78e
+                    <attribute name="time"> <text /> </attribute>
23c78e
+                </element>
23c78e
+                <element name="last_change">
23c78e
+                    <attribute name="time"> <text /> </attribute>
23c78e
+                    <attribute name="user"> <text /> </attribute>
23c78e
+                    <attribute name="client"> <text /> </attribute>
23c78e
+                    <attribute name="origin"> <text /> </attribute>
23c78e
+                </element>
23c78e
+            </optional>
23c78e
+            <optional>
23c78e
+                <element name="nodes_configured">
23c78e
+                    <attribute name="number"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+                </element>
23c78e
+                <element name="resources_configured">
23c78e
+                    <attribute name="number"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+                    <attribute name="disabled"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+                    <attribute name="blocked"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+                </element>
23c78e
+            </optional>
23c78e
+            <optional>
23c78e
+                <element name="cluster_options">
23c78e
+                    <attribute name="stonith-enabled"> <data type="boolean" /> </attribute>
23c78e
+                    <attribute name="symmetric-cluster"> <data type="boolean" /> </attribute>
23c78e
+                    <attribute name="no-quorum-policy"> <text /> </attribute>
23c78e
+                    <attribute name="maintenance-mode"> <data type="boolean" /> </attribute>
23c78e
+                    <attribute name="stop-all-resources"> <data type="boolean" /> </attribute>
23c78e
+                </element>
23c78e
+            </optional>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="resources-list">
23c78e
+        <element name="resources">
23c78e
+            <zeroOrMore>
23c78e
+                <externalRef href="resources-2.4.rng" />
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="nodes-list">
23c78e
+        <element name="nodes">
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-full-node" />
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="node-attributes-list">
23c78e
+        <element name="node_attributes">
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-node-with-attributes" />
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="node-history-list">
23c78e
+        <element name="node_history">
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-node-history" />
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="failures-list">
23c78e
+        <element name="failures">
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-failure" />
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="fence-event-list">
23c78e
+        <element name="fence_history">
23c78e
+            <optional>
23c78e
+                <attribute name="status"> <data type="integer" /> </attribute>
23c78e
+            </optional>
23c78e
+            <zeroOrMore>
23c78e
+                <externalRef href="fence-event-2.0.rng" />
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="tickets-list">
23c78e
+        <element name="tickets">
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-ticket" />
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="bans-list">
23c78e
+        <element name="bans">
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-ban" />
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-full-node">
23c78e
+        <element name="node">
23c78e
+            <attribute name="name"> <text/> </attribute>
23c78e
+            <attribute name="id"> <text/> </attribute>
23c78e
+            <attribute name="online"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="standby"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="standby_onfail"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="maintenance"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="pending"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="unclean"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="shutdown"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="expected_up"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="is_dc"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="resources_running"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+            <attribute name="type">
23c78e
+                <choice>
23c78e
+                    <value>unknown</value>
23c78e
+                    <value>member</value>
23c78e
+                    <value>remote</value>
23c78e
+                    <value>ping</value>
23c78e
+                </choice>
23c78e
+            </attribute>
23c78e
+            <optional>
23c78e
+                
23c78e
+                     "container_id" while later versions use "id_as_resource" -->
23c78e
+                <choice>
23c78e
+                    <attribute name="container_id"> <text/> </attribute>
23c78e
+                    <attribute name="id_as_resource"> <text/> </attribute>
23c78e
+                </choice>
23c78e
+            </optional>
23c78e
+            <externalRef href="resources-2.4.rng" />
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-node-with-attributes">
23c78e
+        <element name="node">
23c78e
+            <attribute name="name"> <text /> </attribute>
23c78e
+            <zeroOrMore>
23c78e
+                <element name="attribute">
23c78e
+                    <attribute name="name"> <text /> </attribute>
23c78e
+                    <attribute name="value"> <text /> </attribute>
23c78e
+                    <optional>
23c78e
+                        <attribute name="expected"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+                    </optional>
23c78e
+                </element>
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-node-history">
23c78e
+        <element name="node">
23c78e
+            <attribute name="name"> <text /> </attribute>
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-resource-history" />
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-resource-history">
23c78e
+        <element name="resource_history">
23c78e
+            <attribute name="id"> <text /> </attribute>
23c78e
+            <attribute name="orphan"> <data type="boolean" /> </attribute>
23c78e
+            <optional>
23c78e
+                <group>
23c78e
+                    <attribute name="migration-threshold"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+                    <optional>
23c78e
+                        <attribute name="fail-count"> <text /> </attribute>
23c78e
+                    </optional>
23c78e
+                    <optional>
23c78e
+                        <attribute name="last-failure"> <text /> </attribute>
23c78e
+                    </optional>
23c78e
+                </group>
23c78e
+            </optional>
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-operation-history" />
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-operation-history">
23c78e
+        <element name="operation_history">
23c78e
+            <attribute name="call"> <text /> </attribute>
23c78e
+            <attribute name="task"> <text /> </attribute>
23c78e
+            <optional>
23c78e
+                <attribute name="interval"> <text /> </attribute>
23c78e
+            </optional>
23c78e
+            <optional>
23c78e
+                <attribute name="last-rc-change"> <text /> </attribute>
23c78e
+            </optional>
23c78e
+            <optional>
23c78e
+                <attribute name="last-run"> <text /> </attribute>
23c78e
+            </optional>
23c78e
+            <optional>
23c78e
+                <attribute name="exec-time"> <text /> </attribute>
23c78e
+            </optional>
23c78e
+            <optional>
23c78e
+                <attribute name="queue-time"> <text /> </attribute>
23c78e
+            </optional>
23c78e
+            <attribute name="rc"> <data type="integer" /> </attribute>
23c78e
+            <attribute name="rc_text"> <text /> </attribute>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-failure">
23c78e
+        <element name="failure">
23c78e
+            <choice>
23c78e
+                <attribute name="op_key"> <text/> </attribute>
23c78e
+                <attribute name="id"> <text/> </attribute>
23c78e
+            </choice>
23c78e
+            <attribute name="node"> <text /> </attribute>
23c78e
+            <attribute name="exitstatus"> <text /> </attribute>
23c78e
+            <attribute name="exitreason"> <text /> </attribute>
23c78e
+            <attribute name="exitcode"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+            <attribute name="call"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+            <attribute name="status"> <text /> </attribute>
23c78e
+            <optional>
23c78e
+                <group>
23c78e
+                    <attribute name="last-rc-change"> <text /> </attribute>
23c78e
+                    <attribute name="queued"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+                    <attribute name="exec"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+                    <attribute name="interval"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+                    <attribute name="task"> <text /> </attribute>
23c78e
+                </group>
23c78e
+            </optional>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-ticket">
23c78e
+        <element name="ticket">
23c78e
+            <attribute name="id"> <text /> </attribute>
23c78e
+            <attribute name="status">
23c78e
+                <choice>
23c78e
+                    <value>granted</value>
23c78e
+                    <value>revoked</value>
23c78e
+                </choice>
23c78e
+            </attribute>
23c78e
+            <attribute name="standby"> <data type="boolean" /> </attribute>
23c78e
+            <optional>
23c78e
+                <attribute name="last-granted"> <text /> </attribute>
23c78e
+            </optional>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-ban">
23c78e
+        <element name="ban">
23c78e
+            <attribute name="id"> <text /> </attribute>
23c78e
+            <attribute name="resource"> <text /> </attribute>
23c78e
+            <attribute name="node"> <text /> </attribute>
23c78e
+            <attribute name="weight"> <data type="integer" /> </attribute>
23c78e
+            <attribute name="master_only"> <data type="boolean" /> </attribute>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+</grammar>
23c78e
diff --git a/xml/api/resources-2.4.rng b/xml/api/resources-2.4.rng
23c78e
new file mode 100644
23c78e
index 0000000..e279583
23c78e
--- /dev/null
23c78e
+++ b/xml/api/resources-2.4.rng
23c78e
@@ -0,0 +1,109 @@
23c78e
+
23c78e
+
23c78e
+         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
23c78e
+
23c78e
+    <start>
23c78e
+        <ref name="element-resource-list"/>
23c78e
+    </start>
23c78e
+
23c78e
+    <define name="element-resource-list">
23c78e
+        <interleave>
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-bundle" />
23c78e
+            </zeroOrMore>
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-clone" />
23c78e
+            </zeroOrMore>
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-group" />
23c78e
+            </zeroOrMore>
23c78e
+            <zeroOrMore>
23c78e
+                <ref name="element-resource" />
23c78e
+            </zeroOrMore>
23c78e
+        </interleave>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-bundle">
23c78e
+        <element name="bundle">
23c78e
+            <attribute name="id"> <text/> </attribute>
23c78e
+            <attribute name="type">
23c78e
+                <choice>
23c78e
+                    <value>docker</value>
23c78e
+                    <value>rkt</value>
23c78e
+                    <value>podman</value>
23c78e
+                </choice>
23c78e
+            </attribute>
23c78e
+            <attribute name="image"> <text/> </attribute>
23c78e
+            <attribute name="unique"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="managed"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="failed"> <data type="boolean" /> </attribute>
23c78e
+            <zeroOrMore>
23c78e
+                <element name="replica">
23c78e
+                    <attribute name="id"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+                    <zeroOrMore>
23c78e
+                        <ref name="element-resource" />
23c78e
+                    </zeroOrMore>
23c78e
+                </element>
23c78e
+            </zeroOrMore>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-clone">
23c78e
+        <element name="clone">
23c78e
+            <attribute name="id"> <text/> </attribute>
23c78e
+            <attribute name="multi_state"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="unique"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="managed"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="disabled"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="failed"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="failure_ignored"> <data type="boolean" /> </attribute>
23c78e
+            <optional>
23c78e
+                <attribute name="target_role"> <text/> </attribute>
23c78e
+            </optional>
23c78e
+            <ref name="element-resource-list" />
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-group">
23c78e
+        <element name="group">
23c78e
+            <attribute name="id"> <text/> </attribute>
23c78e
+            <attribute name="number_resources"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+            <attribute name="managed"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="disabled"> <data type="boolean" /> </attribute>
23c78e
+            <ref name="element-resource-list" />
23c78e
+        </element>
23c78e
+    </define>
23c78e
+
23c78e
+    <define name="element-resource">
23c78e
+        <element name="resource">
23c78e
+            <attribute name="id"> <text/> </attribute>
23c78e
+            <attribute name="resource_agent"> <text/> </attribute>
23c78e
+            <attribute name="role"> <text/> </attribute>
23c78e
+            <optional>
23c78e
+                <attribute name="target_role"> <text/> </attribute>
23c78e
+            </optional>
23c78e
+            <attribute name="active"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="orphaned"> <data type="boolean" /> </attribute>
23c78e
+            <optional>
23c78e
+                <attribute name="blocked"> <data type="boolean" /> </attribute>
23c78e
+            </optional>
23c78e
+            <attribute name="managed"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="failed"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="failure_ignored"> <data type="boolean" /> </attribute>
23c78e
+            <attribute name="nodes_running_on"> <data type="nonNegativeInteger" />  </attribute>
23c78e
+            <optional>
23c78e
+                <attribute name="pending"> <text/> </attribute>
23c78e
+            </optional>
23c78e
+            <zeroOrMore>
23c78e
+                <element name="node">
23c78e
+                    <attribute name="name"> <text/> </attribute>
23c78e
+                    <attribute name="id"> <text/> </attribute>
23c78e
+                    <attribute name="cached"> <data type="boolean" /> </attribute>
23c78e
+                </element>
23c78e
+            </zeroOrMore>
23c78e
+            <optional>
23c78e
+                <element name="xml"> <text/> </element>
23c78e
+            </optional>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+</grammar>
23c78e
-- 
23c78e
1.8.3.1
23c78e
23c78e
23c78e
From 814eb921cd429692220f33722c9bc061266bd838 Mon Sep 17 00:00:00 2001
23c78e
From: Chris Lumens <clumens@redhat.com>
23c78e
Date: Thu, 29 Oct 2020 14:45:02 -0400
23c78e
Subject: [PATCH 3/6] Feature: xml: Add a generic list XML schema file.
23c78e
23c78e
Formatted output supports a generic list structure that isn't used in
23c78e
too many places at the moment, but it could be getting used more in the
23c78e
future.  It's also really easy to have a schema for this piece of XML.
23c78e
---
23c78e
 xml/Makefile.am              |  7 ++++++-
23c78e
 xml/api/generic-list-2.4.rng | 21 +++++++++++++++++++++
23c78e
 2 files changed, 27 insertions(+), 1 deletion(-)
23c78e
 create mode 100644 xml/api/generic-list-2.4.rng
23c78e
23c78e
diff --git a/xml/Makefile.am b/xml/Makefile.am
23c78e
index 79ce900..2f99f1c 100644
23c78e
--- a/xml/Makefile.am
23c78e
+++ b/xml/Makefile.am
23c78e
@@ -44,6 +44,11 @@ version_pairs_last = $(wordlist \
23c78e
 			    ),$(1),$(2) \
23c78e
 			  )
23c78e
 
23c78e
+# NOTE: All files in API_request_base, CIB_cfg_base, API_base, and CIB_base
23c78e
+# need to start with a unique prefix.  These variables all get iterated over
23c78e
+# and globbed, and two files starting with the same prefix will cause
23c78e
+# problems.
23c78e
+
23c78e
 # Names of API schemas that form the choices for pacemaker-result content
23c78e
 API_request_base	= command-output crm_mon crmadmin stonith_admin version
23c78e
 
23c78e
@@ -51,7 +56,7 @@ API_request_base	= command-output crm_mon crmadmin stonith_admin version
23c78e
 CIB_cfg_base		= options nodes resources constraints fencing acls tags alerts
23c78e
 
23c78e
 # Names of all schemas (including top level and those included by others)
23c78e
-API_base		= $(API_request_base) fence-event item resources status
23c78e
+API_base		= $(API_request_base) fence-event generic-list item resources status
23c78e
 CIB_base		= cib $(CIB_cfg_base) status score rule nvset
23c78e
 
23c78e
 # Static schema files and transforms (only CIB has transforms)
23c78e
diff --git a/xml/api/generic-list-2.4.rng b/xml/api/generic-list-2.4.rng
23c78e
new file mode 100644
23c78e
index 0000000..fee93a9
23c78e
--- /dev/null
23c78e
+++ b/xml/api/generic-list-2.4.rng
23c78e
@@ -0,0 +1,21 @@
23c78e
+
23c78e
+
23c78e
+         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
23c78e
+
23c78e
+    <start>
23c78e
+        <ref name="generic-list"/>
23c78e
+    </start>
23c78e
+
23c78e
+    <define name="generic-list">
23c78e
+        <element name="list">
23c78e
+            <attribute name="name"> <text /> </attribute>
23c78e
+            <attribute name="count"> <data type="nonNegativeInteger" /> </attribute>
23c78e
+            <choice>
23c78e
+                <empty/>
23c78e
+                <oneOrMore>
23c78e
+                    <externalRef href="item-1.1.rng"/>
23c78e
+                </oneOrMore>
23c78e
+            </choice>
23c78e
+        </element>
23c78e
+    </define>
23c78e
+</grammar>
23c78e
-- 
23c78e
1.8.3.1
23c78e
23c78e
23c78e
From 316b6f66ca5425093503c51c2f8738922287ebca Mon Sep 17 00:00:00 2001
23c78e
From: Chris Lumens <clumens@redhat.com>
23c78e
Date: Wed, 16 Sep 2020 15:59:34 -0400
23c78e
Subject: [PATCH 4/6] Fix: tools: Save the optarg parameter for
23c78e
 --list-ocf-alternatives.
23c78e
23c78e
We need this so it can be added to the XML output of crm_resource.
23c78e
---
23c78e
 tools/crm_resource.c | 4 +---
23c78e
 1 file changed, 1 insertion(+), 3 deletions(-)
23c78e
23c78e
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
23c78e
index 6573ad5..acaddc0 100644
23c78e
--- a/tools/crm_resource.c
23c78e
+++ b/tools/crm_resource.c
23c78e
@@ -720,9 +720,7 @@ list_alternatives_cb(const gchar *option_name, const gchar *optarg,
23c78e
                      gpointer data, GError **error)
23c78e
 {
23c78e
     SET_COMMAND(cmd_list_alternatives);
23c78e
-    options.require_cib = FALSE;
23c78e
-    options.require_dataset = FALSE;
23c78e
-    options.require_resource = FALSE;
23c78e
+    get_agent_spec(optarg);
23c78e
     return TRUE;
23c78e
 }
23c78e
 
23c78e
-- 
23c78e
1.8.3.1
23c78e
23c78e
23c78e
From c063ce9b193f2022611e651c13afcb3ceb5969e3 Mon Sep 17 00:00:00 2001
23c78e
From: Chris Lumens <clumens@redhat.com>
23c78e
Date: Wed, 2 Sep 2020 16:20:10 -0400
23c78e
Subject: [PATCH 5/6] Fix: scheduler: Use the default format handler in a few
23c78e
 more places.
23c78e
23c78e
---
23c78e
 lib/pengine/pe_output.c | 8 ++------
23c78e
 1 file changed, 2 insertions(+), 6 deletions(-)
23c78e
23c78e
diff --git a/lib/pengine/pe_output.c b/lib/pengine/pe_output.c
23c78e
index d0f96f4..9d43e5f 100644
23c78e
--- a/lib/pengine/pe_output.c
23c78e
+++ b/lib/pengine/pe_output.c
23c78e
@@ -1847,9 +1847,7 @@ static pcmk__message_entry_t fmt_functions[] = {
23c78e
     { "cluster-times", "log", pe__cluster_times_text },
23c78e
     { "cluster-times", "text", pe__cluster_times_text },
23c78e
     { "cluster-times", "xml", pe__cluster_times_xml },
23c78e
-    { "failed-action", "html", pe__failed_action_text },
23c78e
-    { "failed-action", "log", pe__failed_action_text },
23c78e
-    { "failed-action", "text", pe__failed_action_text },
23c78e
+    { "failed-action", "default", pe__failed_action_text },
23c78e
     { "failed-action", "xml", pe__failed_action_xml },
23c78e
     { "group", "xml",  pe__group_xml },
23c78e
     { "group", "html",  pe__group_html },
23c78e
@@ -1868,9 +1866,7 @@ static pcmk__message_entry_t fmt_functions[] = {
23c78e
     { "node-attribute", "log", pe__node_attribute_text },
23c78e
     { "node-attribute", "text", pe__node_attribute_text },
23c78e
     { "node-attribute", "xml", pe__node_attribute_xml },
23c78e
-    { "op-history", "html", pe__op_history_text },
23c78e
-    { "op-history", "log", pe__op_history_text },
23c78e
-    { "op-history", "text", pe__op_history_text },
23c78e
+    { "op-history", "default", pe__op_history_text },
23c78e
     { "op-history", "xml", pe__op_history_xml },
23c78e
     { "primitive", "xml",  pe__resource_xml },
23c78e
     { "primitive", "html",  pe__resource_html },
23c78e
-- 
23c78e
1.8.3.1
23c78e
23c78e
23c78e
From a32b99f5fd09ec15dbba6785c5d8dc2e220417a3 Mon Sep 17 00:00:00 2001
23c78e
From: Chris Lumens <clumens@redhat.com>
23c78e
Date: Thu, 3 Sep 2020 10:23:16 -0400
23c78e
Subject: [PATCH 6/6] Refactor: scheduler: Expose native_output_string as
23c78e
 pcmk__native_output_string.
23c78e
23c78e
The plan is that this function can be used to help build the string that
23c78e
is output for each line of "crm_resource -o" output.  It appears that
23c78e
output only happens for primitive resources.  However, I've added a
23c78e
check at the beginning just in case it's called for some other type of
23c78e
resource.
23c78e
---
23c78e
 include/crm/pengine/internal.h |  3 +++
23c78e
 lib/pengine/native.c           | 24 ++++++++++++++----------
23c78e
 2 files changed, 17 insertions(+), 10 deletions(-)
23c78e
23c78e
diff --git a/include/crm/pengine/internal.h b/include/crm/pengine/internal.h
23c78e
index abe7a76..d658e86 100644
23c78e
--- a/include/crm/pengine/internal.h
23c78e
+++ b/include/crm/pengine/internal.h
23c78e
@@ -243,6 +243,9 @@ void clone_print(pe_resource_t * rsc, const char *pre_text, long options, void *
23c78e
 void pe__print_bundle(pe_resource_t *rsc, const char *pre_text, long options,
23c78e
                       void *print_data);
23c78e
 
23c78e
+gchar * pcmk__native_output_string(pe_resource_t *rsc, const char *name, pe_node_t *node,
23c78e
+                                   long options, const char *target_role, bool show_nodes);
23c78e
+
23c78e
 int pe__name_and_nvpairs_xml(pcmk__output_t *out, bool is_list, const char *tag_name
23c78e
                          , size_t pairs_count, ...);
23c78e
 char *pe__node_display_name(pe_node_t *node, bool print_detail);
23c78e
diff --git a/lib/pengine/native.c b/lib/pengine/native.c
23c78e
index 8f0c5c9..bf1f5c0 100644
23c78e
--- a/lib/pengine/native.c
23c78e
+++ b/lib/pengine/native.c
23c78e
@@ -570,17 +570,21 @@ add_output_node(GString *s, const char *node, bool have_nodes)
23c78e
  * \return Newly allocated string description of resource
23c78e
  * \note Caller must free the result with g_free().
23c78e
  */
23c78e
-static gchar *
23c78e
-native_output_string(pe_resource_t *rsc, const char *name, pe_node_t *node,
23c78e
-                     long options, const char *target_role, bool show_nodes)
23c78e
+gchar *
23c78e
+pcmk__native_output_string(pe_resource_t *rsc, const char *name, pe_node_t *node,
23c78e
+                           long options, const char *target_role, bool show_nodes)
23c78e
 {
23c78e
     const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
23c78e
     const char *provider = NULL;
23c78e
     const char *kind = crm_element_value(rsc->xml, XML_ATTR_TYPE);
23c78e
-    char *retval = NULL;
23c78e
+    gchar *retval = NULL;
23c78e
     GString *outstr = NULL;
23c78e
     bool have_flags = false;
23c78e
 
23c78e
+    if (rsc->variant != pe_native) {
23c78e
+        return NULL;
23c78e
+    }
23c78e
+
23c78e
     CRM_CHECK(name != NULL, name = "unknown");
23c78e
     CRM_CHECK(kind != NULL, kind = "unknown");
23c78e
     CRM_CHECK(class != NULL, class = "unknown");
23c78e
@@ -758,8 +762,8 @@ pe__common_output_html(pcmk__output_t *out, pe_resource_t * rsc,
23c78e
     }
23c78e
 
23c78e
     {
23c78e
-        gchar *s = native_output_string(rsc, name, node, options, target_role,
23c78e
-                                        true);
23c78e
+        gchar *s = pcmk__native_output_string(rsc, name, node, options,
23c78e
+                                              target_role, true);
23c78e
 
23c78e
         list_node = pcmk__output_create_html_node(out, "li", NULL, NULL, NULL);
23c78e
         pcmk_create_html_node(list_node, "span", NULL, cl, s);
23c78e
@@ -826,8 +830,8 @@ pe__common_output_text(pcmk__output_t *out, pe_resource_t * rsc,
23c78e
     }
23c78e
 
23c78e
     {
23c78e
-        gchar *s = native_output_string(rsc, name, node, options, target_role,
23c78e
-                                        true);
23c78e
+        gchar *s = pcmk__native_output_string(rsc, name, node, options,
23c78e
+                                              target_role, true);
23c78e
 
23c78e
         out->list_item(out, NULL, "%s", s);
23c78e
         g_free(s);
23c78e
@@ -923,8 +927,8 @@ common_print(pe_resource_t * rsc, const char *pre_text, const char *name, pe_nod
23c78e
     }
23c78e
 
23c78e
     {
23c78e
-        gchar *resource_s = native_output_string(rsc, name, node, options,
23c78e
-                                                 target_role, false);
23c78e
+        gchar *resource_s = pcmk__native_output_string(rsc, name, node, options,
23c78e
+                                                       target_role, false);
23c78e
         status_print("%s%s", (pre_text? pre_text : ""), resource_s);
23c78e
         g_free(resource_s);
23c78e
     }
23c78e
-- 
23c78e
1.8.3.1
23c78e