[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/luci/site/luci/Extensions cluster_adapte ...



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	jparsons sourceware org	2006-11-03 21:13:25

Modified files:
	luci/site/luci/Extensions: cluster_adapters.py 

Log message:
	Partial fix for broken fence list page

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.142&r2=1.143

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/03 19:13:57	1.142
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/03 21:13:25	1.143
@@ -19,6 +19,7 @@
 from Vm import Vm
 from Script import Script
 from Samba import Samba
+from FenceHandler import FenceHandler
 from clusterOS import resolveOSType
 from GeneralError import GeneralError
 from UnknownClusterError import UnknownClusterError
@@ -2671,38 +2672,83 @@
   for fencedev in fencedevs:
     if fencedev.getName().strip() == fencename:
       map = fencedev.getAttributes()
+      try:
+        map['pretty_name'] = FenceHandler.FENCE_OPTS[fencedev.getAgentType()]
+      except Exception, e:
+        map['pretty_name'] = fencedev.getAgentType()
+
       return map
 
   return map
   
 def getFenceInfo(self, model, request):
+  clustername = request['clustername']
+  baseurl = request['URL']
   map = {}
-  fencedevs = list() 
-  level1 = list()
-  level2 = list()
+  fencedevs = list() #This is for the fencedev list page
+  level1 = list() #First level fence devices
+  level2 = list() #Second level fence devices
+  shared1 = list() #List of available sharable fence devs not used in level1
+  shared2 = list() #List of available sharable fence devs not used in level2
   map['level1'] = level1
   map['level2'] = level2
+  map['shared1'] = shared1
+  map['shared2'] = shared2
   map['fencedevs'] = fencedevs
   nodename = ""
-  if request == None:  #this is being called by the fence device page
+  if request == None:  #this is being called by the fence device list page
     #Get list of fence devices
     fds = model.getFenceDevices()
     for fd in fds:
       #create fencedev hashmap
       if fd.isShared() == True:
-        fencedev = fd.getAttributes()
-        fencedevs.append(fencedev)
+        fencedev = {}
+        attr_hash = fd.getAttributes()
+        kees = attr_hash.keys()
+        for kee in kees:
+          fencedev[kee] = attr_hash[kee] #copy attrs over
+        try:
+          fencedev['pretty_name'] = FenceHandler.FENCE_OPTS[fd.getAgentType()]
+        except Exception, e:
+          fencedev['pretty_name'] = fd.getAgentType()
+
+        nodes_used = list() #This section determines which nodes use the dev
+        nodes = model.getNodes()
+        for node in nodes:
+          flevels = node.getFenceLevels()
+          for flevel in flevels: #These are the method blocks...
+            kids = flevel.getChildren()
+            for kid in kids: #These are actual devices in each level
+              if kid.getName().strip == fd.getName().strip():
+                #See if this fd already has an entry for this node
+                found_duplicate = False
+                for item in nodes_used:
+                  if item['nodename'] == node.getName().strip():
+                    found_duplicate = True
+                if found_duplicate == True:
+                  continue
+                node_hash = {}
+                node_hash['nodename'] = node.getName().strip()
+                node_hash['nodeurl'] = baseurl + "#fence" + "?clustername=" + clustername + "&nodename=" + node.getName() + "&pagetype=" + NODE 
+                nodes_used.append(node_hash)
+
+        fencedev['nodesused'] = nodes_used
+      fencedevs.append(fencedev)
       
     return map
 
   else:
+    pass
     try:
       nodename = request['nodename']
     except KeyError, e:
       raise GeneralError('FATAL', "Could not extract nodename from request")
     
-    #here we need to get fences for a node - just the first two levels
-    #then fill in two data structures with all attr's 
+    #Here we need to get fences for a node - just the first two levels
+    #Each level has its own list of fence devs used in that level
+    #For each fence dev, a list of instance structs is appended
+    #In addition, for each level, a list of available but unused fence devs
+    #is returned. 
     try:
       node = model.retrieveNodeByName(nodename)
     except GeneralError, e:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]