remove a lot of deprecated files ;
authorStephen Soltesz <soltesz@cs.princeton.edu>
Sat, 21 Nov 2009 01:38:00 +0000 (01:38 +0000)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Sat, 21 Nov 2009 01:38:00 +0000 (01:38 +0000)
move non-user or setup scripts to extra/ directory

29 files changed:
Monitor.spec
automate-default.sh
config.d/init-bootman-sequence.py [moved from init-bootman-sequence.py with 100% similarity]
dumpact.py [deleted file]
dumpdiag.py [deleted file]
extra/nodeaction.py [moved from nodeaction.py with 100% similarity]
extra/nodediff.py [moved from nodediff.py with 100% similarity]
extra/nodehistory.py [moved from nodehistory.py with 100% similarity]
extra/nodesets.py [moved from nodesets.py with 100% similarity]
extra/pcutest.py [moved from pcutest.py with 100% similarity]
extra/pkl2php.py [moved from pkl2php.py with 100% similarity]
extra/prep_power_users.py [moved from prep_power_users.py with 100% similarity]
extra/printpdb.py [moved from printpdb.py with 100% similarity]
extra/showlatlon.py [moved from showlatlon.py with 100% similarity]
extra/template.py [moved from template.py with 100% similarity]
get_metasite_nodes.py [deleted file]
getconf.py [deleted file]
getnodekey.py [deleted file]
getnodes.py [deleted file]
mailmonitor.py [deleted file]
monitor-server.init
nodegroups.py
phpconfig.py [deleted file]
plctool.py [deleted file]
printbadcsv.py [deleted file]
setup-agent.sh
statistics/rtinfo.py [moved from rtinfo.py with 100% similarity]
tests/test-myops-xmlrpc.py [moved from test-myops-xmlrpc.py with 100% similarity]
ticket_blacklist.py [deleted file]

index 806865b..b8e2d31 100644 (file)
@@ -276,7 +276,6 @@ fi
 # TODO: this will be nice when we have a web-based service running., such as
 #              an API server or so on.
 # TODO: create real monitorconfig.py from monitorconfig-default.py
-# TODO: create monitorconfig.php using phpconfig.py 
 # TODO: create symlink in /var/lib/monitor for chroot environments
 # TODO: update the content of automate_pl03.sh 
 # TODO: Use the installed version of bootcd to create custom boot images. ( or, use the api now).
index 3e65fcf..c0b4b7b 100755 (executable)
@@ -4,7 +4,6 @@ export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
 # NOTE: Must be an absolute path to guarantee it is read.
 INSTALLPATH=/usr/share/monitor/
-# Generate an 'sh' style file full of variables in monitor.conf
 $INSTALLPATH/shconfig.py >  $INSTALLPATH/monitorconfig.sh
 source $INSTALLPATH/monitorconfig.sh
 cd ${MONITOR_SCRIPT_ROOT}
diff --git a/dumpact.py b/dumpact.py
deleted file mode 100755 (executable)
index 713970c..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-#!/usr/bin/python
-
-# Read in the act_* databases and print out a human readable version
-
-import sys
-import time
-import getopt
-import database 
-from monitor.wrapper import plccache
-
-def main():
-
-       act_all = database.dbLoad(sys.argv[1])
-       plcdb_hn2lb = plccache.plcdb_hn2lb
-       s_nodenames = ""
-       sickdb = {}
-
-       sorted_keys = act_all.keys()
-       sorted_keys.sort()
-       for nodename in sorted_keys:
-               diag_nodelist = act_all[nodename]
-               if nodename in plcdb_hn2lb:
-                       lb = plcdb_hn2lb[nodename]
-                       if lb not in sickdb:
-                               sickdb[lb] = {}
-                       sickdb[lb][nodename] = diag_nodelist
-
-       sorted_keys = sickdb.keys()
-       sorted_keys.sort()
-       for loginbase in sorted_keys:
-               nodedict = sickdb[loginbase]
-               sort_nodekeys = nodedict.keys()
-               sort_nodekeys.sort()
-               print "%s :" % loginbase
-               for nodename in sort_nodekeys:
-                       if len(act_all[nodename]) == 0:
-                               print "%20s : %-40s has no events" % (loginbase, nodename)
-                       else:
-                               l_ev = act_all[nodename]
-                               print "    %s" % nodename
-                               for diag_node in l_ev:
-                                       keys = diag_node.keys()
-                                       keys.sort()
-                                       for k in keys:
-                                               if "message" not in k and "msg" not in k:
-                                                       if 'time' in k:
-                                                               s_time=time.strftime("%Y/%m/%d %H:%M:%S", time.gmtime(diag_node[k]))
-                                                               print "\t'%s' : %s" % (k, s_time)
-                                                       else:
-                                                               print "\t'%s' : %s" % (k, diag_node[k])
-                                       print "\t--"
-
-       print s_nodenames
-
-       
-if __name__ == '__main__':
-       main()
diff --git a/dumpdiag.py b/dumpdiag.py
deleted file mode 100755 (executable)
index 4e38459..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/python
-
-# Read in the act_* databases and print out a human readable version
-
-import sys
-import time
-import getopt
-import database 
-from monitor.wrapper import plccache
-
-def main():
-
-       sickdb = database.dbLoad(sys.argv[1])
-       plcdb_hn2lb = plccache.plcdb_hn2lb
-       s_nodenames = ""
-
-       sorted_keys = sickdb.keys()
-       sorted_keys.sort()
-       print "anything"
-       print len(sorted_keys)
-       for loginbase in sorted_keys:
-               print loginbase
-               nodedict = sickdb[loginbase]['nodes']
-               sort_nodekeys = nodedict.keys()
-               sort_nodekeys.sort()
-               print "%s :" % loginbase
-               for nodename in sort_nodekeys:
-                       diag_node = sickdb[loginbase]['nodes'][nodename]
-                       keys = diag_node.keys()
-                       keys.sort()
-                       print nodename
-                       for k in keys:
-                               #print k
-                               if "message" not in k and "msg" not in k:
-                                       print "\t'%s' : %s" % (k, diag_node[k])
-                       print "\t--"
-
-       print s_nodenames
-
-       
-if __name__ == '__main__':
-       main()
similarity index 100%
rename from nodeaction.py
rename to extra/nodeaction.py
similarity index 100%
rename from nodediff.py
rename to extra/nodediff.py
similarity index 100%
rename from nodehistory.py
rename to extra/nodehistory.py
similarity index 100%
rename from nodesets.py
rename to extra/nodesets.py
similarity index 100%
rename from pcutest.py
rename to extra/pcutest.py
similarity index 100%
rename from pkl2php.py
rename to extra/pkl2php.py
similarity index 100%
rename from printpdb.py
rename to extra/printpdb.py
similarity index 100%
rename from showlatlon.py
rename to extra/showlatlon.py
similarity index 100%
rename from template.py
rename to extra/template.py
diff --git a/get_metasite_nodes.py b/get_metasite_nodes.py
deleted file mode 100755 (executable)
index e2d5764..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/python
-import plc
-import database
-import string
-import sys
-
-def main():
-       meta_sites = ['canarie', 'rnp', 'jgn2', 'i2', 'tp', 'princeton', 'princetondsl', 'plcolo', 'wide']
-       l_blacklist = [ "grouse.hpl.hp.com", "planet1.att.nodes.planet-lab.org"]
-       l_sitelist = []
-       count = 0
-       # for each prefix above
-       for pre_loginbase in meta_sites:
-               print "getting sites from base %s*" % pre_loginbase
-               search_sites  = plc.getSites({'login_base' : pre_loginbase + "*"})
-               # for each of the sites that begin with this prefix
-               for site in search_sites:
-                       # get the nodes for that site
-                       l_sitelist.append(site['login_base'])
-                       print "%s : " % site['login_base']
-                       nodes = plc.getSiteNodes2(site['login_base'])
-                       for node in nodes:
-                               hn = node['hostname']
-                               if hn not in l_blacklist:
-                                       print "\t%s" % hn
-                                       count += 1
-                                       # add the nodes to the blacklist
-                                       l_blacklist.append(hn)
-                               #else:
-                               #       print "not adding %s" % hn
-       print string.join(l_sitelist,  ",")
-       print "Found %d nodes" % count
-       print "Found %d sites " % len(l_sitelist)
-
-
-if __name__=="__main__":
-       main() 
diff --git a/getconf.py b/getconf.py
deleted file mode 100755 (executable)
index ad8f9a7..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-#!/usr/bin/python
-
-from monitor.wrapper import plc
-from monitor import config
-import monitor.parser as parsermodule
-api = plc.getAuthAPI()
-import sys
-import os
-
-def getconf(hostname, force=False, media=None):
-       n = api.GetNodes(hostname)
-       filename = "bootcd/" + hostname + ".txt"
-       if not os.path.exists(filename) or force:
-               f = open("bootcd/" + hostname + ".txt", 'w')
-               f.write( api.AdmGenerateNodeConfFile(n[0]['node_id']) )
-               f.close()
-               print os.system("cd bootcd; ./build.sh -f %s.txt -t iso -o /plc/data/var/www/html/bootcds/%s.iso &> /dev/null" % ( hostname, hostname))
-               print "cd bootcd; ./build.sh -f %s.txt -t usb_partition -o /plc/data/var/www/html/bootcds/%s-partition.usb &> /dev/null" % ( hostname, hostname)
-               print os.system("cd bootcd; ./build.sh -f %s.txt -t usb_partition -o /plc/data/var/www/html/bootcds/%s-partition.usb &> /dev/null" % ( hostname, hostname))
-       else:
-               #print os.system("cd bootcd; ./build.sh -f %s.txt -t iso -o /plc/data/var/www/html/bootcds/%s.iso &> /dev/null" % ( hostname, hostname))
-               print "cd bootcd; ./build.sh -f %s.txt -t usb_partition -o /plc/data/var/www/html/bootcds/%s-partition.usb &> /dev/null" % ( hostname, hostname)
-               #print os.system("cd bootcd; ./build.sh -f %s.txt -t usb_partition -o /plc/data/var/www/html/bootcds/%s-partition.usb &> /dev/null" % ( hostname, hostname))
-               # assume that the images have already been generated..
-               pass
-
-       args = {}
-       if not media:
-               args['url_list']  = "   http://%s/bootcds/%s-partition.usb\n" % (config.MONITOR_HOSTNAME, hostname)
-               args['url_list'] += "   http://%s/bootcds/%s.iso" % (config.MONITOR_HOSTNAME, hostname)
-       else:
-               if media == "usb":
-                       args['url_list']  = "   http://%s/bootcds/%s-partition.usb\n" % (config.MONITOR_HOSTNAME, hostname)
-               elif media == "iso":
-                       args['url_list']  = "   http://%s/bootcds/%s.iso" % (config.MONITOR_HOSTNAME, hostname)
-               else:
-                       args['url_list']  = "   http://%s/bootcds/%s-partition.usb\n" % (config.MONITOR_HOSTNAME, hostname)
-                       args['url_list'] += "   http://%s/bootcds/%s.iso" % (config.MONITOR_HOSTNAME, hostname)
-                       
-
-       return args
-
-if __name__ == '__main__':
-       parser = parsermodule.getParser()
-       parser.set_defaults(media='both', force=False)
-       parser.add_option("", "--media", dest="media", metavar="usb, iso, both", 
-                                               help="""Which media to generate the message for.""")
-       parser.add_option("", "--force", dest="force", action="store_true", 
-                                               help="""Force the recreation of the usb images.""")
-       parser = parsermodule.getParser(['defaults'], parser)
-
-       config = parsermodule.parse_args(parser)
-
-       ret = {'url_list' : ''} 
-       for i in config.args:
-               conf = getconf(i, config.force, config.media)
-               ret['url_list'] += conf['url_list']
-               ret['hostname'] = i
-
-       if config.media == "both":
-               print """
-Hello,
-
-Here are links to both the ISO CD image, and partitioned, USB image for the
-DC7800 and others.  These are based on the new 4.2 BootImage, and are the most
-up-to-date software for PlanetLab nodes.
-
-%(url_list)s
-
-All that is necessary is to raw-write these images to a usb stick or CD-ROM, and
-then boot from them.  If using USB, please use a command like:
-
-   dd if=%(hostname)s.usb of=/dev/sdX
-
-Where sdX is your USB device.  It is not necessary to run any other formatting
-commands for these images, because they already include a MBR, partition
-table, and fs.
-
-Please let me know if you have any trouble.
-
-Thank you,
-
-""" % ret
-
-       elif config.media == "iso":
-               print """
-Hello,
-
-Here are links to the ISO CD image(s) for your machines.  These are based on
-the new 4.2 BootImage, and are the most up-to-date software for PlanetLab
-nodes.
-
-%(url_list)s
-
-All that is necessary is to burn these images to a CD-ROM, and
-then boot from them.  
-
-Please let me know if you have any trouble.
-
-Thank you,
-
-""" % ret
-
-       elif config.media == "usb":
-               print """
-Hello,
-
-Here are links to the partitioned, USB images for the DC7800 and others.  
-These are based on the new 4.2 BootImage, and are the most
-up-to-date software for PlanetLab nodes.
-
-%(url_list)s
-
-All that is necessary is to raw-write these images to a usb stick, and
-then boot from them.  Please use a command like:
-
-   dd if=%(hostname)s.usb of=/dev/sdX
-
-Where sdX is your direct, USB device.  Do not use a partition on the usb
-image, or the boot will fail.  It is not necessary to run any other formatting
-commands for these images, because they already include a MBR, partition
-table, and fs.
-
-Please let me know if you have any trouble.
-
-Thank you,
-
-""" % ret
diff --git a/getnodekey.py b/getnodekey.py
deleted file mode 100644 (file)
index 4ffe00d..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/python
-
-import os
-import sys
-import string
-import time
-import moncommands
-import plc
-
-def main():
-
-       l_nodes = [ 'planetlab4.inf.ethz.ch', 'planetlab-1.di.fc.ul.pt',
-             'planetlab2.singaren.net.sg', 'planetlab2.nbgisp.com',
-             'planetlab1.koganei.wide.ad.jp', 'planetlab2.koganei.wide.ad.jp',
-             'planetlab1.citadel.edu', 'pl2.ucs.indiana.edu',
-             'plab1.engr.sjsu.edu', 'plab2.engr.sjsu.edu',
-             'planetlab1.iin-bit.com.cn', 'planetlab1.cs.virginia.edu',
-             'planetlab1.info.ucl.ac.be', 'node-1.mcgillplanetlab.org', ]
-       d_nodes = {}
-       for host in l_nodes:
-               n = plc.getNodes({'hostname' : host})
-               d_nodes[host] = n
-               #print n
-
-       for host in d_nodes:
-               ssh = moncommands.SSH('root', host)
-               val = ssh.runE("grep NODE_KEY /tmp/planet.cnf")
-               print "%s == %s" % (host, val)
-
-       
-if __name__ == '__main__':
-       import os
-       try:
-               main()
-       except Exception, error:
-               print "Exception %s" % error
-               sys.exit(0)
diff --git a/getnodes.py b/getnodes.py
deleted file mode 100755 (executable)
index 7be8a0e..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/python
-
-import database
-import plc
-import sys
-from reboot import pcu_name, get_pcu_values
-
-import sys
-import parser as parsermodule
-
-parser = parsermodule.getParser()
-parser.set_defaults(withpcu=False,
-                                       refresh=False)
-parser.add_option("", "--refresh", action="store_true", dest="refresh",
-                                       help="Refresh the cached values")
-config = parsermodule.parse_args(parser)
-
-if not config.run:
-       k = config.__dict__.keys()
-       k.sort()
-       for o in k:
-               print o, "=", config.__dict__[o]
-       print "Add --run to actually perform the command"
-       sys.exit(1)
-
-nodelist = database.if_cached_else_refresh(1, 
-                                                       config.refresh, 
-                                                       "l_plcnodes", 
-                                                       lambda : plc.getNodes({'peer_id':None}, ['hostname']))
-nodes = [n['hostname'] for n in nodelist]
-
-for nodename in nodes:
-       print nodename
diff --git a/mailmonitor.py b/mailmonitor.py
deleted file mode 100644 (file)
index fab3e65..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (c) 2004  The Trustees of Princeton University (Trustees).
-# 
-# Stephen Soltesz <soltesz@cs.princeton.edu>
-#
-# $Id: monitor.py,v 1.7 2007/07/03 19:59:02 soltesz Exp $
-
-import sys
-
-from monitor import database
-from monitor.wrapper import rt
-from monitor.wrapper import plc
-from monitor.policy import *
-from monitor.database.info.model import *
-
-api = plc.getAuthAPI()
-
-def reboot(hostname):
-       print "CALLING: mailmonitor.reboot(%s)" % hostname
-
-       l_nodes = api.GetNodes(hostname)
-       if len(l_nodes) == 0:
-               raise Exception("No such host: %s" % hostname)
-       
-       q_blacklist = BlacklistRecord.query.all()
-
-       l_blacklist = [ n.hostname for n in q_blacklist ]
-       l_nodes  = filter(lambda x : not x['hostname'] in l_blacklist, l_nodes)
-       if len(l_nodes) == 0:
-               raise Exception("Host removed via blacklist: %s" % hostname)
-
-       mon = MonitorMergeDiagnoseSendEscellate(hostname, True)
-       mon.run()
-
-       return True
-
-def main():
-       for host in sys.argv[1:]:
-               reboot(host)
-
-if __name__ == '__main__':
-       print "calling main"
-       main()
index 424c362..aed298c 100644 (file)
@@ -79,7 +79,7 @@ function check_monitor_schema_and_data()
 {
        # NOTE: call create_all() to setup the database from the info model.
        python -c "from monitor.database.info.model import *; from elixir import create_all; create_all()"
-       $MONITORPATH/init-bootman-sequence.py
+       $MONITORPATH/config.d/init-bootman-sequence.py
 }
 
 function check_monitor_conf ()
index dee3cec..ecb9c08 100755 (executable)
@@ -21,7 +21,6 @@ from monitor import parser as parsermodule
 
 api = plc.getAuthAPI()
 
-from monitor.query import verify,query_to_dict,node_select
 from monitor.common import *
 from sets import Set
 
@@ -74,7 +73,7 @@ def main():
                group_str = config.site
 
        elif config.nodeselect:
-               hostlist = node_select(config.nodeselect)
+               hostlist = query.node_select(config.nodeselect)
                nodelist = [ plccache.GetNodeByName(h) for h in hostlist ]
 
                group_str = "selection"
diff --git a/phpconfig.py b/phpconfig.py
deleted file mode 100755 (executable)
index 2848c75..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/python
-
-import config
-
-print "<?php"
-for attr in dir(config):
-       val = config.__getattribute__(attr)
-       if attr[0].isupper() and attr[1].isupper():
-               print "define('%s', '%s'); " % (attr, val)
-print "?>"
diff --git a/plctool.py b/plctool.py
deleted file mode 100644 (file)
index 9be8462..0000000
+++ /dev/null
@@ -1,421 +0,0 @@
-#!/bin/env python
-#
-# Helper functions that minipulate the PLC api.
-# 
-# Faiyaz Ahmed <faiyaza@cs.princeton.edu>
-# Copyright (C) 2006, 2007 The Trustees of Princeton University
-#
-# $Id: plctool.py,v 1.2 2007/04/19 20:43:00 mef Exp $
-#
-
-from monitor.wrapper.emailTxt import *
-import xml, xmlrpclib
-import logging
-import time
-import config
-import getpass, getopt
-import sys
-
-logger = logging.getLogger("monitor")
-XMLRPC_SERVER = 'https://www.planet-lab.org/PLCAPI/'
-api = xmlrpclib.Server(XMLRPC_SERVER, verbose=False, allow_none = True)
-auth = None
-
-def nodesDbg(argv):
-       """Returns list of nodes in dbg as reported by PLC"""
-
-       global api, auth
-       dbgNodes = []
-       allnodes = api.GetNodes(auth, None, ['hostname','boot_state'])
-       for node in allnodes:
-               if node['boot_state'] == 'dbg': dbgNodes.append(node['hostname'])
-       logger.info("%d nodes in debug according to PLC." %len(dbgNodes))
-       return dbgNodes
-
-
-def siteId(argv):
-       """Returns loginbase for given nodename"""
-
-       global api, auth
-       nodename = argv[0]
-       site_ids = api.GetNodes(auth, [nodename], ['site_id'])
-       if len(site_ids) == 1:
-               site_id = [site_ids[0]['site_id']]
-               loginbase = api.GetSites (auth, site_id, ["login_base"])
-               return loginbase[0]['login_base']
-
-def slices(argv):
-       """Returns list of slices for a site."""
-
-       global api, auth
-       if len(argv) < 1:
-               printUsage("not enough arguments; please provide loginbase")
-               sys.exit(1)
-
-       loginbase = argv[0]
-       if auth is None:
-               printUsage("requires admin privs")
-               sys.exit(1)
-
-       slices = api.GetSlices (auth, {'name':"%s_*"%loginbase},['name'])
-       slices = map(lambda x: x['name'],slices)
-       return slices
-
-def getpcu(argv):
-       """Returns dict of PCU info of a given node."""
-
-       global api, auth
-       nodename = argv[0].lower()
-       if auth is None:
-               printUsage("requires admin privs")
-               sys.exit(1)
-
-       pcus = api.GetNodes(auth, [nodename], ['pcu_ids'])
-       if len(pcus):
-               pcus = map(lambda x: x['pcu_ids'],pcus)[0]
-               nodepcus = api.GetPCUs(auth,pcus)
-       else:
-               nodepcus = []
-       return nodepcus
-
-
-def getSiteNodes(argv):
-       """Returns all site nodes for site id (loginbase)."""
-       global api, auth
-       if len(argv) < 1:
-               printUsage("not enough arguments; please provide loginbase")
-               sys.exit(1)
-
-       loginbase = argv[0]
-       nodelist = []
-       site_ids = api.GetSites(auth, {'login_base': "%s" % loginbase}, ['node_ids'])
-       if len(site_ids) == 1:
-               node_ids = site_ids[0]['node_ids']
-               nodes = api.GetNodes(auth,node_ids,['hostname'])
-               nodelist = map(lambda x: x['hostname'], nodes)
-       elif len(site_ids) == 0:
-               logger.info("getSiteNodes: can't find site %s" %loginbase)            
-       nodelist.sort()
-       return nodelist
-
-def renewAllSlices (argv):
-       """Sets the expiration date of all slices to given date"""
-       global api, auth
-
-       newexp = argv[0]
-       # convert time string using fmt "%B %d %Y" to epoch integer
-       try:
-               newexp = int(time.mktime(time.strptime(newexp,"%B %d %Y")))
-       except ValueError, e:
-               errormsg = """Expecting date to be in Month Day Year
-  e.g., April 7 2007
-  new expiration date provided %s""" % newexp
-               printUsage(errormsg)
-               sys.exit(1)
-               
-       slices = api.GetSlices(auth)
-       for slice in slices:
-               name = slice['name']
-               exp = int(slice['expires'])
-               olddate = time.asctime(time.localtime(exp))
-               slice_attributes = api.GetSliceAttributes(auth,slice['slice_attribute_ids'])
-               for slice_attribute in slice_attributes:
-                       if slice_attribute['name'] == "enabled":
-                               print "%s is suspended" % name
-               if exp < newexp:
-                       newdate = time.asctime(time.localtime(newexp))
-                       ret = api.SliceRenew(auth,name,newexp)
-                       if ret == 0:
-                               print "failed to renew %s" %name
-
-def nodeBootState(argv):
-       """Sets boot state of a node."""
-
-       global api, auth
-       if len(argv) < 1:
-               printUsage("not enough arguments")
-               sys.exit(1)
-               
-       if len(argv) >=1:
-               nodename = argv[0]
-       if len(argv) >=2:
-               state = argv[1]
-
-       if auth is None:
-               printUsage("requires admin privs")
-               sys.exit(1)
-
-       node = api.GetNodes(auth, [nodename], ['node_id','boot_state'])
-       if len(node) == 1:
-               node = node[0]
-               try:
-                       logger.info("%s boot_state=%s" %(nodename, node['boot_state']))
-                       if len(argv) >=2 and not config.debug:
-                               logger.info("Setting node %s boot_state=%s" %(nodename, state))
-                               node_id = node['node_id']
-                               api.UpdateNode(auth, node_id, {'boot_state': state})
-               except Exception, exc:
-                       logger.info("nodeBootState:  %s" % exc)
-       else:
-               logger.info("Cant find node %s to toggle boot state" % nodename)
-
-
-def nodePOD(argv):
-       """Sends Ping Of Death to node."""
-
-       global api, auth
-       if len(argv) < 1:
-               printUsage("not enough arguments")
-               sys.exit(1)
-               
-       nodename = argv[0]
-       if auth is None:
-               printUsage("requires admin privs")
-               sys.exit(1)
-
-       node = api.GetNodes(auth, [nodename], ['node_id'])
-       if len(node) == 1:
-               node = node[0]
-               logger.info("Sending POD to %s" % nodename)
-               try:
-                       if not config.debug:
-                               api.RebootNode(auth, node['node_id'])
-               except Exception, exc:
-                       logger.info("nodePOD:  %s" % exc)
-       else:
-               logger.info("Cant find node %s to send POD." % nodename)
-
-def suspendSlice(argv):
-       """Freeze specific slice."""
-       global api, auth
-       if auth is None:
-               printUsage("requires admin privs")
-               sys.exit(1)
-
-       slice = argv[0]
-       logger.info("Suspending slice %s" % slice)
-       try:
-               if not config.debug:
-                       api.AddSliceAttribute(auth, slice, "enabled", "0")
-       except Exception, exc:
-               logger.info("suspendSlices:  %s" % exc)
-
-def suspendSlices(argv):
-       """Freeze all site slices."""
-       global api, auth
-       if auth is None:
-               printUsage("requires admin privs")
-               sys.exit(1)
-
-       if argv[0].find(".") <> -1: siteslices = slices([siteId(argv)])
-       else: siteslices = slices(argv)
-
-       for slice in siteslices:
-               suspendSlice([slice])
-
-def __enableSlice(slice):
-       logger.info("unfreezing slice %s" % slice['name'])
-       slice_attributes = api.GetSliceAttributes(auth,slice['slice_attribute_ids'])
-       for slice_attribute in slice_attributes:
-               if slice_attribute['name'] == "enabled":
-                       api.DeleteSliceAttribute(auth, slice_attribute['slice_attribute_id'])
-       
-def enableSlice(arg):
-       """Enable suspended slice."""
-       global api, auth
-       if auth is None:
-               printUsage("requires admin privs")
-               sys.exit(1)
-
-       slicename = arg[0]
-       gSlices = {'name':slicename}
-       slice = api.GetSlices(auth,gSlices)
-       if len(slice) == 1:
-               __enableSlice(slice[0])
-       else:
-               logger.info("slice %s not found" % slicename)
-
-def enableSlices(argv):
-       """Enable suspended site slices."""
-
-       global api, auth
-       if auth is None:
-               printUsage("requires admin privs")
-               sys.exit(1)
-
-       if argv[0].find(".") <> -1:
-               slices = api.GetSlices(auth,[siteId(argv)])
-       else:
-               gSlices = {'name':"%s_*"%argv[0]}
-               slices = api.GetSlices(auth,gSlices)
-
-       for slice in slices:
-               __enableSlice(slice)
-
-def setSliceMax(argv):
-       """Set max_slices for Slice. Returns previous max_slices"""
-       global api, auth
-       if auth is None:
-               printUsage("requires admin privs")
-               sys.exit(1)
-
-       name = argv[0]
-       val = int(argv[1])
-       if name.find(".") <> -1:
-               site_ids = api.GetNodes(auth, [name], ['site_id'])
-               if len(site_ids) == 1:
-                       site_id = [site_ids[0]['site_id']]
-                       loginbase = api.GetSites (auth, site_id, ["login_base"])
-               else:
-                       printUsage("invalid hostname %s" % name)
-                       sys.exit(1)
-       else:
-               site_ids = api.GetSites(auth, {'login_base': "%s" % name}, ['site_id'])
-               if len(site_ids) == 1:
-                       siteid = site_ids[0]['site_id']
-               loginbase = name
-
-       numslices = api.GetSites(auth, [siteid], ["max_slices"])[0]['max_slices']
-       try:
-               api.UpdateSite(auth, siteid, {'max_slices': val})
-               logger.info("_SetSliceMax:  %s max_slices was %d set to %d" % (loginbase,numslices,val))
-               return numslices
-       except Exception, exc:
-               logger.info("_SetSliceMax:  %s" % exc)
-
-
-def authCheck(arg):
-       """Enable suspended slice."""
-       global api, auth
-       if auth is None:
-               printUsage("requires admin privs")
-               sys.exit(1)
-
-       if len(arg) != 2:
-               printUsage("incorrect arguments")
-               sys.exit(1)
-       user= arg[0]
-       pwd = arg[1]
-       
-       check = {}
-       check['Username'] = user
-       check['AuthMethod'] = "password"
-       check['AuthString'] = pwd
-       for role in ['user','tech','pi','admin']:
-               check['Role'] = role
-               res = api.AdmAuthCheck(check)
-               print "%s -> %s %d" % (user,role,res)
-
-
-def cleanSlices(arg):
-       """Remove all disabled/deleted users from all slices."""
-       disabledUsers = {'enabled':False}
-       persons = api.GetPersons(auth,disabledUsers,['enabled','slice_ids','email','person_id'])
-       for person in persons:
-               assert (person['enabled']==False)
-               person_id = person['person_id']
-               if len(person['slice_ids'])>0:
-                       for slice_id in person['slice_ids']:
-                               print "deleting slice %d from %s" % (slice_id,person['email'])
-                               api.DeletePersonFromSlice(auth,person_id,slice_id)
-
-
-
-USAGE = """
-Usage: %s [-u user] [-p password] [-r role] CMD
-
-Options:
--u      PLC account username
--p      PLC account password
--r      PLC account role
--h      This message
-""" % sys.argv[0]
-
-def printUsage(error = None):
-       global funclist
-       if error <> None:
-               print "%s %s" %(sys.argv[0],error)
-       print USAGE
-       print "CMD:"
-       for name,function in funclist:
-               print "%20s\t%20s" % (name, function.__doc__)
-       
-def main():
-       global api, auth
-
-       auth = None
-       user = None
-       password = None
-       role = 'admin'
-
-       (opts, argv) = getopt.getopt(sys.argv[1:], "u:p:r:h")
-       if len(argv)==0:
-               printUsage()
-               sys.exit(1)
-
-       for (opt, optval) in opts:
-               if opt == '-u':
-                       user = optval
-               elif opt == '-p':
-                       password = optval
-               elif opt == '-r':
-                       role = optval
-               elif opt == '-h':
-                       print USAGE
-                       sys.exit(0)
-
-       if user <> None:
-               if password is None:
-                       try:
-                               password = getpass.getpass()
-                       except (EOFError, KeyboardInterrupt):
-                               print( "" )
-                               sys.exit(1)
-               auth = {}
-               auth['Username'] = user
-               auth['AuthMethod'] = "password"
-               auth['AuthString'] = password
-               auth['Role'] = role
-
-       cmd = functbl.get(argv[0], None)
-       if cmd is None:
-               printUsage()
-               sys.exit(1)
-
-       logger.setLevel(logging.DEBUG)
-       ch = logging.StreamHandler()
-       ch.setLevel(logging.DEBUG)
-       formatter = logging.Formatter('logger - %(message)s')
-       ch.setFormatter(formatter)
-       logger.addHandler(ch)
-       result = cmd(argv[1:])
-       if result <> None:
-               if argv[0] == "nodesDbg":
-                       for n in result:
-                               print n
-               else:
-                       print result
-
-funclist = (("nodesDbg",nodesDbg),
-           ("siteId", siteId),
-           ("slices", slices),
-           ("pcu", getpcu),
-           ("siteNodes", getSiteNodes),
-           ("nodeBootState", nodeBootState),
-           ("nodePOD", nodePOD),
-           ("freezeSlice", suspendSlice),
-           ("unfreezeSlice", enableSlice),
-           ("freezeSlices", suspendSlices),
-           ("unfreezeSlices", enableSlices),
-           ("setSliceMax", setSliceMax),
-           ("authCheck", authCheck),
-           ("cleanSlices", cleanSlices),
-           ("renewAllSlices", renewAllSlices))
-
-functbl = {}
-for f in funclist:
-       functbl[f[0]]=f[1]
-
-if __name__=="__main__":
-       import reboot
-       main() 
diff --git a/printbadcsv.py b/printbadcsv.py
deleted file mode 100755 (executable)
index 2f5036d..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-#!/usr/bin/python
-from monitor import database
-from monitor import config
-import parser as parsermodule
-
-from www.printbadnodes import *
-
-def main():
-       db = database.dbLoad(config.dbname)
-       act= database.dbLoad("act_all")
-
-       ## Field widths used for printing
-       maxFieldLengths = { 'nodename' : -45,
-                                               'ping' : 6, 
-                                               'ssh' : 6, 
-                                               'rt' : 10, 
-                                               'pcu' : 7, 
-                                               'category' : 9, 
-                                               'state' : 5, 
-                                               'kernel' : 10.65, 
-                                               'comonstats' : 5, 
-                                               'plcsite' : 12,
-                                               'bootcd' : 10.65}
-       ## create format string based on config.fields
-       fields = {}
-       format = ""
-       for f in config.fields.split(','):
-               fields[f] = "%%(%s)%ds" % (f, maxFieldLengths[f])
-       for f in config.fields.split(','):
-               format += fields[f] + " "
-
-
-       d_n = db['nodes']
-       if config.display:
-               l_nodes = sys.argv[2:]
-       else:
-               l_nodes = d_n.keys()
-
-       # d2 was an array of [{node}, {}, ...]
-       # the bysite is a loginbase dict of [{node}, {node}]
-       d2 = []
-       for nodename in l_nodes: 
-               vals=d_n[nodename]['values'] 
-               v = {}
-               v.update(vals)
-               v['nodename'] = nodename 
-               if 'plcsite' in vals and 'status' in vals['plcsite'] and vals['plcsite']['status'] == "SUCCESS":
-                       site_string = "<b>%-20s</b> %2s nodes :: %2s of %4s slices" % ( \
-                                                                                                               vals['plcsite']['login_base'],
-                                                                                                               vals['plcsite']['num_nodes'], 
-                                                                                                               vals['plcsite']['num_slices'], 
-                                                                                                               vals['plcsite']['max_slices'])
-                       v['site_string'] = site_string
-                       d2.append(v)
-               else:
-                       #print "ERROR: ", nodename, vals, "<br>"
-                       pass
-                       #site_string = "<b>UNKNOWN</b>"
-                       
-
-       if config.cmpping:
-               d2.sort(cmp=cmpPing)
-       elif config.cmpssh:
-               d2.sort(cmp=cmpSSH)
-       elif config.cmpcategory:
-               d2.sort(cmp=cmpCategory)
-       elif config.cmpstate:
-               d2.sort(cmp=cmpState)
-       elif config.cmpdays:
-               d2.sort(cmp=cmpDays)
-       elif config.cmpkernel:
-               d2.sort(cmp=cmpUname)
-       else:
-               d2.sort(cmp=cmpCategory)
-       
-
-       for row in d2:
-               site_string = row['site_string']
-               vals = row
-               # convert uname values into a single kernel version string
-               if 'kernel' in vals:
-                       kernel = vals['kernel'].split()
-                       if len(kernel) > 0:
-                               if kernel[0] == "Linux":
-                                       vals['kernel'] = kernel[2]
-                               else:
-                                       vals['ssherror'] = vals['kernel']
-                                       vals['kernel'] = ""
-               else:
-                       vals['ssherror'] = ""
-                       vals['kernel'] = ""
-                       continue
-
-               if 'pcu' in vals and vals['pcu'] == "PCU":
-                       # check the health of the pcu.
-                       s = pcu_state(vals['plcnode']['pcu_ids'][0])
-                       if s == 0:
-                               vals['pcu'] = "UP-PCU"
-                       else:
-                               vals['pcu'] = "DN-PCU"
-
-               vals['rt'] = " -"
-               if vals['nodename'] in act:
-                       if len(act[vals['nodename']]) > 0 and 'rt' in act[vals['nodename']][0]:
-                               if 'Status' in act[vals['nodename']][0]['rt']:
-                                       vals['rt'] = "%s %s" % (act[vals['nodename']][0]['rt']['Status'], 
-                                                                                       act[vals['nodename']][0]['rt']['id'])
-
-               str = format % vals 
-               fields = str.split()
-               #print "<tr>"
-               s = fields_to_html(fields, vals)
-               s = ""
-               if config.display:
-                       print str
-
-       keys = categories.keys()
-       for cat in ['BOOT-PROD', 'BOOT-OLDPROD', 'BOOT-OLDBOOTCD', 'DEBUG-PROD',
-       'DEBUG-OLDPROD', 'DEBUG-OLDBOOTCD', 'DOWN-ERROR']:
-               if cat not in keys:
-                       categories[cat] = 0
-       keys = categories.keys()
-       for cat in ['BOOT-PROD', 'BOOT-OLDPROD', 'BOOT-OLDBOOTCD', 'DEBUG-PROD',
-       'DEBUG-OLDPROD', 'DEBUG-OLDBOOTCD', 'DOWN-ERROR']:
-               if cat in keys:
-                       print "%d," % categories[cat],
-       print ""
-import cgi
-if __name__ == '__main__':
-       parser = parsermodule.getParser()
-       parser.set_defaults(cmpdays=False, 
-                                               comon="sshstatus", 
-                                               fields="nodename,ping,ssh,pcu,category,state,kernel,bootcd,rt", 
-                                               dbname="findbad", # -070724-1", 
-                                               display=False,
-                                               cmpping=False, 
-                                               cmpssh=False, 
-                                               cmpcategory=False,
-                                               cmpstate=False)
-       parser.add_option("", "--fields",       dest="dbname", help="")
-       parser.add_option("", "--dbname",       dest="dbname", help="")
-       parser.add_option("", "--display",      dest="display", action="store_true")
-       parser.add_option("", "--days",         dest="cmpdays", action="store_true", help="")
-       parser.add_option("", "--ping",         dest="cmpping", action="store_true", help="")
-       parser.add_option("", "--ssh",          dest="cmpssh",  action="store_true", help="")
-       parser.add_option("", "--category",     dest="cmpcategory", action="store_true", help="")
-       parser.add_option("", "--kernel",       dest="cmpkernel", action="store_true", help="")
-       parser.add_option("", "--state",        dest="cmpstate", action="store_true", help="")
-       parser.add_option("", "--comon",        dest="comon",   help="")
-       config = parsermodule.parse_args(parser)
-       main()
index 2ac58df..b78dcf0 100755 (executable)
@@ -2,7 +2,6 @@
 
 # NOTE: Must be an absolute path to guarantee it is read.
 INSTALLPATH=/usr/share/monitor/
-# Generate an 'sh' style file full of variables in monitor.conf
 $INSTALLPATH/shconfig.py >  $INSTALLPATH/monitorconfig.sh
 source $INSTALLPATH/monitorconfig.sh
 cd ${MONITOR_SCRIPT_ROOT}
similarity index 100%
rename from rtinfo.py
rename to statistics/rtinfo.py
diff --git a/ticket_blacklist.py b/ticket_blacklist.py
deleted file mode 100755 (executable)
index 08f50b7..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/python
-
-import os
-import sys
-import string
-import time
-import database
-import plc
-import getopt
-
-def usage():
-       print "ticket_blacklist.py --delete=<i>" 
-
-def main():
-
-       try:
-               longopts = ["delete=", "help"]
-               (opts, argv) = getopt.getopt(sys.argv[1:], "d:h", longopts)
-       except getopt.GetoptError, err:
-               print "Error: " + err.msg
-               sys.exit(1)
-
-       l_ticket_blacklist = database.if_cached_else(1, "l_ticket_blacklist", lambda : [])
-
-       for (opt, optval) in opts:
-               if opt in ["-d", "--delete"]:
-                       i = int(optval)
-                       del l_ticket_blacklist[i]
-               else:
-                       usage()
-                       sys.exit(0)
-
-       i_cnt = 0
-       for i in l_ticket_blacklist:
-               print i_cnt, " ", i
-               i_cnt += 1
-
-       while 1:
-               line = sys.stdin.readline()
-               if not line:
-                       break
-               line = line.strip()
-               if not line in l_ticket_blacklist:
-                       l_ticket_blacklist.append(line)
-
-       print "Total %d nodes in ticket_blacklist" % (len(l_ticket_blacklist))
-       database.dbDump("l_ticket_blacklist")
-       
-if __name__ == '__main__':
-       import os
-       #try:
-       main()
-       #except Exception, error:
-       #       print "Exception %s" % error
-       #       sys.exit(0)