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

rmccabe at sourceware.org rmccabe at sourceware.org
Tue Oct 31 17:18:14 UTC 2006


CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe at sourceware.org	2006-10-31 17:18:14

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

Log message:
	fix node flags brokenness

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/cluster_adapters.py.diff?cvsroot=cluster&r1=1.134&r2=1.135
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/luci/site/luci/Extensions/ricci_communicator.py.diff?cvsroot=cluster&r1=1.15&r2=1.16

--- conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/31 00:16:14	1.134
+++ conga/luci/site/luci/Extensions/cluster_adapters.py	2006/10/31 17:18:12	1.135
@@ -2898,31 +2898,35 @@
       try:
         cluname = req.form['clusterName']
       except:
-        luci_log.debug_verbose('No cluster name -- returning empty map')
+        luci_log.debug_verbose('ICB0: No cluster name -- returning empty map')
         return map
 
-  path = CLUSTER_FOLDER_PATH + cluname
+  path = str(CLUSTER_FOLDER_PATH + cluname)
   try:
-    clusterfolder = self.restrictedTraverse(str(path))
+    clusterfolder = self.restrictedTraverse(path)
     if not clusterfolder:
       raise Exception, 'clusterfolder is None'
   except Exception, e:
-    luci_log.debug_verbose('cluster %s [%s] folder missing: %s -- returning empty map' % (cluname, path, str(e)))
+    luci_log.debug_verbose('ICB1: cluster %s [%s] folder missing: %s -- returning empty map' % (cluname, path, str(e)))
     return map
   except:
-    luci_log.debug_verbose('cluster %s [%s] folder missing: returning empty map' % (cluname, path))
+    luci_log.debug_verbose('ICB2: cluster %s [%s] folder missing: returning empty map' % (cluname, path))
 
   try:
     items = clusterfolder.objectItems('ManagedSystem')
     if not items or len(items) < 1:
+      luci_log.debug_verbose('ICB3: no flags at %s for cluster %s' \
+          % (cluname, path))
       return map  #This returns an empty map, and should indicate not busy
   except Exception, e:
-    luci_log.debug('An error occurred while looking for cluster %s flags at path %s: %s' % (cluname, path, str(e)))
+    luci_log.debug('ICB4: An error occurred while looking for cluster %s flags at path %s: %s' % (cluname, path, str(e)))
     return map
   except:
-    luci_log.debug('An error occurred while looking for cluster %s flags at path %s' % (cluname, path))
+    luci_log.debug('ICB5: An error occurred while looking for cluster %s flags at path %s' % (cluname, path))
     return map
-    
+
+  luci_log.debug_verbose('ICB6: isClusterBusy: %s is busy: %d flags' \
+      % (cluname, len(items)))
   map['busy'] = "true"
   #Ok, here is what is going on...if there is an item,
   #we need to call the ricci_bridge and get a batch report.
@@ -2952,31 +2956,58 @@
       batch_xml = None
       ricci = item[0].split("____") #This removes the 'flag' suffix
 
+      luci_log.debug_verbose('ICB6A: using host %s for rc for item %s' \
+          % (ricci[0], item[0]))
       try:
         rc = RicciCommunicator(ricci[0])
+        if not rc:
+          rc = None
+          raise RicciError, 'rc is None for %s' % ricci[0]
       except RicciError, e:
         rc = None
-        luci_log.debug_verbose('ricci returned error in iCB for %s: %s' \
+        luci_log.debug_verbose('ICB7: ricci returned error in iCB for %s: %s' \
           % (cluname, str(e)))
       except:
         rc = None
-        luci_log.info('ricci connection failed for cluster %s' % cluname)
+        luci_log.info('ICB8: ricci connection failed for cluster %s' % cluname)
 
+      batch_id = None
       if rc is not None:
         try:
-          batch_xml = rc.batch_report(item[1].getProperty(BATCH_ID))
-          if batch_xml != None:
-            (creation_status, total) = batch_status(batch_xml)
-          else:
-            luci_log.debug_verbose('batch report for cluster %s, item %s is None' % (cluname, item[0]))
-        except:
-          creation_status = RICCI_CONNECT_FAILURE  #No contact with ricci (-1000)
-          batch_xml = "bloody_failure" #set to avoid next if statement
-      else:
+          batch_id = item[1].getProperty(BATCH_ID)
+          luci_log.debug_verbose('ICB8A: got batch_id %s from %s' \
+              % (batch_id, item[0]))
+        except Exception, e:
+          try:
+            luci_log.debug_verbose('ICB8B: failed to get batch_id from %s: %s' \
+                % (item[0], str(e)))
+          except:
+            luci_log.debug_verbose('ICB8C: failed to get batch_id from %s' % item[0])
+
+        if batch_id is not None:
+          try:
+            batch_xml = rc.batch_report(batch_id)
+            if batch_xml is not None:
+              luci_log.debug_verbose('ICB8D: batch_xml for %s from batch_report is not None -- getting batch status' % batch_id)
+              (creation_status, total) = batch_status(batch_xml)
+              try:
+                luci_log.debug_verbose('ICB8E: batch status returned (%d,%d)' \
+                    % (creation_status, total))
+              except:
+                luci_log.debug_verbose('ICB8F: error logging batch status return')
+            else:
+              luci_log.debug_verbose('ICB9: batch_xml for cluster is None')
+          except Exception, e:
+            luci_log.debug_verbose('ICB9A: error getting batch_xml from rc.batch_report: %s' % str(e))
+            creation_status = RICCI_CONNECT_FAILURE  #No contact with ricci (-1000)
+            batch_xml = "bloody_failure" #set to avoid next if statement
+
+      if rc is None or batch_id is None:
+          luci_log.debug_verbose('ICB12: unable to connect to a ricci agent for cluster %s to get batch status')
           creation_status = RICCI_CONNECT_FAILURE  #No contact with ricci (-1000)
-          batch_xml = "bloody_failure" #set to avoid next if statement
+          batch_xml = "bloody_bloody_failure" #set to avoid next if statement
 
-      if batch_xml == None:  #The job is done and gone from queue
+      if batch_xml is None:  #The job is done and gone from queue
         if redirect_message == False: #We have not displayed this message yet
           node_report['desc'] = REDIRECT_MSG
           node_report['iserror'] = True 
@@ -2984,7 +3015,7 @@
           nodereports.append(node_report)
           redirect_message = True
 
-        luci_log.debug_verbose('batch job is done -- deleting %s' % item[0])
+        luci_log.debug_verbose('ICB13: batch job is done -- deleting %s' % item[0])
         clusterfolder.manage_delObjects(item[0])
         continue
 
@@ -3038,7 +3069,7 @@
           try:
               clusterfolder.manage_delObjects(item[0])
           except Exception, e:
-              luci_log.info('Unable to delete %s: %s' % (item[0], str(e)))
+              luci_log.info('ICB14: Unable to delete %s: %s' % (item[0], str(e)))
           continue
         else:
           map['busy'] = "true"
--- conga/luci/site/luci/Extensions/ricci_communicator.py	2006/10/31 13:16:30	1.15
+++ conga/luci/site/luci/Extensions/ricci_communicator.py	2006/10/31 17:18:12	1.16
@@ -221,7 +221,7 @@
         return doc
 
     def batch_report(self, batch_id):
-        luci_log.debug_verbose('[auth=%d] asking for batchid# %d for host %s' \
+        luci_log.debug_verbose('[auth=%d] asking for batchid# %s for host %s' \
             % (self.__authed, batch_id, self.__hostname))
 
         if not self.authed():
@@ -244,7 +244,7 @@
         if doc.firstChild.getAttribute('success') == '12':
             return None
         if doc.firstChild.getAttribute('success') != '0':
-            raise RicciError, 'Error while retrieving batch report for batch #%s from host %s' % (batch_id, self.__hostname)
+            raise RicciError, 'Error while retrieving batch report for batch #%d from host %s' % (batch_id, self.__hostname)
         batch_node = None
         for node in doc.firstChild.childNodes:
             if node.nodeType == xml.dom.Node.ELEMENT_NODE:
@@ -403,10 +403,10 @@
                     last = last + 1
                     last = last - 2 * last
     try:
-        luci_log.debug_verbose('Returning (%s, %s) for batch_status(\"%s\")' \
+        luci_log.debug_verbose('Returning (%d, %d) for batch_status(\"%s\")' \
             % (last, total, batch_xml.toxml()))
     except:
-        pass
+        luci_log.debug_verbose('Returning last, total')
 
     return (last, total)
 




More information about the Cluster-devel mailing list