+def prep_pcu_for_display(pcu):
+
+ try:
+ pcu.loginbase = site_id2lb[pcu.plc_pcu_stats['site_id']]
+ except:
+ pcu.loginbase = "unknown"
+
+ pcu.ports = format_ports(pcu.port_status, pcu.plc_pcu_stats['model'])
+ pcu.status = format_pcu_shortstatus(pcu)
+
+ #print pcu.entry_complete
+ pcu.entry_complete_str = pcu.entry_complete
+ #pcu.entry_complete_str += "".join([ f[0] for f in pcu.entry_complete.split() ])
+ if pcu.dns_status == "NOHOSTNAME":
+ pcu.dns_short_status = 'NoHost'
+ elif pcu.dns_status == "DNS-OK":
+ pcu.dns_short_status = 'Ok'
+ elif pcu.dns_status == "DNS-NOENTRY":
+ pcu.dns_short_status = 'NoEntry'
+ elif pcu.dns_status == "NO-DNS-OR-IP":
+ pcu.dns_short_status = 'NoHostOrIP'
+ elif pcu.dns_status == "DNS-MISMATCH":
+ pcu.dns_short_status = 'Mismatch'
+
+class NodeWidget(widgets.Widget):
+ pass
+
+def prep_node_for_display(node):
+ if node.plc_pcuid:
+ pcu = FindbadPCURecord.get_latest_by(plc_pcuid=node.plc_pcuid)
+ if pcu:
+ node.pcu_status = pcu.reboot_trial_status
+ node.pcu_short_status = format_pcu_shortstatus(pcu)
+ node.pcu = pcu
+ prep_pcu_for_display(node.pcu)
+ else:
+ node.pcu_short_status = "none"
+ node.pcu_status = "nodata"
+ node.pcu = None
+
+ else:
+ node.pcu_status = "nopcu"
+ node.pcu_short_status = "none"
+ node.pcu = None
+
+
+ if node.kernel_version:
+ node.kernel = node.kernel_version.split()[2]
+ else:
+ node.kernel = ""
+
+ try:
+ node.loginbase = site_id2lb[node.plc_node_stats['site_id']]
+ except:
+ node.loginbase = "unknown"
+
+ if node.loginbase:
+ node.site = HistorySiteRecord.by_loginbase(node.loginbase)
+ if node.site is None:
+ # TODO: need a cleaner fix for this...
+ node.site = HistorySiteRecord.by_loginbase("pl")
+ if not node.site:
+ node.site = HistorySiteRecord.by_loginbase("ple")
+
+
+ node.history = HistoryNodeRecord.by_hostname(node.hostname)
+
+ node.ports = format_ports(node.port_status)
+
+ try:
+ exists = node.plc_node_stats['last_contact']
+ except:
+ node.plc_node_stats = {'last_contact' : None}
+
+
+
+class Root(controllers.RootController, MonitorXmlrpcServer):