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

[Cluster-devel] conga/luci/site/luci/Extensions ModelBuilder.p ...



CVSROOT:	/cvs/cluster
Module name:	conga
Branch: 	RHEL5
Changes by:	kupcevic sourceware org	2007-01-10 21:48:26

Modified files:
	luci/site/luci/Extensions: ModelBuilder.py TagObject.py 

Log message:
	small piece of 212021 that enables ui when bad tags are passed in - prevents button lockup

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ModelBuilder.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.8.2.4&r2=1.8.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/TagObject.py.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1&r2=1.1.2.1

--- conga/luci/site/luci/Extensions/ModelBuilder.py	2007/01/10 19:26:56	1.8.2.4
+++ conga/luci/site/luci/Extensions/ModelBuilder.py	2007/01/10 21:48:26	1.8.2.5
@@ -122,6 +122,7 @@
     self.isModified = False
     self.quorumd_ptr = None
     self.usesQuorumd = False
+    self.unusual_items = list()
     self.isVirtualized = False
     if mcast_addr == None:
       self.usesMulticast = False
@@ -137,6 +138,7 @@
       self.purgePCDuplicates()
       self.resolve_references()
       self.check_for_multicast()
+      self.check_for_nodeids()
     else:
       if filename == None:
         if lock_type == DLM_TYPE:
@@ -160,7 +162,7 @@
         self.check_for_multicast()
 
 
-  def buildModel(self, parent_node):
+  def buildModel(self, parent_node, parent_object=None):
 
     if parent_node == None:
       parent_node = self.parent
@@ -178,8 +180,22 @@
           attrNode = attrs.get(attrName)
           attrValue = attrNode.nodeValue
           new_object.addAttribute(attrName,attrValue)
-      except KeyError, k:
+      except KeyError, k: ##This allows for custom tags
+        new_object = TagObject(parent_node.nodeName)
+        attrs = parent_node.attributes
+        for attrName in attrs.keys():
+          attrNode = attrs.get(attrName)
+          attrValue = attrNode.nodeValue
+          new_object.addAttribute(attrName, attrValue)
+        self.unusual_items.append((parent_object, new_object))
+        for item in parent_node.childNodes:
+          result_object = self.buildModel(item, new_object)
+          if result_object != None:
+            new_object.addChild(result_object)
         return None
+
+       ######End of unusual item exception
+
       if parent_node.nodeName == CLUSTER_PTR_STR:
         self.cluster_ptr = new_object
       if parent_node.nodeName == CLUSTERNODES_PTR_STR:
@@ -210,7 +226,7 @@
 
 
     for item in parent_node.childNodes:
-      result_object = self.buildModel(item)
+      result_object = self.buildModel(item,new_object)
       if result_object != None:
         new_object.addChild(result_object)
 
@@ -422,6 +438,7 @@
     
     #check for dual power fences
     self.dual_power_fence_check()
+    self.restore_unusual_items()
 
     try:
 
@@ -431,15 +448,70 @@
 
       self.isModified = False
 
+    ##Need to restore model
+      self.parent = doc
+
+      self.object_tree = self.buildModel(None)
+      self.check_empty_ptrs()
+      self.check_fence_daemon()
+      self.resolve_fence_instance_types()
+      self.purgePCDuplicates()
+      self.resolve_references()
+      self.check_for_multicast() 
+
     finally:
+      pass
       #dual_power_fence_check() adds extra
       #fence instance entries for dual power controllers
       #These must be removed from the tree before the UI
       #can be used
-      self.purgePCDuplicates()
+      #self.purgePCDuplicates()
 
     return strbuf
-  
+
+  def restore_unusual_items(self):
+    for item in self.unusual_items:
+      duplicate = False
+      kids = item[0].getChildren()
+      for kid in kids:
+        if kid == item[1]:
+          duplicate = True
+          break
+      if duplicate == True:
+        continue
+      else:
+        item[0].addChild(item[1]) 
+
+  def check_for_nodeids(self):
+    nodes = self.getNodes()
+    for node in nodes:
+      if node.getAttribute('nodeid') == None:
+        new_id = self.getUniqueNodeID()
+        node.addAttribute('nodeid',new_id)
+                                                                                
+  def getUniqueNodeID(self):
+    nodes = self.getNodes()
+    total_nodes = len(nodes)
+    dex_list = list()
+    for nd_idx in range (1, (total_nodes + 3)):
+      dex_list.append(str(nd_idx))
+                                                                                
+    for dex in dex_list:
+      found = False
+      for node in nodes:
+        ndid = node.getAttribute('nodeid')
+        if ndid != None:
+          if ndid == dex:
+            found = True
+            break
+        else:
+          continue
+                                                                                
+      if found == True:
+        continue
+      else:
+        return dex
+ 
   def has_filepath(self):
     if self.filename == None:
       return False
--- conga/luci/site/luci/Extensions/TagObject.py	2006/05/30 20:17:21	1.1
+++ conga/luci/site/luci/Extensions/TagObject.py	2007/01/10 21:48:26	1.1.2.1
@@ -3,10 +3,13 @@
 TAG_NAME = "document"
 
 class TagObject:
-  def __init__(self):
+  def __init__(self, tagname=None):
     self.attr_hash = {}
     self.children = list()
-    self.TAG_NAME = TAG_NAME
+    if tagname == None:
+      self.TAG_NAME = TAG_NAME
+    else:
+      self.TAG_NAME = tagname
 
   def addChild(self, child):
     #print "in AddChild, adding child %s" % child.getName()


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