[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-07 20:13:17

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

Log message:
	separation of fence info calls

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

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/07 02:36:04	1.150
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/07 20:13:17	1.151
@@ -2867,11 +2867,10 @@
 
   return map
   
-def getFenceInfo(self, model, request, fornode = None):
+def getFenceInfo(self, model, request):
   clustername = request['clustername']
   baseurl = request['URL']
   map = {}
-  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
@@ -2880,132 +2879,90 @@
   map['level2'] = level2
   map['shared1'] = shared1
   map['shared2'] = shared2
-  map['fencedevs'] = fencedevs
-  nodename = ""
-  if fornode == 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 = {}
-        attr_hash = fd.getAttributes()
-        kees = attr_hash.keys()
-        for kee in kees:
-          fencedev[kee] = attr_hash[kee] #copy attrs over
-        try:
-          fencedev['pretty_name'] = FENCE_OPTS[fd.getAgentType()]
-        except:
-          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
+  pass
 
-  else:
-    pass
-    try:
-      nodename = request['nodename']
-    except KeyError, e:
-      raise GeneralError('FATAL', "Could not extract nodename from request")
+  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
-    #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:
-      raise GeneralError('FATAL', "Couldn't find node name in current node list")
+  #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:
+    raise GeneralError('FATAL', "Couldn't find node name in current node list")
 
-    levels = node.getFenceLevels()
-    len_levels = len(levels)
+  levels = node.getFenceLevels()
+  len_levels = len(levels)
 
-    if len_levels == 0:
-      return map
+  if len_levels == 0:
+    return map
 
-    for i in xrange(2):
-      if not i in levels:
-        continue
-      fence_struct = {}
-      if levels[i] != None:
-        level = levels[i]
-      else:
-        #No more levels...
-        continue
-      kids = level.getChildren()
-      if len(kids) == 0:
-        continue
+  for i in xrange(2):
+    if not i in levels:
+      continue
+    fence_struct = {}
+    if levels[i] != None:
+      level = levels[i]
+    else:
+      #No more levels...
+      continue
+    kids = level.getChildren()
+    if len(kids) == 0:
+      continue
+    else:
+      #for each kid, 
+      ### resolve name, find fence device
+      ### Add fd to list, if it is not there yet 
+      ### determine if it is a shared fence type
+      ### if it is a shared device, add instance entry
+      fds = model.getFenceDevices()
+      fence_struct = None
+      for kid in kids:
+        name = kid.getName()
+        found_fd = False
+        if not i in map:
+          continue
+        for entry in map[i]:
+          if entry['name'] == name:
+            fence_struct = entry
+            found_fd = True
+            break
+        if found_fd == False:
+          for fd in fds:
+            if fd.getName() == name:  #Found the fence device
+              fence_struct = {}
+              fence_struct['isShareable'] = fd.isShared()
+              fd_attrs = fd.getAttributes()
+              kees = fd_attrs.keys()
+              for kee in kees:
+                fence_struct[kee] = fd_attrs[kee]
+        fi_attrs = kid.getAttributes()
+        kees = fi_attrs.keys()
+        if fence_struct['isShareable'] == True:
+          instance_struct = {}
+          for kee in kees:
+            instance_struct[kee] = fi_attrs[kee]
+            try:
+                check = fence_struct['instances']
+                check.append(instance_struct)
+            except KeyError, e:
+                fence_struct['instances'] = list()
+                fence_struct['instances'].append(instance_struct) 
+        else:  #Not a shareable fence device type
+          for kee in kees:
+            fence_struct[kee] = fi_attrs[kee]
+      if i == 0:
+        level1.append(fence_struct)      
       else:
-        #for each kid, 
-        ### resolve name, find fence device
-        ### Add fd to list, if it is not there yet 
-        ### determine if it is a shared fence type
-        ### if it is a shared device, add instance entry
-        fds = model.getFenceDevices()
-        fence_struct = None
-        for kid in kids:
-          name = kid.getName()
-          found_fd = False
-          if not i in map:
-            continue
-          for entry in map[i]:
-            if entry['name'] == name:
-              fence_struct = entry
-              found_fd = True
-              break
-          if found_fd == False:
-            for fd in fds:
-              if fd.getName() == name:  #Found the fence device
-                fence_struct = {}
-                fence_struct['isShareable'] = fd.isShared()
-                fd_attrs = fd.getAttributes()
-                kees = fd_attrs.keys()
-                for kee in kees:
-                  fence_struct[kee] = fd_attrs[kee]
-          fi_attrs = kid.getAttributes()
-          kees = fi_attrs.keys()
-          if fence_struct['isShareable'] == True:
-            instance_struct = {}
-            for kee in kees:
-              instance_struct[kee] = fi_attrs[kee]
-              try:
-                  check = fence_struct['instances']
-                  check.append(instance_struct)
-              except KeyError, e:
-                  fence_struct['instances'] = list()
-                  fence_struct['instances'].append(instance_struct) 
-          else:  #Not a shareable fence device type
-            for kee in kees:
-              fence_struct[kee] = fi_attrs[kee]
-        if i == 0:
-          level1.append(fence_struct)      
-        else:
-          level2.append(fence_struct)      
+        level2.append(fence_struct)      
 
-    return map    
+  return map    
       
 def getFencesInfo(self, model, request):
   clustername = request['clustername']
@@ -3015,6 +2972,7 @@
   map['fencedevs'] = fencedevs
   #Get list of fence devices
   fds = model.getFenceDevices()
+  nodes_used = list() #This section determines which nodes use the dev
   for fd in fds:
     #create fencedev hashmap
     if fd.isShared() == True:
@@ -3028,14 +2986,15 @@
       except:
         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():
+            luci_log.debug_verbose('getFencesInfo: comparing >%s< and >%s<' % (kid.getName().strip(),fd.getName().strip()))
+            if kid.getName().strip() == fd.getName().strip():
+              luci_log.debug_verbose('getFencesInfo: Found a match')
               #See if this fd already has an entry for this node
               found_duplicate = False
               for item in nodes_used:


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