Added 'FORCED' to handle some special actions
[monitor.git] / www / printbadnodes.py
index c8bbfcb..2f86db7 100755 (executable)
@@ -63,7 +63,7 @@ def cmpState(l1, l2):
        return cmpMap(l1,l2,'state', map)
 
 def cmpCategoryVal(v1, v2):
-       map = array_to_priority_map([ None, 'ALPHA', 'PROD', 'OLDBOOTCD', 'UNKNOWN', 'ERROR', ])
+       map = array_to_priority_map([ None, 'ALPHA', 'PROD', 'OLDBOOTCD', 'UNKNOWN', 'FORCED', 'ERROR', ])
        return cmpValMap(v1,v2,map)
 
 def cmpCategory(l1, l2):
@@ -199,7 +199,7 @@ def fields_to_html(fields, vals):
                                r_str += "<td %s>%s</td>" % (bgcolor, f)
                elif f == 'PCU':
                        if len(vals['plcnode']['pcu_ids']) > 0:
-                               url = "<a href='http://dendrite.cs.princeton.edu/~soltesz/printbadpcus.php#id%s'>PCU</a>" % vals['plcnode']['pcu_ids'][0]
+                               url = "<a href='/cgi-bin/printbadpcus.php#id%s'>PCU</a>" % vals['plcnode']['pcu_ids'][0]
                                r_str += "<td nowrap %s>%s</td>" % (bgcolor, url)
                else:
                        r_str += "<td nowrap %s>%s</td>" % (bgcolor, f)
@@ -258,6 +258,11 @@ def main(sitefilter):
        # d2 was an array of [{node}, {}, ...]
        # the bysite is a loginbase dict of [{node}, {node}]
        d2 = []
+       import re
+       if sitefilter != None:
+               sf = re.compile(sitefilter)
+       else:
+               sf = None
        for nodename in l_nodes: 
                vals=d_n[nodename]['values'] 
                v = {}
@@ -267,7 +272,7 @@ def main(sitefilter):
                        'status' in vals['plcsite'] and  \
                        vals['plcsite']['status'] == "SUCCESS":
 
-                       url = "<a href='printbad.cgi?site=%s'>%s</a>" % ( vals['plcsite']['login_base'],
+                       url = "<a href='printbadnodes.py?site=%s'>%s</a>" % ( vals['plcsite']['login_base'],
                                                                                                                         vals['plcsite']['login_base'])
 
                        site_string = "%s %2s nodes :: %2s of %4s slices" % ( \
@@ -283,7 +288,7 @@ def main(sitefilter):
 
                v['site_string'] = site_string
                v['loginbase'] = loginbase
-               if (sitefilter != None and loginbase == sitefilter) or sitefilter == None:
+               if (sitefilter != None and sf.match(loginbase) != None) or sitefilter == None:
                        d2.append(v)
                        
 
@@ -392,21 +397,21 @@ def main(sitefilter):
                print "</tr>"
        print "</table>"
 
-import cgi
-import cgitb; 
-cgitb.enable()
-import sys
 
-form = cgi.FieldStorage()
-myfilter = None
 
-if form.has_key('site'):
-       myfilter = form.getvalue("site")
-else:
-       myfilter = None
+if __name__ == '__main__':
+       import cgi
+       import cgitb; 
+       cgitb.enable()
+       import sys
 
+       form = cgi.FieldStorage()
+       myfilter = None
 
-if __name__ == '__main__':
+       if form.has_key('site'):
+               myfilter = form.getvalue("site")
+       else:
+               myfilter = None
        parser = OptionParser()
        parser.set_defaults(cmpdays=False, 
                                                comon="sshstatus",