added some new cr
[monitor.git] / findbadpcu.py
index 0e06e17..c7dc9d4 100755 (executable)
@@ -61,6 +61,7 @@ externalState = {'round': round, 'nodes': {'a': None}}
 count = 0
 
 import reboot
+from reboot import pcu_name
 
 import soltesz
 import plc
@@ -68,14 +69,6 @@ import comon
 import threadpool
 import syncplcdb
 
-def pcu_name(pcu):
-       if pcu['hostname'] is not None and pcu['hostname'] is not "":
-               return pcu['hostname']
-       elif pcu['ip'] is not None and pcu['ip'] is not "":
-               return pcu['ip']
-       else:
-               return None
-
 def nmap_portstatus(status):
        ps = {}
        l_nmap = status.split()
@@ -355,7 +348,7 @@ def recordPingAndSSH(request, result):
 
                count += 1
                print "%d %s %s" % (count, nodename, externalState['nodes'][pcu_id]['values'])
-               soltesz.dbDump(config.dbname, externalState, 'php')
+               soltesz.dbDump(config.dbname, externalState)
 
 # this will be called when an exception occurs within a thread
 def handle_exception(request, result):
@@ -409,7 +402,7 @@ def checkAndRecordState(l_pcus, cohash):
 def main():
        global externalState
 
-       externalState = soltesz.if_cached_else(1, config.dbname, lambda : externalState, 'php'
+       externalState = soltesz.if_cached_else(1, config.dbname, lambda : externalState) 
        cohash = {}
 
        if config.increment:
@@ -419,7 +412,7 @@ def main():
        if config.filename == "":
                print "Calling API GetPCUs() : refresh(%s)" % config.refresh
                l_pcus = soltesz.if_cached_else_refresh(1, 
-                                                               config.refresh, "pculist", lambda : plc.GetPCUs(), 'php')
+                                                               config.refresh, "pculist", lambda : plc.GetPCUs())
                l_pcus  = [pcu['pcu_id'] for pcu in l_pcus]
        else:
                l_pcus = config.getListFromFile(config.filename)
@@ -450,5 +443,5 @@ if __name__ == '__main__':
        except Exception, err:
                print "Exception: %s" % err
                print "Saving data... exitting."
-               soltesz.dbDump(config.dbname, externalState, 'php')
+               soltesz.dbDump(config.dbname, externalState)
                sys.exit(0)