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

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



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2008-02-05 18:26:55

Modified files:
	luci/site/luci/Extensions: LuciValidation.py 
	luci/site/luci/Extensions/ClusterModel: ClusterNode.py 
	                                        ModelBuilder.py 

Log message:
	Fix a bug that caused fence method blocks to be added inside the first child tag of cluster nodes (which need not be <fence>).

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciValidation.py.diff?cvsroot=cluster&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ClusterNode.py.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&r1=1.15&r2=1.16

--- conga/luci/site/luci/Extensions/LuciValidation.py	2008/01/23 04:34:09	1.6
+++ conga/luci/site/luci/Extensions/LuciValidation.py	2008/02/05 18:26:54	1.7
@@ -81,12 +81,12 @@
 
 	levels = node.getFenceLevels()
 	try:
-		method_id = levels[fence_level - 1].getAttribute('name')
+		method_id = levels[min(1, fence_level - 1)].getAttribute('name')
 		if not method_id:
 			raise Exception, 'No method ID'
 		fence_method = Method()
 		fence_method.addAttribute('name', str(method_id))
-		levels[fence_level - 1] = fence_method
+		levels[min(1, fence_level - 1)] = fence_method
 	except Exception, e:
 		method_id = fence_level
 		fence_method = Method()
@@ -102,7 +102,7 @@
 				break
 		if delete_target is not None:
 			try:
-				node.getChildren()[0].removeChild(delete_target)
+				node.getFenceNode().removeChild(delete_target)
 			except Exception, e:
 				if LUCI_DEBUG_MODE is True:
 					luci_log.debug_verbose('vNFC9: %s: %r %s' \
@@ -251,23 +251,17 @@
 				continue
 			fence_method.addChild(retobj)
 
-		if len(node.getChildren()) > 0:
-			# There's already a <fence> block
-			found_target = False
-			for idx in xrange(len(levels)):
-				if levels[idx].getAttribute('name') == method_id:
-					found_target = True
-					break
-
-			if found_target is False:
-				# There's a fence block, but no relevant method
-				# block
-				node.getChildren()[0].addChild(fence_method)
-		else:
-			# There is no <fence> tag under the node yet.
-			fence_node = Fence()
+		fence_node = node.getFenceNode()
+		found_target = False
+		for idx in xrange(len(levels)):
+			if levels[idx].getAttribute('name') == method_id:
+				found_target = True
+				break
+
+		if found_target is False:
+			# There's a fence block, but no relevant method
+			# block
 			fence_node.addChild(fence_method)
-			node.addChild(fence_node)
 
 	if len(errors) > 0:
 		return (False, {'errors': errors })
--- conga/luci/site/luci/Extensions/ClusterModel/ClusterNode.py	2008/01/02 20:56:08	1.4
+++ conga/luci/site/luci/Extensions/ClusterModel/ClusterNode.py	2008/02/05 18:26:55	1.5
@@ -6,6 +6,7 @@
 # Free Software Foundation.
 
 from TagObject import TagObject
+from Fence import Fence
 
 TAG_NAME = "clusternode"
 
@@ -14,16 +15,21 @@
     TagObject.__init__(self)
     self.TAG_NAME = TAG_NAME
 
+  def getFenceNode(self):
+    ret = None
+    for child in self.getChildren():
+        if child.getTagName() == 'fence':
+            ret = child
+            break
+    if ret is None:
+        ret = Fence()
+        self.addChild(ret)
+    return ret
+
   def getFenceLevels(self):
-    #under this node will be a 'fence' block, then 0 or more 'method'  blocks.
-    #This method returns the set of 'method' objs. 'method' blocks represent
-    #fence levels
-    child = self.getChildren()
-    if len(child) > 0:
-      return child[0].getChildren()
-    else:
-      retval = list()
-      return retval
+    # This method returns the set of 'method' objs. 'method' blocks represent
+    # fence levels
+    return self.getFenceNode().getChildren()
 
   def getMulticastNode(self):
     children = self.getChildren()
--- conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2008/01/15 04:41:40	1.15
+++ conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2008/02/05 18:26:55	1.16
@@ -981,13 +981,6 @@
       mcast = self.mcast_ptr
 
     mcast.addAttribute('addr', mcast_addr)
-    if mcast_if is not None:
-      mcast.addAttribute('interface', mcast_if)
-    else:
-      try:
-        mcast.removeAttribute('interface')
-      except:
-        pass
     self.mcast_address = mcast_addr
     self.mcast_interface = mcast_if
     self.usesMulticast = True


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