From 6c38b5cef7bf12fa4ade23ae1c54b3491797fb1d Mon Sep 17 00:00:00 2001
From: =?utf8?q?Bar=C4=B1=C5=9F=20Metin?= <Talip-Baris.Metin@sophia.inria.fr>
Date: Thu, 15 Oct 2009 11:13:04 +0000
Subject: [PATCH] - fix UP/DOWN summary on nodes page. - make node page display
 all nodes by default - add boot_server field - add myops_ssh_key to the
 keychain

---
 automate-default.sh                                     | 1 +
 monitor/database/info/findbad.py                        | 1 +
 monitor/scanapi.py                                      | 2 ++
 nodequery.py                                            | 4 +++-
 upgrade/monitor-server-3.0-22.sql                       | 5 +++++
 web/MonitorWeb/dev.cfg                                  | 2 +-
 web/MonitorWeb/monitorweb/controllers.py                | 1 +
 web/MonitorWeb/monitorweb/templates/node_template.kid   | 2 ++
 web/MonitorWeb/monitorweb/templates/nodefast.kid        | 8 ++++----
 web/MonitorWeb/monitorweb/templates/nodelist.kid        | 5 +++--
 web/MonitorWeb/monitorweb/templates/nodescanhistory.kid | 2 ++
 11 files changed, 25 insertions(+), 8 deletions(-)
 create mode 100644 upgrade/monitor-server-3.0-22.sql

diff --git a/automate-default.sh b/automate-default.sh
index 9f0f9d1..3e65fcf 100755
--- a/automate-default.sh
+++ b/automate-default.sh
@@ -56,6 +56,7 @@ if [ -z "$AGENT" ] ; then
         # if no agent is running, set it up.
         ssh-agent > ${MONITOR_SCRIPT_ROOT}/agent.sh
         source ${MONITOR_SCRIPT_ROOT}/agent.sh
+        ssh-add /etc/planetlab/myops_ssh_key.rsa
         ssh-add /etc/planetlab/debug_ssh_key.rsa
         ssh-add /etc/planetlab/root_ssh_key.rsa
 fi
diff --git a/monitor/database/info/findbad.py b/monitor/database/info/findbad.py
index 2f9251e..d92e7e5 100644
--- a/monitor/database/info/findbad.py
+++ b/monitor/database/info/findbad.py
@@ -38,6 +38,7 @@ class FindbadNodeRecord(Entity):
 # INTERNAL
 	kernel_version = Field(String,default=None)
 	bootcd_version = Field(String,default=None)
+        boot_server = Field(String,default=None)
 	nm_status = Field(String,default=None)
 	fs_status = Field(String,default=None)
 	iptables_status = Field(String,default=None)
diff --git a/monitor/scanapi.py b/monitor/scanapi.py
index 119f7fd..327b2b4 100644
--- a/monitor/scanapi.py
+++ b/monitor/scanapi.py
@@ -237,6 +237,7 @@ class ScanNodeInternal(ScanInterface):
 					echo '  "kernel_version":"'`uname -a`'",'
 					echo '  "bmlog":"'`ls /tmp/bm.log`'",'
 					echo '  "bootcd_version":"'`cat /mnt/cdrom/bootme/ID`'",'
+					echo '  "boot_server":"'`cat /mnt/cdrom/bootme/BOOTSERVER`'",'
 					echo '  "nm_status":"'`ps ax | grep nm.py | grep -v grep`'",'
 					echo '  "dns_status":"'`host boot.planet-lab.org 2>&1`'",'
 					echo '  "iptables_status":"'`iptables -t mangle -nL | awk '$1~/^[A-Z]+$/ {modules[$1]=1;}END{for (k in modules) {if (k) printf "%s ",k;}}'`'",'
@@ -260,6 +261,7 @@ EOF			""")
 					break
 				else:
 					values.update({'kernel_version': "", 'bmlog' : "", 'bootcd_version' : '', 
+                                                                        'boot_server' : '',
 									'nm_status' : '', 
 									'fs_status' : '',
 									'uptime' : '',
diff --git a/nodequery.py b/nodequery.py
index c78d6b4..85ff153 100755
--- a/nodequery.py
+++ b/nodequery.py
@@ -36,6 +36,8 @@ def fb_print_nodeinfo(fbnode, hostname, fields=None):
 		fbnode['bootcd_version'] = fbnode['bootcd_version'].split()[-1]
 	else:
 		fbnode['bootcd_version'] = "unknown"
+        if not fbnode['boot_server']:
+                fbnode['boot_server'] = "unknown"
 	fbnode['pcu'] = color_pcu_state(fbnode)
 
 	if not fields:
@@ -58,7 +60,7 @@ def fb_print_nodeinfo(fbnode, hostname, fields=None):
 			#print "ERROR!!!!!!!!!!!!!!!!!!!!!"
 			pass
 
-		print "%(hostname)-45s | %(date_checked)11.11s | %(boot_state)5.5s| %(observed_status)8.8s | %(ssh_status)5.5s | %(pcu)6.6s | %(bootcd_version)6.6s | %(kernel_version)s" % fbnode
+		print "%(hostname)-45s | %(date_checked)11.11s | %(boot_state)5.5s| %(observed_status)8.8s | %(ssh_status)5.5s | %(pcu)6.6s | %(bootcd_version)6.6s | %(boot_server)s | %(kernel_version)s" % fbnode
 	else:
 		format = ""
 		for f in fields:
diff --git a/upgrade/monitor-server-3.0-22.sql b/upgrade/monitor-server-3.0-22.sql
new file mode 100644
index 0000000..9b8fc4d
--- /dev/null
+++ b/upgrade/monitor-server-3.0-22.sql
@@ -0,0 +1,5 @@
+-- If there's an existing database, these commands will upgrade it to the
+-- current version
+
+ALTER TABLE findbadnoderecord ADD COLUMN boot_server varchar DEFAULT NULL;
+ALTER TABLE findbadnoderecord_history ADD COLUMN boot_server varchar DEFAULT NULL;
diff --git a/web/MonitorWeb/dev.cfg b/web/MonitorWeb/dev.cfg
index 74cfff6..f165f42 100644
--- a/web/MonitorWeb/dev.cfg
+++ b/web/MonitorWeb/dev.cfg
@@ -31,7 +31,7 @@ server.environment="development"
 autoreload.package="monitorweb"
 
 
-server.socket_host="monitor.planet-lab.org"
+server.socket_host="www.planet-lab.eu"
 server.socket_port=8082
 #server.webpath="/monitor/"
 #base_url_filter.on = False
diff --git a/web/MonitorWeb/monitorweb/controllers.py b/web/MonitorWeb/monitorweb/controllers.py
index b284851..48ec3d2 100644
--- a/web/MonitorWeb/monitorweb/controllers.py
+++ b/web/MonitorWeb/monitorweb/controllers.py
@@ -53,6 +53,7 @@ class NodeQueryFields(widgets.WidgetsList):
 	external_dns_status = widgets.CheckBox(label="Hostname Resolves?")
 	kernel_version = widgets.CheckBox(label="Kernel")
 	bootcd_version = widgets.CheckBox(label="BootCD")
+        boot_server = widgets.CheckBox(label="Boot Server")
 	observed_status = widgets.CheckBox(label="Observed Status")
 	uptime = widgets.CheckBox(label="Uptime")
 	traceroute = widgets.CheckBox(label="Traceroute")
diff --git a/web/MonitorWeb/monitorweb/templates/node_template.kid b/web/MonitorWeb/monitorweb/templates/node_template.kid
index c50a745..e8064a5 100644
--- a/web/MonitorWeb/monitorweb/templates/node_template.kid
+++ b/web/MonitorWeb/monitorweb/templates/node_template.kid
@@ -15,6 +15,7 @@ from links import *
 		<th>pcu</th>
 		<th>kernel</th>
                 <th>BootCD</th>
+                <th>Boot Server</th>
 		<th>last_contact</th>
 	</span>
 	<span py:if="node is not None">
@@ -41,6 +42,7 @@ from links import *
 		</td>
 		<td nowrap="true" py:content="node.kernel"></td>
 		<td nowrap="true" py:content="node.node.bootcd_version"></td>
+		<td nowrap="true" py:content="node.node.boot_server"></td>
 		<td  id="node-${node.node.observed_status}" py:content="diff_time(node.node.plc_node_stats['last_contact'])"></td>
 	</span>
 </span>
diff --git a/web/MonitorWeb/monitorweb/templates/nodefast.kid b/web/MonitorWeb/monitorweb/templates/nodefast.kid
index 97072d2..253dc2f 100644
--- a/web/MonitorWeb/monitorweb/templates/nodefast.kid
+++ b/web/MonitorWeb/monitorweb/templates/nodefast.kid
@@ -17,16 +17,16 @@ from links import *
   </script>
 
   <center>
-  <b py:content="'BOOT: %d' % len([agg for agg in query if agg.node.status == 'good'])"></b> | 
-  <b py:content="'DOWN: %d' % len([agg for agg in query if agg.node.status == 'down'])"></b><br/>
+  <b py:content="'UP: %d' % len([agg for agg in query if agg.node.status in ('online', 'good')])"></b> | 
+  <b py:content="'DOWN: %d' % len([agg for agg in query if agg.node.status not in ('online', 'good')])"></b><br/>
   </center>
 
-<table id="nodelist" cellpadding="0" border="0" class="plekit_table sortable-onload-2 colstyle-alt no-arrow paginationcallback-nodelist_paginator max-pages-10 paginate-25">
+<table id="nodelist" cellpadding="0" border="0" class="plekit_table sortable-onload-2 colstyle-alt no-arrow paginationcallback-nodelist_paginator max-pages-10 paginate-999">
   <thead>
 
     <tr class='pagesize_area'><td class='pagesize_area' colspan='10'>
         <form class='pagesize' action='satisfy_xhtml_validator'><fieldset>
-            <input class='pagesize_input' type='text' id="nodelist_pagesize" value='25'
+            <input class='pagesize_input' type='text' id="nodelist_pagesize" value='999'
                    onkeyup='plekit_pagesize_set("nodelist","nodelist_pagesize", 25);' 
                    size='3' maxlength='3' />                                                          
             <label class='pagesize_label'> items/page </label>                                     
diff --git a/web/MonitorWeb/monitorweb/templates/nodelist.kid b/web/MonitorWeb/monitorweb/templates/nodelist.kid
index e32b92d..771d6b4 100644
--- a/web/MonitorWeb/monitorweb/templates/nodelist.kid
+++ b/web/MonitorWeb/monitorweb/templates/nodelist.kid
@@ -17,8 +17,8 @@ from links import *
   </script>
 
   <center>
-  <b py:content="'BOOT: %d' % len([agg for agg in query if agg.node.observed_status == 'BOOT'])"></b> | 
-  <b py:content="'DOWN: %d' % len([agg for agg in query if agg.node.observed_status == 'DOWN'])"></b><br/>
+  <b py:content="'UP: %d' % len([agg for agg in query if agg.node.status in ('online', 'good')])"></b> | 
+  <b py:content="'DOWN: %d' % len([agg for agg in query if agg.node.status not in ('online', 'good')])"></b><br/>
   </center>
 
 <table id="nodelist" cellpadding="0" border="0" class="plekit_table sortable-onload-2 colstyle-alt no-arrow paginationcallback-nodelist_paginator max-pages-10 paginate-25">
@@ -58,6 +58,7 @@ from links import *
       <th class="sortable plekit_table">pcu</th>
       <th class="sortable plekit_table">kernel</th>
       <th class="sortable plekit_table">BootCD</th>
+      <th class="sortable plekit_table">Boot Server</th>
       <th class="sortable-sortLastContact plekit_table">Last_contact</th>
   </tr>
   </thead>
diff --git a/web/MonitorWeb/monitorweb/templates/nodescanhistory.kid b/web/MonitorWeb/monitorweb/templates/nodescanhistory.kid
index 3c9f84b..7552114 100644
--- a/web/MonitorWeb/monitorweb/templates/nodescanhistory.kid
+++ b/web/MonitorWeb/monitorweb/templates/nodescanhistory.kid
@@ -62,6 +62,7 @@ from cherrypy import request, response
       <th class="sortable plekit_table">Stat</th>
       <th class="sortable plekit_table">kernel</th>
       <th class="sortable plekit_table">BootCD</th>
+      <th class="sortable plekit_table">Boot Server</th>
       <th class="sortable plekit_table">Last_contact</th>
   </tr>
   </thead>
@@ -76,6 +77,7 @@ from cherrypy import request, response
                 <td py:content="node.node.plc_node_stats['boot_state']">boot</td>
 		<td nowrap="true" py:content="node.kernel"></td>
 		<td nowrap="true" py:content="node.node.bootcd_version"></td>
+		<td nowrap="true" py:content="node.node.boot_server"></td>
 		<td  id="node-${node.node.observed_status}" py:content="diff_time(node.node.plc_node_stats['last_contact'])"></td>
 	</span>
     </tr>
-- 
2.47.0