commit 7af2878cbd98455aaa141978c2d538f019ed1bef
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Fri Jun 24 18:24:39 2016 -0500

    Low: libpengine: print target role and blocked status in XML output
    
    consistent with text/HTML output (added by 4657ad0)

diff --git a/lib/pengine/clone.c b/lib/pengine/clone.c
index 663a935..a945f28 100644
--- a/lib/pengine/clone.c
+++ b/lib/pengine/clone.c
@@ -314,11 +314,36 @@ short_print(char *list, const char *prefix, const char *type, const char *suffix
     }
 }
 
+static const char *
+configured_role_str(resource_t * rsc)
+{
+    const char *target_role = g_hash_table_lookup(rsc->meta,
+                                                  XML_RSC_ATTR_TARGET_ROLE);
+
+    if (target_role == NULL) {
+        target_role = g_hash_table_lookup(((resource_t*)rsc->children->data)->meta,
+                                          XML_RSC_ATTR_TARGET_ROLE);
+    }
+    return target_role;
+}
+
+static enum rsc_role_e
+configured_role(resource_t * rsc)
+{
+    const char *target_role = configured_role_str(rsc);
+
+    if (target_role) {
+        return text2role(target_role);
+    }
+    return RSC_ROLE_UNKNOWN;
+}
+
 static void
 clone_print_xml(resource_t * rsc, const char *pre_text, long options, void *print_data)
 {
     int is_master_slave = rsc->variant == pe_master ? 1 : 0;
     char *child_text = crm_concat(pre_text, "   ", ' ');
+    const char *target_role = configured_role_str(rsc);
     GListPtr gIter = rsc->children;
 
     status_print("%s<clone ", pre_text);
@@ -329,6 +354,9 @@ clone_print_xml(resource_t * rsc, const char *pre_text, long options, void *prin
     status_print("failed=\"%s\" ", is_set(rsc->flags, pe_rsc_failed) ? "true" : "false");
     status_print("failure_ignored=\"%s\" ",
                  is_set(rsc->flags, pe_rsc_failure_ignored) ? "true" : "false");
+    if (target_role) {
+        status_print("target_role=\"%s\" ", target_role);
+    }
     status_print(">\n");
 
     for (; gIter != NULL; gIter = gIter->next) {
@@ -371,21 +399,6 @@ bool is_set_recursive(resource_t * rsc, long long flag, bool any)
     return FALSE;
 }
 
-static enum rsc_role_e
-configured_role(resource_t * rsc)
-{
-    const char *target_role = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_TARGET_ROLE);
-
-    if(target_role == NULL) {
-        target_role = g_hash_table_lookup(((resource_t*)rsc->children->data)->meta, XML_RSC_ATTR_TARGET_ROLE);
-    }
-
-    if(target_role) {
-        return text2role(target_role);
-    }
-    return RSC_ROLE_UNKNOWN;
-}
-
 void
 clone_print(resource_t * rsc, const char *pre_text, long options, void *print_data)
 {
diff --git a/lib/pengine/native.c b/lib/pengine/native.c
index 957f3f2..712423e 100644
--- a/lib/pengine/native.c
+++ b/lib/pengine/native.c
@@ -360,17 +360,40 @@ native_pending_task(resource_t * rsc)
     return pending_task;
 }
 
-static void
-native_print_xml(resource_t * rsc, const char *pre_text, long options, void *print_data)
+static enum rsc_role_e
+native_displayable_role(resource_t *rsc)
 {
     enum rsc_role_e role = rsc->role;
-    const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
-    const char *prov = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER);
-    const char *rsc_state = NULL;
 
-    if(role == RSC_ROLE_STARTED && uber_parent(rsc)->variant == pe_master) {
+    if ((role == RSC_ROLE_STARTED)
+        && (uber_parent(rsc)->variant == pe_master)) {
+
         role = RSC_ROLE_SLAVE;
     }
+    return role;
+}
+
+static const char *
+native_displayable_state(resource_t *rsc, long options)
+{
+    const char *rsc_state = NULL;
+
+    if (options & pe_print_pending) {
+        rsc_state = native_pending_state(rsc);
+    }
+    if (rsc_state == NULL) {
+        rsc_state = role2text(native_displayable_role(rsc));
+    }
+    return rsc_state;
+}
+
+static void
+native_print_xml(resource_t * rsc, const char *pre_text, long options, void *print_data)
+{
+    const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
+    const char *prov = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER);
+    const char *rsc_state = native_displayable_state(rsc, options);
+    const char *target_role = NULL;
 
     /* resource information. */
     status_print("%s<resource ", pre_text);
@@ -379,15 +402,16 @@ native_print_xml(resource_t * rsc, const char *pre_text, long options, void *pri
                  class,
                  prov ? "::" : "", prov ? prov : "", crm_element_value(rsc->xml, XML_ATTR_TYPE));
 
-    if (options & pe_print_pending) {
-        rsc_state = native_pending_state(rsc);
+    status_print("role=\"%s\" ", rsc_state);
+    if (rsc->meta) {
+        target_role = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_TARGET_ROLE);
     }
-    if (rsc_state == NULL) {
-        rsc_state = role2text(role);
+    if (target_role) {
+        status_print("target_role=\"%s\" ", target_role);
     }
-    status_print("role=\"%s\" ", rsc_state);
     status_print("active=\"%s\" ", rsc->fns->active(rsc, TRUE) ? "true" : "false");
     status_print("orphaned=\"%s\" ", is_set(rsc->flags, pe_rsc_orphan) ? "true" : "false");
+    status_print("blocked=\"%s\" ", is_set(rsc->flags, pe_rsc_block) ? "true" : "false");
     status_print("managed=\"%s\" ", is_set(rsc->flags, pe_rsc_managed) ? "true" : "false");
     status_print("failed=\"%s\" ", is_set(rsc->flags, pe_rsc_failed) ? "true" : "false");
     status_print("failure_ignored=\"%s\" ",
@@ -431,7 +455,6 @@ native_print_xml(resource_t * rsc, const char *pre_text, long options, void *pri
     }
 }
 
-
 void
 native_print(resource_t * rsc, const char *pre_text, long options, void *print_data)
 {
@@ -440,7 +463,7 @@ native_print(resource_t * rsc, const char *pre_text, long options, void *print_d
     const char *class = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
     const char *kind = crm_element_value(rsc->xml, XML_ATTR_TYPE);
     const char *target_role = NULL;
-    enum rsc_role_e role = rsc->role;
+    enum rsc_role_e role = native_displayable_role(rsc);
 
     int offset = 0;
     int flagOffset = 0;
@@ -459,10 +482,6 @@ native_print(resource_t * rsc, const char *pre_text, long options, void *print_d
         target_role = g_hash_table_lookup(rsc->meta, XML_RSC_ATTR_TARGET_ROLE);
     }
 
-    if(role == RSC_ROLE_STARTED && uber_parent(rsc)->variant == pe_master) {
-        role = RSC_ROLE_SLAVE;
-    }
-
     if (pre_text == NULL && (options & pe_print_printf)) {
         pre_text = " ";
     }
@@ -518,13 +537,8 @@ native_print(resource_t * rsc, const char *pre_text, long options, void *print_d
     } else if(is_set(rsc->flags, pe_rsc_failed)) {
         offset += snprintf(buffer + offset, LINE_MAX - offset, "FAILED");
     } else {
-        const char *rsc_state = NULL;
-        if (options & pe_print_pending) {
-            rsc_state = native_pending_state(rsc);
-        }
-        if (rsc_state == NULL) {
-            rsc_state = role2text(role);
-        }
+        const char *rsc_state = native_displayable_state(rsc, options);
+
         offset += snprintf(buffer + offset, LINE_MAX - offset, "%s", rsc_state);
     }
 
diff --git a/xml/crm_mon.rng b/xml/crm_mon.rng
index e3e1aa3..008c3ef 100644
--- a/xml/crm_mon.rng
+++ b/xml/crm_mon.rng
@@ -249,8 +249,14 @@
             <attribute name="id"> <text/> </attribute>
             <attribute name="resource_agent"> <text/> </attribute>
             <attribute name="role"> <text/> </attribute>
+            <optional>
+                <attribute name="target_role"> <text/> </attribute>
+            </optional>
             <attribute name="active"> <data type="boolean" /> </attribute>
             <attribute name="orphaned"> <data type="boolean" /> </attribute>
+            <optional>
+                <attribute name="blocked"> <data type="boolean" /> </attribute>
+            </optional>
             <attribute name="managed"> <data type="boolean" /> </attribute>
             <attribute name="failed"> <data type="boolean" /> </attribute>
             <attribute name="failure_ignored"> <data type="boolean" /> </attribute>
@@ -285,6 +291,9 @@
             <attribute name="managed"> <data type="boolean" /> </attribute>
             <attribute name="failed"> <data type="boolean" /> </attribute>
             <attribute name="failure_ignored"> <data type="boolean" /> </attribute>
+            <optional>
+                <attribute name="target_role"> <text/> </attribute>
+            </optional>
             <ref name="resource_list" />
         </element>
     </define>
