www/printbadnodes.py
[monitor.git] / sitebad.py
index eccaa28..f55a4d3 100755 (executable)
@@ -6,17 +6,16 @@ import string
 import time
 
 
-import soltesz
+import database
 import comon
 import threadpool
 import syncplcdb
 from nodequery import verify,query_to_dict,node_select
 
 import plc
-import auth
-api = plc.PLC(auth.auth, auth.plc)
+api = plc.getAuthAPI()
 from unified_model import *
-from monitor_policy import MINUP
+from const import MINUP
 
 round = 1
 externalState = {'round': round, 'sites': {}}
@@ -24,13 +23,13 @@ count = 0
 
 def main(config):
        global externalState
-       externalState = soltesz.if_cached_else(1, config.dbname, lambda : externalState) 
+       externalState = database.if_cached_else(1, config.dbname, lambda : externalState) 
        if config.increment:
                # update global round number to force refreshes across all nodes
                externalState['round'] += 1
 
        l_nodes = syncplcdb.create_plcdb()
-       l_plcsites = soltesz.dbLoad("l_plcsites")
+       l_plcsites = database.dbLoad("l_plcsites")
 
        if config.site:
                l_sites = [config.site]
@@ -59,12 +58,12 @@ def checkAndRecordState(l_sites, l_plcsites):
                        count += 1
 
                if count % 20 == 0:
-                       soltesz.dbDump(config.dbname, externalState)
+                       database.dbDump(config.dbname, externalState)
 
-       soltesz.dbDump(config.dbname, externalState)
+       database.dbDump(config.dbname, externalState)
 
-fb = soltesz.dbLoad('findbad')
-lb2hn = soltesz.dbLoad("plcdb_lb2hn")
+fb = database.dbLoad('findbad')
+lb2hn = database.dbLoad("plcdb_lb2hn")
 
 def getnodesup(nodelist):
        up = 0
@@ -120,9 +119,9 @@ def collectStatusAndState(sitename, l_plcsites):
        return True
 
 if __name__ == '__main__':
-       from config import config
-       from optparse import OptionParser
-       parser = OptionParser()
+       import parser as parsermodule
+
+       parser = parsermodule.getParser()
        parser.set_defaults(filename=None, node=None, site=None, nodeselect=False, nodegroup=None, 
                                                increment=False, dbname="sitebad", cachenodes=False)
        parser.add_option("", "--site", dest="site", metavar="login_base", 
@@ -134,8 +133,7 @@ if __name__ == '__main__':
                                                help="Specify the name of the database to which the information is saved")
        parser.add_option("-i", "--increment", action="store_true", dest="increment", 
                                                help="Increment round number to force refresh or retry")
-       config = config(parser)
-       config.parse_args()
+       config = parsermodule.parse_args(parser)
 
        try:
                main(config)
@@ -144,5 +142,5 @@ if __name__ == '__main__':
                print traceback.print_exc()
                print "Exception: %s" % err
                print "Saving data... exitting."
-               soltesz.dbDump(config.dbname, externalState)
+               database.dbDump(config.dbname, externalState)
                sys.exit(0)