Blame SOURCES/0004-Fix-crm_resource-Correctly-check-if-a-resource-is-un.patch

3d71c6
From: Andrew Beekhof <andrew@beekhof.net>
3d71c6
Date: Fri, 14 Aug 2015 09:43:32 +1000
3d71c6
Subject: [PATCH] Fix: crm_resource: Correctly check if a resource is unmanaged
3d71c6
 or has a target-role
3d71c6
3d71c6
(cherry picked from commit 3ff29dbe2cab872b452c4580736d23d1f69736fa)
3d71c6
---
3d71c6
 tools/crm_resource.c         |  2 +-
3d71c6
 tools/crm_resource_runtime.c | 31 ++++++++++++++++++-------------
3d71c6
 2 files changed, 19 insertions(+), 14 deletions(-)
3d71c6
3d71c6
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
3d71c6
index 2fce3b7..156bbea 100644
3d71c6
--- a/tools/crm_resource.c
3d71c6
+++ b/tools/crm_resource.c
3d71c6
@@ -888,7 +888,7 @@ main(int argc, char **argv)
3d71c6
             rsc = uber_parent(rsc);
3d71c6
         }
3d71c6
 
3d71c6
-        crm_debug("Re-checking the state of %s on %s", rsc_id, host_uname);
3d71c6
+        crm_debug("Re-checking the state of %s for %s on %s", rsc->id, rsc_id, host_uname);
3d71c6
         if(rsc) {
3d71c6
             crmd_replies_needed = 0;
3d71c6
             rc = cli_resource_delete(cib_conn, crmd_channel, host_uname, rsc, &data_set);
3d71c6
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
3d71c6
index a270cbf..f260e19 100644
3d71c6
--- a/tools/crm_resource_runtime.c
3d71c6
+++ b/tools/crm_resource_runtime.c
3d71c6
@@ -616,35 +616,40 @@ cli_resource_delete(cib_t *cib_conn, crm_ipc_t * crmd_channel, const char *host_
3d71c6
 void
3d71c6
 cli_resource_check(cib_t * cib_conn, resource_t *rsc)
3d71c6
 {
3d71c6
-
3d71c6
+    int need_nl = 0;
3d71c6
     char *role_s = NULL;
3d71c6
     char *managed = NULL;
3d71c6
     resource_t *parent = uber_parent(rsc);
3d71c6
 
3d71c6
-    find_resource_attr(cib_conn, XML_ATTR_ID, parent->id,
3d71c6
-                       XML_TAG_META_SETS, NULL, NULL, XML_RSC_ATTR_MANAGED, &managed);
3d71c6
+    find_resource_attr(cib_conn, XML_NVPAIR_ATTR_VALUE, parent->id,
3d71c6
+                       NULL, NULL, NULL, XML_RSC_ATTR_MANAGED, &managed);
3d71c6
 
3d71c6
-    find_resource_attr(cib_conn, XML_ATTR_ID, parent->id,
3d71c6
-                       XML_TAG_META_SETS, NULL, NULL, XML_RSC_ATTR_TARGET_ROLE, &role_s);
3d71c6
+    find_resource_attr(cib_conn, XML_NVPAIR_ATTR_VALUE, parent->id,
3d71c6
+                       NULL, NULL, NULL, XML_RSC_ATTR_TARGET_ROLE, &role_s);
3d71c6
 
3d71c6
-    if(managed == NULL) {
3d71c6
-        managed = strdup("1");
3d71c6
-    }
3d71c6
-    if(crm_is_true(managed) == FALSE) {
3d71c6
-        printf("\n\t*Resource %s is configured to not be managed by the cluster\n", parent->id);
3d71c6
-    }
3d71c6
     if(role_s) {
3d71c6
         enum rsc_role_e role = text2role(role_s);
3d71c6
         if(role == RSC_ROLE_UNKNOWN) {
3d71c6
             // Treated as if unset
3d71c6
 
3d71c6
         } else if(role == RSC_ROLE_STOPPED) {
3d71c6
-            printf("\n\t* The configuration specifies that '%s' should remain stopped\n", parent->id);
3d71c6
+            printf("\n  * The configuration specifies that '%s' should remain stopped\n", parent->id);
3d71c6
+            need_nl++;
3d71c6
 
3d71c6
         } else if(parent->variant > pe_clone && role != RSC_ROLE_MASTER) {
3d71c6
-            printf("\n\t* The configuration specifies that '%s' should not be promoted\n", parent->id);
3d71c6
+            printf("\n  * The configuration specifies that '%s' should not be promoted\n", parent->id);
3d71c6
+            need_nl++;
3d71c6
         }
3d71c6
     }
3d71c6
+
3d71c6
+    if(managed && crm_is_true(managed) == FALSE) {
3d71c6
+        printf("%s  * The configuration prevents the cluster from stopping or starting '%s' (unmanaged)\n", need_nl == 0?"\n":"", parent->id);
3d71c6
+        need_nl++;
3d71c6
+    }
3d71c6
+
3d71c6
+    if(need_nl) {
3d71c6
+        printf("\n");
3d71c6
+    }
3d71c6
 }
3d71c6
 
3d71c6
 int