12 from nodecommon import *
13 from unified_model import node_end_record, PersistFlags
17 import parser as parsermodule
19 parser = parsermodule.getParser()
20 parser.set_defaults(node=None,
23 parser.add_option("", "--node", dest="node", metavar="nodename.edu",
24 help="A single node name to add to the nodegroup")
25 parser.add_option("", "--endrecord", dest="endrecord", action="store_true",
26 help="Force an end to the action record; to prompt Montior to start messaging again.")
27 parser.add_option("", "--findbad", dest="findbad", action="store_true",
28 help="Re-run findbad on the nodes we're going to check before acting.")
29 parser.add_option("", "--bootcd", dest="bootcd", action="store_true",
30 help="A stock help message for fetching a new BootCD from the PLC GUI.")
31 config = parsermodule.parse_args(parser)
34 def plc_print_nodeinfo(plcnode):
35 url = "https://www.planet-lab.org/db/nodes/index.php?nodepattern="
36 plcnode['url'] = url + plcnode['hostname']
38 print "%(hostname)s %(url)s" % plcnode
39 print " Checked: %s" % time.ctime()
41 print "\t boot_state | created | updated | last_contact | key"
42 print "\t %5s | %11.11s | %11.11s | %12s | %s" % \
43 (color_boot_state(plcnode['boot_state']), diff_time(plcnode['date_created']),
44 diff_time(plcnode['last_updated']),
45 diff_time(plcnode['last_contact']), plcnode['key'])
47 def fb_print_nodeinfo(fbnode):
48 pf = PersistFlags(fbnode['hostname'], 1, db='node_persistflags')
49 fbnode['last_change'] = diff_time(pf.last_changed)
51 if 'checked' in fbnode:
52 print "%11.11s " % diff_time(fbnode['checked'])
55 print "\t state | ssh | pcu | bootcd | category | last change | kernel"
57 fbnode['bootcd'] = fbnode['bootcd'].split()[-1]
59 fbnode['bootcd'] = "unknown"
61 fbnode['state'] = color_boot_state(get_current_state(fbnode))
63 fbnode['state'] = "none"
64 if len(fbnode['kernel'].split()) > 2:
65 fbnode['kernel'] = fbnode['kernel'].split()[2]
66 print "\t %(state)5s | %(ssh)5.5s | %(pcu)5.5s | %(bootcd)6.6s | %(category)8.8s | %(last_change)11s | %(kernel)s" % fbnode
68 def act_print_nodeinfo(actnode, header):
70 if 'date_created' in actnode:
71 print " Created: %11.11s" % diff_time(actnode['date_created'])
72 print " LastTime %11.11s" % diff_time(actnode['time'])
73 print "\t RT | category | action | msg"
76 if 'rt' in actnode and 'Status' in actnode['rt']:
77 print "\t %5.5s %5.5s | %8.8s | %15.15s | %s" % \
78 (actnode['rt']['Status'], actnode['rt']['id'][7:],
79 actnode['category'], actnode['action'][0], actnode['info'][1:])
81 if type(actnode['action']) == type([]):
82 action = actnode['action'][0]
84 action = actnode['action']
85 if 'category' in actnode:
86 category = actnode['category']
90 if 'msg_format' in actnode:
91 print "\t %5.5s | %8.8s | %15.15s | %s" % \
92 (actnode['ticket_id'],
94 actnode['msg_format'][:-1])
96 print "\t %5.5s | %8.8s | %15.15s" % \
97 (actnode['ticket_id'],
100 def pcu_print_info(pcuinfo, hostname):
102 if 'checked' in pcuinfo:
103 print "%11.11s " % diff_time(pcuinfo['checked'])
107 print "\t user | password | port | pcu_id | hostname "
108 print "\t %17s | %17s | %4s | %6s | %30s | %s" % \
109 (pcuinfo['username'], pcuinfo['password'],
110 pcuinfo[hostname], pcuinfo['pcu_id'], reboot.pcu_name(pcuinfo), pcuinfo['model'])
112 if 'portstatus' in pcuinfo and pcuinfo['portstatus'] != {} and pcuinfo['portstatus'] != None:
113 if pcuinfo['portstatus']['22'] == "open":
114 print "\t ssh -o PasswordAuthentication=yes -o PubkeyAuthentication=no %s@%s" % (pcuinfo['username'], reboot.pcu_name(pcuinfo))
115 if pcuinfo['portstatus']['23'] == "open":
116 print "\t telnet %s" % (reboot.pcu_name(pcuinfo))
117 if pcuinfo['portstatus']['80'] == "open" or \
118 pcuinfo['portstatus']['443'] == "open":
119 print "\t https://%s" % (reboot.pcu_name(pcuinfo))
120 print "\t import %s.png" % (reboot.pcu_name(pcuinfo))
121 print """\t mutt -s "crash for %s" -a %s.png sapanb@cs.princeton.edu < /dev/null""" % (hostname, reboot.pcu_name(pcuinfo))
122 if pcuinfo['portstatus']['443'] == "open":
123 print "\t racadm.py -r %s -u %s -p '%s'" % (pcuinfo['ip'], pcuinfo['username'], pcuinfo['password'])
124 print "\t cmdhttps/locfg.pl -s %s -f iloxml/Reset_Server.xml -u %s -p '%s' | grep MESSAGE" % \
125 (reboot.pcu_name(pcuinfo), pcuinfo['username'], pcuinfo['password'])
126 print "\t cmdhttps/locfg.pl -s %s -f iloxml/License.xml -u %s -p '%s' | grep MESSAGE" % \
127 (reboot.pcu_name(pcuinfo), pcuinfo['username'], pcuinfo['password'])
128 if pcuinfo['portstatus']['16992'] == "open":
129 print "\t ./cmdamt/remoteControl -A -verbose 'http://%s:16992/RemoteControlService' -user admin -pass '%s'" % (reboot.pcu_name(pcuinfo), pcuinfo['password'])
132 # rerun findbad with the nodes in the given nodes.
135 util.file.setFileFromList(file, config.args)
136 os.system("./findbad.py --cachenodes --debug=0 --dbname=findbad --increment --nodelist %s" % file)
138 for node in config.args:
141 fb = database.dbLoad("findbad")
142 plc_nodeinfo = api.GetNodes({'hostname': config.node}, None)[0]
143 fb_nodeinfo = fb['nodes'][config.node]['values']
145 plc_print_nodeinfo(plc_nodeinfo)
146 fb_nodeinfo['hostname'] = node
147 fb_print_nodeinfo(fb_nodeinfo)
149 if fb_nodeinfo['pcu'] == "PCU":
150 pcu = reboot.get_pcu_values(fb_nodeinfo['plcnode']['pcu_ids'][0])
151 if pcu: pcu_print_info(pcu, config.node)
154 act_all = database.dbLoad("act_all")
157 if config.node in act_all and len(act_all[config.node]) > 0:
161 node_end_record(config.node)
162 #a = Action(config.node, act_all[config.node][0])
164 #a.delField('found_rt_ticket')
165 #a.delField('second-mail-at-oneweek')
166 #a.delField('second-mail-at-twoweeks')
167 #a.delField('first-found')
169 #rec['action'] = ["close_rt"]
170 #rec['category'] = "UNKNOWN"
171 #rec['stage'] = "monitor-end-record"
172 #rec['time'] = time.time() - 7*60*60*24
173 #act_all[config.node].insert(0,rec)
174 #database.dbDump("act_all", act_all)
176 for act_nodeinfo in act_all[config.node]:
177 act_print_nodeinfo(act_nodeinfo, header)
178 else: act_nodeinfo = None
184 If you need a new bootcd, the steps are very simple:
187 * https://www.planet-lab.org/db/nodes/index.php?nodepattern=%s
188 * Select Download -> Download ISO image for %s
189 * Save the ISO, and burn it to a writable CD-ROM.
190 * Replace the old CD and reboot the machine.
192 Please let me know if you have any additional questions.
193 """ % (config.node, config.node)