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

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



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2007-10-03 19:40:37

Modified files:
	luci/site/luci/Extensions: FenceHandler.py 
	luci/site/luci/Extensions/ClusterModel: Device.py FenceDevice.py 
	                                        FenceDeviceAttr.py 
	                                        ModelBuilder.py 

Log message:
	Fix a bug that caused the check for dual power fencing to fail when adding new fence instances for the first time.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/FenceHandler.py.diff?cvsroot=cluster&r1=1.26&r2=1.27
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/Device.py.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/FenceDevice.py.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/FenceDeviceAttr.py.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py.diff?cvsroot=cluster&r1=1.11&r2=1.12

--- conga/luci/site/luci/Extensions/FenceHandler.py	2007/10/03 02:11:58	1.26
+++ conga/luci/site/luci/Extensions/FenceHandler.py	2007/10/03 19:40:37	1.27
@@ -1077,6 +1077,7 @@
 
 	fenceinst = Device()
 	fenceinst.addAttribute('name', parent_name)
+	fenceinst.setAgentType(fence_agent)
 
 	if form.has_key('option'):
 		option = form['option'].strip()
--- conga/luci/site/luci/Extensions/ClusterModel/Device.py	2007/09/20 22:37:32	1.5
+++ conga/luci/site/luci/Extensions/ClusterModel/Device.py	2007/10/03 19:40:37	1.6
@@ -31,11 +31,7 @@
     return self.has_native_option_set
 
   def isPowerController(self):
-    for item in FenceDeviceAttr.FENCE_POWER_CONTROLLERS:
-      if self.agent_type == item:
-        return True
-
-    return False
+    return self.agent_type in FenceDeviceAttr.FENCE_POWER_CONTROLLERS
 
   def addAttribute(self, name, value):
     if name == OPTION:
--- conga/luci/site/luci/Extensions/ClusterModel/FenceDevice.py	2007/09/20 22:37:32	1.3
+++ conga/luci/site/luci/Extensions/ClusterModel/FenceDevice.py	2007/10/03 19:40:37	1.4
@@ -29,7 +29,11 @@
     return agent
 
   def getPrettyName(self):
-    return self.pretty_fence_names[self.attr_hash['name']]
+    agent_type = self.getAgentType()
+    pname = self.pretty_fence_names.get(agent_type)
+    if pname is None:
+      pname = agent_type
+    return pname
 
   def isShared(self):
     agent = self.getAgentType()
@@ -39,8 +43,4 @@
         return False
       else:
         return True
-
-    try:
-      return self.shared_fences[agent]
-    except KeyError, e:
-      return False
+    return self.shared_fences.has_key(agent)
--- conga/luci/site/luci/Extensions/ClusterModel/FenceDeviceAttr.py	2007/09/21 16:06:52	1.2
+++ conga/luci/site/luci/Extensions/ClusterModel/FenceDeviceAttr.py	2007/10/03 19:40:37	1.3
@@ -5,7 +5,11 @@
 # GNU General Public License as published by the
 # Free Software Foundation.
 
-FENCE_POWER_CONTROLLERS = [ 'fence_wti', 'fence_apc', 'fence_apc_snmp' ]
+FENCE_POWER_CONTROLLERS = (
+	'fence_wti',
+	'fence_apc',
+	'fence_apc_snmp'
+)
 
 FENCE_OPTS = {
 	'fence_apc':			'APC Power Device',
@@ -70,61 +74,61 @@
 }
 
 FENCE_FI_ATTRS = {
-	'fence_apc':			[ 'port', 'switch' ],
-	'fence_wti':			[ 'port' ],
-	'fence_brocade':		[ 'port' ],
-	'fence_vixel':			[ 'port' ],
-	'fence_gnbd':			[ 'ipaddress' ],
-	'fence_sanbox2':		[ 'port' ],
-	'fence_bladecenter':	[ 'blade' ],
-	'fence_mcdata':			[ 'port' ],
-	'fence_egenera':		[ 'lpan', 'pserver' ],
-	'fence_bullpap':		[ 'domain' ],
-	'fence_xvm':			[ 'domain' ],
-	'fence_scsi':			[ 'node' ],
-	'fence_ilo':			[ ],
-	'fence_ipmilan':		[ ],
-	'fence_drac':			[ ],
-	'fence_rsa':			[ ],
-	'fence_rps10':			[ ],
-	'fence_manual':			[ ]
+	'fence_apc':			( 'port', 'switch' ),
+	'fence_wti':			( 'port' ),
+	'fence_brocade':		( 'port' ),
+	'fence_vixel':			( 'port' ),
+	'fence_gnbd':			( 'ipaddress' ),
+	'fence_sanbox2':		( 'port' ),
+	'fence_bladecenter':	( 'blade' ),
+	'fence_mcdata':			( 'port' ),
+	'fence_egenera':		( 'lpan', 'pserver' ),
+	'fence_bullpap':		( 'domain' ),
+	'fence_xvm':			( 'domain' ),
+	'fence_scsi':			( 'node' ),
+	'fence_ilo':			( ),
+	'fence_ipmilan':		( ),
+	'fence_drac':			( ),
+	'fence_rsa':			( ),
+	'fence_rps10':			( ),
+	'fence_manual':			( )
 }
 
 FENCE_FD_ATTRS = {
 	'fence_apc':
-		[ 'name', 'ipaddr', 'login', 'passwd' ],
+		( 'name', 'ipaddr', 'login', 'passwd' ),
 	'fence_wti':
-		[ 'name', 'ipaddr', 'passwd' ],
+		( 'name', 'ipaddr', 'passwd' ),
 	'fence_brocade':
-		[ 'name', 'ipaddr', 'login', 'passwd' ],
+		( 'name', 'ipaddr', 'login', 'passwd' ),
 	'fence_vixel':
-		[ 'name', 'ipaddr', 'passwd' ],
+		( 'name', 'ipaddr', 'passwd' ),
 	'fence_gnbd':
-		[ 'name', 'servers' ],
+		( 'name', 'servers' ),
 	'fence_sanbox2':
-		[ 'name', 'ipaddr', 'login', 'passwd' ],
+		( 'name', 'ipaddr', 'login', 'passwd' ),
 	'fence_bladecenter':
-		[ 'name', 'ipaddr', 'login', 'passwd' ],
+		( 'name', 'ipaddr', 'login', 'passwd' ),
 	'fence_mcdata':
-		[ 'name', 'ipaddr', 'login', 'passwd' ],
+		( 'name', 'ipaddr', 'login', 'passwd' ),
 	'fence_egenera':
-		[ 'name', 'cserver' ],
+		( 'name', 'cserver' ),
 	'fence_bullpap':
-		[ 'name', 'ipaddr', 'login', 'passwd' ],
+		( 'name', 'ipaddr', 'login', 'passwd' ),
 	'fence_xvm':
-		[ 'name' ],
+		( 'name' ),
 	'fence_scsi':
-		[ 'name' ],
+		( 'name' ),
 	'fence_ilo':
-		[ 'name', 'hostname', 'login', 'passwd' ],
+		( 'name', 'hostname', 'login', 'passwd' ),
 	'fence_ipmilan':
-		[ 'name', 'ipaddr', 'login', 'passwd', 'lanplus', 'auth' ],
+		( 'name', 'ipaddr', 'login', 'passwd', 'lanplus', 'auth' ),
 	'fence_drac':
-		[ 'name', 'ipaddr', 'login', 'passwd' ],
+		( 'name', 'ipaddr', 'login', 'passwd' ),
 	'fence_rsa':
-		[ 'name', 'hostname', 'login', 'passwd' ],
+		( 'name', 'hostname', 'login', 'passwd' ),
 	'fence_rps10':
-		[ 'name', 'device', 'port' ],
+		( 'name', 'device', 'port' ),
 	'fence_manual':
-		[ 'name' ]
+		( 'name' )
 }
--- conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/09/21 03:02:47	1.11
+++ conga/luci/site/luci/Extensions/ClusterModel/ModelBuilder.py	2007/10/03 19:40:37	1.12
@@ -347,21 +347,17 @@
   ##a separate pass, after the DOM is completely built. This method
   ##sets the agent type for each fence instance.
   def resolve_fence_instance_types(self):
-    fds = self.getFenceDevices()
     agent_hash = {}
-    for fd in fds:
-      agent = fd.getAttribute("agent")
+    for fd in self.getFenceDevices():
+      agent = fd.getAgentType()
       if agent is not None:
         agent_hash[fd.getName()] = agent
 
-    nodes = self.getNodes()
-    for node in nodes:
-      levels = node.getFenceLevels()
-      for level in levels:
-        children = level.getChildren()
-        for child in children:
+    for node in self.getNodes():
+      for level in node.getFenceLevels():
+        for child in level.getChildren():
           child.setAgentType(agent_hash[child.getName()])
-
+    
   ##This method builds RefObject containers for appropriate
   ##entities after the object tree is built.
   def resolve_references(self):
@@ -1137,40 +1133,36 @@
         self.CMAN_ptr.removeAttribute('two_node')
 
   def dual_power_fence_check(self):
-    #if 2 or more power controllers reside in the same fence level,
-    #duplicate entries must be made for every controller with an
-    #attribute for option set first for off, then for on.
-
-    #for every node:
-      #for every fence level:
-        #examine every fence
-        #If fence is of power type, add to 'found' list for that level
-        #If 'found' list is longer than 1, write out extra objs
-    nodes = self.getNodes()
-    for node in nodes:
-      levels = node.getFenceLevels()
-      for level in levels:
-        kids = level.getChildren()
-        l = list()
-        for kid in kids:
-          if kid.hasNativeOptionSet() == True:
+    # if 2 or more power controllers reside in the same fence level,
+    # duplicate entries must be made for every controller with an
+    # attribute for option set first for off, then for on.
+
+    # for every node:
+      # for every fence level:
+        # examine every fence
+        # If fence is of power type, add to 'found' list for that level
+        # If 'found' list is longer than 1, write out extra objs
+    for node in self.getNodes():
+      for level in node.getFenceLevels():
+        pc_list = list()
+        for kid in level.getChildren():
+          if kid.hasNativeOptionSet() is True:
             continue
           if kid.isPowerController() is True:
-            l.append(kid)
-        if len(l) > 1:  #Means we found multiple PCs in the same level
-          for fence in l:
-            fence.addAttribute("option", "off")
-          for fence in l:
-            if fence.getAttribute("option") == "off":
-              d = Device()
-              d.setAgentType(fence.getAgentType())
-              attrs = fence.getAttributes()
-              kees = attrs.keys()
-              for k in kees:
-                d.addAttribute(k, attrs[k])
-              d.addAttribute("option", "on")
-              level.addChild(d)
+            pc_list.append(kid)
 
+        if len(pc_list) > 1:
+          # Means we found multiple PCs in the same level
+          for fence in pc_list:
+            fence.addAttribute("option", "off")
+            d = Device()
+            d.setAgentType(fence.getAgentType())
+            attrs = fence.getAttributes()
+            for (k, v) in attrs.iteritems():
+              d.addAttribute(k, v)
+            d.addAttribute("option", "on")
+            level.addChild(d)
+        
   def purgePCDuplicates(self):
     found_one = True
     while found_one is True:


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