+ widget = NodeWidget(template='monitorweb.templates.node_template')
+ return dict(now=time.ctime(), query=query, fc=filtercount, nodewidget=widget)
+
+ def nodeaction_handler(self, tg_exceptions=None):
+ """Handle any kind of error."""
+ refurl = request.headers.get("Referer",link("pcu"))
+ print refurl
+
+ # TODO: do this more intelligently...
+ uri_fields = urllib.splitquery(refurl)
+ if uri_fields[1] is not None:
+ val = query_to_dict(uri_fields[1])
+ if 'pcuid' in val:
+ pcuid = val['pcuid']
+ elif 'hostname' in val:
+ pcuid = FindbadNodeRecord.get_latest_by(hostname=val['hostname']).first().plc_pcuid
+ else:
+ pcuid=None
+
+ cherry_trail = cherrypy._cputil.get_object_trail()
+ for i in cherry_trail:
+ print "trail: ", i
+
+ print pcuid
+ return self.pcuview(pcuid, **dict(exceptions=tg_exceptions))
+
+ def nodeaction(self, **data):
+ for item in data.keys():
+ print "%s %s" % ( item, data[item] )
+
+ if 'hostname' in data:
+ hostname = data['hostname']
+ else:
+ flash("No hostname given in submitted data")
+ return
+
+ if 'submit' in data or 'type' in data:
+ try:
+ action = data['submit']
+ except:
+ action = data['type']
+ else:
+ flash("No submit action given in submitted data")
+ return
+
+ if action == "Reboot":
+ print "REBOOT: %s" % hostname
+ ret = reboot.reboot_str(str(hostname))
+ print ret
+ if ret: raise RuntimeError("Error using PCU: " + ret)
+ flash("Reboot appeared to work. All at most 5 minutes. Run ExternalScan to check current status.")
+
+ elif action == "ExternalScan":
+ scanapi.externalprobe(str(hostname))
+ flash("External Scan Successful!")
+ elif action == "InternalScan":
+ scanapi.internalprobe(str(hostname))
+ flash("Internal Scan Successful!")
+ else:
+ # unknown action
+ raise RuntimeError("Unknown action given")
+ return