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

rmccabe at sourceware.org rmccabe at sourceware.org
Fri Oct 20 20:00:30 UTC 2006


CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-10-20 20:00:30

Modified files:
	luci/site/luci/Extensions: LuciSyslog.py conga_constants.py 
	                           ricci_communicator.py 

Log message:
	more debugging output

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/LuciSyslog.py.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/conga_constants.py.diff?cvsroot=cluster&r1=1.20&r2=1.21
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&r1=1.12&r2=1.13

--- conga/luci/site/luci/Extensions/LuciSyslog.py	2006/10/20 18:41:58	1.4
+++ conga/luci/site/luci/Extensions/LuciSyslog.py	2006/10/20 20:00:29	1.5
@@ -44,6 +44,14 @@
 		except:
 			raise LuciSyslogError, 'syslog private call failed'
 
+	def debug_verbose(self, msg):
+		if not LUCI_DEBUG_MODE or LUCI_DEBUG_VERBOSITY < 2 or not self.__init:
+			return
+		try:
+			syslog(LOG_DEBUG, msg)
+		except:
+			raise LuciSyslogError, 'syslog debug calle failed'
+
 	def debug(self, msg):
 		if not LUCI_DEBUG_MODE or not self.__init:
 			return
--- conga/luci/site/luci/Extensions/conga_constants.py	2006/10/20 18:41:58	1.20
+++ conga/luci/site/luci/Extensions/conga_constants.py	2006/10/20 20:00:29	1.21
@@ -115,3 +115,4 @@
 PLONE_ROOT='luci'
 
 LUCI_DEBUG_MODE = 1
+LUCI_DEBUG_VERBOSITY = 2
--- conga/luci/site/luci/Extensions/ricci_communicator.py	2006/10/20 18:41:58	1.12
+++ conga/luci/site/luci/Extensions/ricci_communicator.py	2006/10/20 20:00:29	1.13
@@ -32,6 +32,8 @@
         except Exception, e:
             raise RicciError, 'Error connecting to %s:%d: %s' \
                     % (self.__hostname, self.__port, str(e))
+        luci_log.debug_verbose('Connected to %s:%d' \
+            % (self.__hostname, self.__port))
         try:
             self.ss = ssl(sock, self.__privkey_file, self.__cert_file)
             # TODO: data transfer timeout should be much less, 
@@ -43,6 +45,12 @@
         
         # receive ricci header
         hello = self.__receive()
+        try:
+            luci_log.debug_verbose('Received header from %s: \"%s\"' \
+				% (self.__hostname, hello.toxml()))
+        except:
+            pass
+
         self.__authed = hello.firstChild.getAttribute('authenticated') == 'true'
         self.__cluname = hello.firstChild.getAttribute('clustername')
         self.__clualias = hello.firstChild.getAttribute('clusteralias')
@@ -54,21 +62,35 @@
     
     
     def hostname(self):
+        luci_log.debug_verbose('[auth %d] reported hostname = %s' \
+            % (self.__authed, self.__hostname))
         return self.__hostname
     def authed(self):
+        luci_log.debug_verbose('reported authed = %d for %s' \
+            % (self.__authed, self.__hostname))
         return self.__authed
     def system_name(self):
+        luci_log.debug_verbose('[auth %d] reported system_name = %s for %s' \
+            % (self.__authed, self.__reported_hostname, self.__hostname))
         return self.__reported_hostname
     def cluster_info(self):
+        luci_log.debug_verbose('[auth %d] reported cluster_info = (%s,%s) for %s' \
+            % (self.__authed, self.__cluname, self.__clualias, self.__hostname))
         return (self.__cluname, self.__clualias)
     def os(self):
+        luci_log.debug_verbose('[auth %d] reported system_name = %s for %s' \
+            % (self.__authed, self.__os, self.__hostname))
         return self.__os
     def dom0(self):
+        luci_log.debug_verbose('[auth %d] reported system_name = %s for %s' \
+            % (self.__authed, self.__dom0, self.__hostname))
         return self.__dom0
     
     
     def auth(self, password):
         if self.authed():
+            luci_log.debug_verbose('already authenticated to %s' \
+                % self.__hostname)
             return True
         
         # send request
@@ -83,8 +105,9 @@
         # receive response
         resp = self.__receive()
         self.__authed = resp.firstChild.getAttribute('authenticated') == 'true'
-        
-        return self.authed()
+
+        luci_log.debug_verbose('auth call returning %d' % self.__authed)
+        return self.__authed
 
 
     def unauth(self):
@@ -96,8 +119,13 @@
         self.__send(doc)
         resp = self.__receive()
 
+        luci_log.debug_verbose('trying to unauthenticate to %s' \
+            % self.__hostname)
+
         try:
             ret = resp.firstChild.getAttribute('success')
+            luci_log.debug_verbose('unauthenticate returned %s for %s' \
+                % (ret, self.__hostname))
             if ret != '0':
                 raise Exception, 'Invalid response'
         except:
@@ -109,6 +137,12 @@
 
 
     def process_batch(self, batch_xml, async=False):
+        try:
+            luci_log.debug_verbose('auth=%d to %s for batch %s [async=%d]' \
+                % (self.__authed, self.__hostname, batch_xml.toxml(), async))
+        except:
+            pass
+
         if not self.authed():
             raise RicciError, 'not authenticated to host %s', self.__hostname
         
@@ -137,7 +171,14 @@
         
         # receive response
         doc = self.__receive()
+        try:
+            luci_log.debug_verbose('received from %s XML \"%s\"' \
+                % (self.__hostname, doc.toxml()))
+        except:
+            pass
+ 
         if doc.firstChild.getAttribute('success') != '0':
+            luci_log.debug_verbose('batch command failed')
             raise RicciError, 'The last ricci command to host %s failed' \
                     % self.__hostname
         
@@ -147,6 +188,7 @@
                 if node.nodeName == 'batch':
                     batch_node = node.cloneNode(True)
         if batch_node == None:
+            luci_log.debug_verbose('batch node missing <batch/>')
             raise RicciError, 'missing <batch/> in ricci\'s response from %s' \
                     % self.__hostname
 
@@ -155,6 +197,8 @@
     def batch_run(self, batch_str, async=True):
         try:
             batch_xml_str = '<?xml version="1.0" ?><batch>' + batch_str + '</batch>'
+            luci_log.debug_verbose('attempting batch \"%s\" for host %s' \
+                % (batch_xml_str, self.__hostname))
             batch_xml = minidom.parseString(batch_xml_str).firstChild
         except Exception, e:
             luci_log.debug('received invalid batch XML for %s: \"%s\"' \
@@ -163,6 +207,11 @@
 
         try:
             ricci_xml = self.process_batch(batch_xml, async)
+            try:
+                luci_log.debug_verbose('received XML \"%s\" from host %s in response to batch command.' \
+                    % (ricci_xml.toxml(), self.__hostname))
+            except:
+                pass
         except:
             luci_log.debug('An error occurred while trying to process the batch job: %s' % batch_xml_str)
             return None
@@ -170,6 +219,9 @@
         return ricci_xml
 
     def batch_report(self, batch_id):
+        luci_log.debug_verbose('[auth=%d] asking for batchid# %d for host %s' \
+            % (self.__authed, batch_id, self.__hostname))
+
         if not self.authed():
             raise RicciError, 'Not authenticated to host %s' % self.__hostname
         
@@ -215,6 +267,8 @@
                 raise RicciError, 'write error while sending XML to host %s' \
                         % self.__hostname
             buff = buff[pos:]
+        luci_log.debug_verbose('Sent XML \"%s\" to host %s' \
+            % (buff, self.__hostname))
         return
     
     def __receive(self):
@@ -237,6 +291,8 @@
                 % (self.__hostname, str(e)))
             raise RicciError, 'Error reading data from host %s' \
                     % self.__hostname
+        luci_log.debug_verbose('Received XML \"%s\" from host %s' \
+            % (xml_in, self.__hostname))
 
         try:
             if doc == None:
@@ -321,7 +377,12 @@
 #             module (-num) failed (next module won't be processed)
 def batch_status(batch_xml):
     if batch_xml.nodeName != 'batch':
-        raise 'not a batch'
+        try:
+            luci_log.debug('Expecting an XML batch node. Got \"%s\"' \
+                % batch_xml.toxml())
+        except:
+            pass
+        raise RicciError, 'Not an XML batch node'
     total = 0
     last  = 0
     for node in batch_xml.childNodes:
@@ -336,6 +397,12 @@
                     # failure
                     last = last + 1
                     last = last - 2 * last
+    try:
+        luci_log.debug_verbose('Returning (%s, %s) for batch_status(\"%s\")' \
+            % (last, total, batch_xml.toxml()))
+    except:
+        pass
+
     return (last, total)
 
 




More information about the Cluster-devel mailing list