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

[Cluster-devel] conga/luci/site/luci/Extensions ricci_bridge.py



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2006-11-20 23:30:18

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

Log message:
	return either true, false or none, depending on whether the node is virtual, not virtual, or we're unable to determine whether it's virtual, respectively

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

--- conga/luci/site/luci/Extensions/ricci_bridge.py	2006/11/20 23:10:57	1.45
+++ conga/luci/site/luci/Extensions/ricci_bridge.py	2006/11/20 23:30:17	1.46
@@ -508,9 +508,38 @@
 
 	ricci_xml = rc.batch_run(batch_str, async=False)
 	if not ricci_xml or not ricci_xml.firstChild:
-		luci_log.debug_verbose('no ricci_xml in nodeIsVirtual')
+		luci_log.debug_verbose('nodeIsVirtual0: None returned')
 		return None
-	return ricci_xml.firstChild
+
+	var_tags = ricci_xml.getElementsByTagName('var')
+	if not var_tags or len(var_tags) < 2:
+		luci_log.debug_verbose('nodeIsVirtual1: unexpected response %s' \
+			% ricci_xml.toxml())
+		return None
+
+	success = False
+	virtual = False
+	for i in var_tags:
+		try:
+			name = i.getAttribute('name')
+			if not name:
+				raise Exception, 'name is blank'
+			if name == 'success':
+				result = i.getAttribute('value')
+				if result == 'true':
+					success = True
+			elif name == 'virt_guest':
+				result = i.getAttribute('value')
+				if result == 'true':
+					virtual = True
+			else:
+				raise Exception, 'unexpected attribute name: %s' % name
+		except Exception, e:
+			luci_log.debug_verbose('nodeIsVirtual2: error: %s' % str(e))
+
+	if not success:
+		return None
+	return virtual
 
 def getDaemonStates(rc, dlist):
 	batch_str = '<module name="service"><request API_version="1.0"><function_call name="query"><var mutable="false" name="search" type="list_xml">'


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