[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
Branch: 	RHEL5
Changes by:	jparsons sourceware org	2006-11-30 20:12:38

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

Log message:
	Fix for quorumd cluster props, part of bug #212021

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

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/20 23:32:43	1.120.2.11
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/11/30 20:12:38	1.120.2.12
@@ -18,10 +18,11 @@
 from Vm import Vm
 from Script import Script
 from Samba import Samba
+from QuorumD import QuorumD
+from Heuristic import Heuristic
 from clusterOS import resolveOSType
 from FenceHandler import FenceHandler, FENCE_OPTS
 from GeneralError import GeneralError
-from UnknownClusterError import UnknownClusterError
 from homebase_adapters import nodeUnauth, nodeAuth, manageCluster, createClusterSystems, havePermCreateCluster, setNodeFlag, delNodeFlag, userAuthenticated, getStorageNode, getClusterNode
 from LuciSyslog import LuciSyslog
 
@@ -588,8 +589,9 @@
 	except ValueError, e:
 		errors.append('An invalid Minimum Score value was given: %s' % str(e))
 
-  device = None
-  label = None  #Either device or label must be present
+	#Either device or label must be present
+	device = None
+	label = None
 	try:
 		device = form['device'].strip()
 		label = form['label'].strip()
@@ -652,26 +654,31 @@
 	if len(errors) > 0:
 		return (False, {'errors': errors })
 
-  qd = QuorumD()
-  qd.addAttribute('interval', interval)
-  qd.addAttribute('votes', votes)
-  qd.addAttribute('tko', tko)
-  qd.addAttribute('min_score', min_score)
-  if device:
-    qd.addAttribute('device', device)
-  else:
-    qd.addAttribute('label', label)
-  cp = model.getClusterPtr()
-  cp.addChild(qd)
+	qd = QuorumD()
+	qd.addAttribute('interval', interval)
+	qd.addAttribute('votes', votes)
+	qd.addAttribute('tko', tko)
+	qd.addAttribute('min_score', min_score)
+
+	if device:
+		qd.addAttribute('device', device)
+	else:
+		qd.addAttribute('label', label)
 
-  for h in heuristics:
-    new_h = Heuristic()
-    new_h.addAttribute('program', h[1])
-    new_h.addAttribute('interval', h[2])
-    new_h.addAttribute('score', h[3])
-    qd.addChild(new_h)
+	cp = model.getClusterPtr()
+	cp.addChild(qd)
 
-	return (True, {'messages': ['Changes accepted. - FILL ME IN']})
+	for h in heuristics:
+		new_h = Heuristic()
+		new_h.addAttribute('program', h[1])
+		new_h.addAttribute('interval', h[2])
+		new_h.addAttribute('score', h[3])
+		qd.addChild(new_h)
+
+	if len(errors) > 0:
+		return (False, {'errors': errors })
+
+	return (True, {})
 
 def validateGeneralConfig(model, form):
 	errors = list()
@@ -1018,7 +1025,7 @@
 
   try:
     pagetype = request[PAGETYPE]
-  except KeyError, e:
+  except:
     pagetype = '3'
 
 
@@ -1113,7 +1120,7 @@
 
   try:
     url = request['URL']
-  except KeyError, e:
+  except:
     url = "/luci/cluster/index_html"
 
   #The only way this method can run is if there exists
@@ -2811,8 +2818,13 @@
       svclist.append(thing)
 
   #Get cluster name and node name from request
-  clustername = request['clustername']
-  nodename = request['nodename']
+  try:
+    clustername = request['clustername']
+    nodename = request['nodename']
+  except Exception, e:
+    luci_log.debug_verbose('getNodeInfo0: %s' % str(e))
+    return {}
+
   #extract correct node line from cluster status
   found = False
   for item in status:
@@ -2820,7 +2832,9 @@
       found = True
       break
   if found == False:
-    raise UnknownClusterError("Fatal", "Unable to resolve node name in cluster status")
+    luci_log.debug_verbose('getNodeInfo1: Unable to resolve node name in cluster status')
+    return {}
+
   #Now determine state of node...
   if item['online'] == "false":
     nodestate = NODE_UNKNOWN
@@ -3047,8 +3061,21 @@
   raise
   
 def getFenceInfo(self, model, request):
-  clustername = request['clustername']
-  baseurl = request['URL']
+  try:
+    clustername = request['clustername']
+  except:
+    try:
+      clustername = request.form['clustername']
+    except:
+      luci_log.debug_verbose('getFenceInfo0: unable to determine cluster name')
+      return {}
+
+  try:
+    baseurl = request['URL']
+  except Exception, e:
+    luci_log.debug_verbose('getFenceInfo1: no request.URL')
+    return {}
+
   map = {}
   level1 = list() #First level fence devices
   level2 = list() #Second level fence devices
@@ -3064,8 +3091,13 @@
 
   try:
     nodename = request['nodename']
-  except KeyError, e:
-    raise GeneralError('FATAL', "Could not extract nodename from request")
+  except:
+    try:
+      nodename = request.form['nodename']
+    except:
+      luci_log.debug_verbose('getFenceInfo2: unable to extract nodename: %s' \
+          % str(e))
+      return {}
     
   #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
@@ -3075,7 +3107,8 @@
   try:
     node = model.retrieveNodeByName(nodename)
   except GeneralError, e:
-    raise GeneralError('FATAL', "Couldn't find node name in current node list")
+    luci_log.debug_verbose('getFenceInfo3: unabel to find node name %s in current node list' % (str(nodename), str(e)))
+    return {}
 
   fds = model.getFenceDevices()
 
@@ -3160,9 +3193,9 @@
             level1.append(fencedev)
             last_kid_fd = fd
             continue
+    map['level1'] = level1
 
     #level1 list is complete now, but it is still necessary to build shared1
-    sharednames = list()
     for fd in fds:
       isUnique = True
       if fd.isShared() == False:
@@ -3178,6 +3211,7 @@
         shared_struct['agent'] = agentname
         shared_struct['prettyname'] = FENCE_OPTS[agentname]
         shared1.append(shared_struct)
+    map['shared1'] = shared1
 
   #YUK: This next section violates the DRY rule, :-(
   if len_levels >= 2:
@@ -3254,9 +3288,9 @@
             level2.append(fencedev)
             last_kid_fd = fd
             continue
+    map['level2'] = level2
 
     #level2 list is complete but like above, we need to build shared2
-    sharednames = list()
     for fd in fds:
       isUnique = True
       if fd.isShared() == False:
@@ -3272,6 +3306,7 @@
         shared_struct['agent'] = agentname
         shared_struct['prettyname'] = FENCE_OPTS[agentname]
         shared2.append(shared_struct)
+    map['shared2'] = shared2
 
   return map    
       
@@ -3280,7 +3315,7 @@
   baseurl = request['URL']
   map = {}
   fencedevs = list() #This is for the fencedev list page
-  map['fencedevs'] = fencedevs
+
   #Get list of fence devices
   fds = model.getFenceDevices()
   nodes_used = list() #This section determines which nodes use the dev
@@ -3296,6 +3331,7 @@
         fencedev['pretty_name'] = FENCE_OPTS[fd.getAgentType()]
       except:
         fencedev['pretty_name'] = fd.getAgentType()
+      fencedev['agent'] = fd.getAgentType()
       #Add config url for this fencedev
       fencedev['cfgurl'] = baseurl + "?clustername=" + clustername + "&fencename=" + fd.getName().strip() + "&pagetype=" + FENCEDEV
 
@@ -3320,7 +3356,8 @@
 
       fencedev['nodesused'] = nodes_used
       fencedevs.append(fencedev)
-    
+
+  map['fencedevs'] = fencedevs
   return map
 
     


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