Blame SOURCES/bz1158566-02-fix-loading-cluster-status-for-web-UI.patch

71541a
From f55ca2f12c4552fcd516737fa797cf806aa70705 Mon Sep 17 00:00:00 2001
71541a
From: Ondrej Mular <omular@redhat.com>
71541a
Date: Thu, 3 Sep 2015 12:29:37 +0200
71541a
Subject: [PATCH] fix loading cluster status for web UI
71541a
71541a
---
71541a
 pcs/status.py          | 37 ++++++++++++++++++++++++++++++++++---
71541a
 pcsd/cluster_entity.rb | 25 ++++++++++++++++++++++---
71541a
 pcsd/pcs.rb            |  3 +++
71541a
 3 files changed, 59 insertions(+), 6 deletions(-)
71541a
71541a
diff --git a/pcs/status.py b/pcs/status.py
71541a
index eb2a5eb..34354ef 100644
71541a
--- a/pcs/status.py
71541a
+++ b/pcs/status.py
71541a
@@ -123,14 +123,28 @@ def nodes_status(argv):
71541a
     onlinenodes = []
71541a
     offlinenodes = []
71541a
     standbynodes = []
71541a
+    remote_onlinenodes = []
71541a
+    remote_offlinenodes = []
71541a
+    remote_standbynodes = []
71541a
     for node in nodes[0].getElementsByTagName("node"):
71541a
+        node_name = node.getAttribute("name")
71541a
+        node_remote = node.getAttribute("type") == "remote"
71541a
         if node.getAttribute("online") == "true":
71541a
             if node.getAttribute("standby") == "true":
71541a
-                standbynodes.append(node.getAttribute("name"))
71541a
+                if node_remote:
71541a
+                    remote_standbynodes.append(node_name)
71541a
+                else:
71541a
+                    standbynodes.append(node_name)
71541a
             else:
71541a
-                onlinenodes.append(node.getAttribute("name"))
71541a
+                if node_remote:
71541a
+                    remote_onlinenodes.append(node_name)
71541a
+                else:
71541a
+                    onlinenodes.append(node_name)
71541a
         else:
71541a
-            offlinenodes.append(node.getAttribute("name"))
71541a
+            if node_remote:
71541a
+                remote_offlinenodes.append(node_name)
71541a
+            else:
71541a
+                offlinenodes.append(node_name)
71541a
 
71541a
     print "Pacemaker Nodes:"
71541a
 
71541a
@@ -149,6 +163,23 @@ def nodes_status(argv):
71541a
         print node,
71541a
     print ""
71541a
 
71541a
+    print "Pacemaker Remote Nodes:"
71541a
+
71541a
+    print " Online:",
71541a
+    for node in remote_onlinenodes:
71541a
+        print node,
71541a
+    print ""
71541a
+
71541a
+    print " Standby:",
71541a
+    for node in remote_standbynodes:
71541a
+        print node,
71541a
+    print ""
71541a
+
71541a
+    print " Offline:",
71541a
+    for node in remote_offlinenodes:
71541a
+        print node,
71541a
+    print ""
71541a
+
71541a
 # TODO: Remove, currently unused, we use status from the resource.py
71541a
 def resources_status(argv):
71541a
     info_dom = utils.getClusterState()
71541a
diff --git a/pcsd/cluster_entity.rb b/pcsd/cluster_entity.rb
71541a
index 78bc5ab..4f751b8 100644
71541a
--- a/pcsd/cluster_entity.rb
71541a
+++ b/pcsd/cluster_entity.rb
71541a
@@ -533,7 +533,8 @@ module ClusterEntity
71541a
       @operations = []
71541a
       failed_ops = []
71541a
       message_list = []
71541a
-      cib_dom.elements.each("//lrm_resource[@id='#{@id}']/lrm_rsc_op") { |e|
71541a
+      cib_dom.elements.each("//lrm_resource[@id='#{@id}']/lrm_rsc_op | "\
71541a
+      + "//lrm_resource[starts-with(@id, \"#{@id}:\")]/lrm_rsc_op") { |e|
71541a
         operation = ResourceOperation.new(e)
71541a
         @operations << operation
71541a
         if operation.rc_code != 0
71541a
@@ -819,13 +820,15 @@ module ClusterEntity
71541a
           primitive_list = @member.members
71541a
         end
71541a
         @masters, @slaves = get_masters_slaves(primitive_list)
71541a
-        if @masters.empty?
71541a
-          @error_list << {
71541a
+        if @masters.empty? and !disabled?
71541a
+          @status = ClusterEntity::ResourceStatus.new(:partially_running)
71541a
+          @warning_list << {
71541a
             :message => 'Resource is master/slave but has not been promoted '\
71541a
               + 'to master on any node.',
71541a
             :type => 'no_master'
71541a
           }
71541a
         end
71541a
+        @status = @member.status if @status < @member.status
71541a
       end
71541a
     end
71541a
 
71541a
@@ -851,6 +854,22 @@ module ClusterEntity
71541a
       end
71541a
     end
71541a
 
71541a
+    def update_status
71541a
+      if @member
71541a
+        @member.update_status
71541a
+        if @member.instance_of?(Primitive)
71541a
+          primitive_list = [@member]
71541a
+        else
71541a
+          primitive_list = @member.members
71541a
+        end
71541a
+        @masters, @slaves = get_masters_slaves(primitive_list)
71541a
+        if @masters.empty? and !disabled?
71541a
+          @status = ClusterEntity::ResourceStatus.new(:partially_running)
71541a
+        end
71541a
+        @status = @member.status if @status < @member.status
71541a
+      end
71541a
+    end
71541a
+
71541a
     private
71541a
     def get_masters_slaves(primitive_list)
71541a
       masters = []
71541a
diff --git a/pcsd/pcs.rb b/pcsd/pcs.rb
71541a
index cc5b038..87404ac 100644
71541a
--- a/pcsd/pcs.rb
71541a
+++ b/pcsd/pcs.rb
71541a
@@ -568,6 +568,9 @@ def get_nodes_status()
71541a
     if l.start_with?("Pacemaker Nodes:")
71541a
       in_pacemaker = true
71541a
     end
71541a
+    if l.start_with?("Pacemaker Remote Nodes:")
71541a
+      break
71541a
+    end
71541a
     if l.end_with?(":")
71541a
       next
71541a
     end
71541a
-- 
71541a
1.9.1
71541a