You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2014/10/14 18:31:54 UTC

svn commit: r1631812 - in /vcl/trunk/web: .ht-inc/dashboard.php .ht-inc/utils.php js/dashboard.js

Author: jfthomps
Date: Tue Oct 14 16:31:53 2014
New Revision: 1631812

URL: http://svn.apache.org/r1631812
Log:
VCL-531 - additions to dashboard
VCL-773 - Dashboard View Update

dashboard.php:
-modified dashboard: moved blockallocation block to end of left column; added managementnodes block to top of right column
-modified AJupdateDashboard: added call to getManagementNodeData to include management node information with returned data
-modified getNewReservationData and getFailedImagingData: added code to honor selected affiliation
-added getManagementNodeData

utils.php: modified getDojoHTML: added dojox.string.sprintf to dashboard dojo includes

dashboard.js:
-modified updateDashboardCB: added call to clearTimeout for refreshtimer before calling setTimeout for it again, there was a problem where selecting an affiliation would cause lots of refreshes of the data; added call to updateManagementNodes
-modified updateNewReservations: added section for displaying user information
-added updateManagementNodes
-added secToMin
-added secToHour

Modified:
    vcl/trunk/web/.ht-inc/dashboard.php
    vcl/trunk/web/.ht-inc/utils.php
    vcl/trunk/web/js/dashboard.js

Modified: vcl/trunk/web/.ht-inc/dashboard.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/dashboard.php?rev=1631812&r1=1631811&r2=1631812&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/dashboard.php (original)
+++ vcl/trunk/web/.ht-inc/dashboard.php Tue Oct 14 16:31:53 2014
@@ -47,13 +47,14 @@ function dashboard() {
 	print addWidget('toplongimages', 'Top 5 Long Term Images in Use', '(Reservations > 24 hours long)');
 	print addWidget('toppastimages', 'Top 5 Images From Past Day', '(Reservations with a start<br>time within past 24 hours)');
 	print addWidget('topfailedcomputers', 'Top Recent Computer Failures', '(Failed in the last 5 days)');
+	print addWidget('blockallocation', 'Block Allocation Status');
 	print "</td>\n";
 	# -------- end left column ---------
 
 	# ---------- right column ---------
 	print "<td valign=\"top\">\n";
+	print addWidget('managementnodes', 'Management Nodes', '[ ] denotes node in maintenance state');
 	print addWidget('topfailed', 'Top Recent Image Failures', '(Failed in the last 5 days)');
-	print addWidget('blockallocation', 'Block Allocation Status');
 	print addLineChart('reschart', 'Past 12 Hours of Active Reservations');
 	print "</td>\n";
 	# -------- end right column --------
@@ -87,6 +88,7 @@ function AJupdateDashboard() {
 	$data['blockallocation'] = getBlockAllocationData();
 	$data['newreservations'] = getNewReservationData();
 	$data['failedimaging'] = getFailedImagingData();
+	$data['managementnodes'] = getManagementNodeData();
 	sendJSON($data);
 }
 
@@ -660,13 +662,15 @@ function getBlockAllocationData() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getNewReservationData() {
+	$affilid = getDashboardAffilID();
 	$query = "SELECT c.hostname AS computer, "
 	       .        "i.prettyname AS image, "
 	       .        "rq.id, "
 	       .        "rq.start, "
 	       .        "CONCAT(s1.name, '|', s2.name) AS state, "
 	       .        "o.installtype, "
-	       .        "m.hostname AS managementnode "
+	       .        "m.hostname AS managementnode, "
+	       .        "CONCAT(u.unityid, '@', af.name) AS user "
 	       . "FROM request rq "
 	       . "LEFT JOIN reservation rs ON (rs.requestid = rq.id) "
 	       . "LEFT JOIN computer c ON (c.id = rs.computerid) "
@@ -675,10 +679,15 @@ function getNewReservationData() {
 	       . "LEFT JOIN state s1 ON (s1.id = rq.stateid) "
 	       . "LEFT JOIN state s2 ON (s2.id = rq.laststateid) "
 	       . "LEFT JOIN managementnode m ON (m.id = rs.managementnodeid) "
-	       . "WHERE (rq.stateid IN (6, 13, 19) AND rq.start < NOW()) OR "
+	       . "LEFT JOIN user u ON (u.id = rq.userid) "
+	       . "LEFT JOIN user u2 ON (u2.id = c.ownerid) "
+	       . "LEFT JOIN affiliation af ON (af.id = u.affiliationid) "
+	       . "WHERE ((rq.stateid IN (6, 13, 19) AND rq.start < NOW()) OR "
 	       .       "(rq.stateid = 14 AND rq.laststateid IN (6, 13, 16, 19) AND "
-	       .       "rq.start < DATE_ADD(NOW(), INTERVAL 1 HOUR)) "
-	       . "ORDER BY rq.start";
+			 .       "rq.start < DATE_ADD(NOW(), INTERVAL 1 HOUR))) ";
+	if($affilid)
+		$query .= "AND (u.affiliationid = $affilid OR u2.affiliationid = $affilid) ";
+	$query .= "ORDER BY rq.start";
 	$qh = doQuery($query, 101);
 	$data = array();
 	while($row = mysql_fetch_assoc($qh)) {
@@ -710,6 +719,7 @@ function getNewReservationData() {
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function getFailedImagingData() {
+	$affilid = getDashboardAffilID();
 	$query = "SELECT c.hostname AS computer, "
 	       .        "i.prettyname AS image, "
 	       .        "rq.id, "
@@ -727,9 +737,12 @@ function getFailedImagingData() {
 	       . "LEFT JOIN vmhost vh ON (c.vmhostid = vh.id) "
 	       . "LEFT JOIN computer ch ON (vh.computerid = ch.id) "
 	       . "LEFT JOIN user u ON (rq.userid = u.id) "
+	       . "LEFT JOIN user u2 ON (u2.id = c.ownerid) "
 	       . "WHERE rq.stateid = 10 AND "
-	       .       "rq.laststateid = 16 "
-	       . "ORDER BY rq.start";
+	       .       "rq.laststateid = 16 ";
+	if($affilid)
+		$query .= "AND (u.affiliationid = $affilid OR u2.affiliationid = $affilid) ";
+	$query .= "ORDER BY rq.start";
 	$qh = doQuery($query, 101);
 	$data = array();
 	while($row = mysql_fetch_assoc($qh)) {
@@ -751,6 +764,61 @@ function getFailedImagingData() {
 
 ////////////////////////////////////////////////////////////////////////////////
 ///
+/// \fn getManagementNodeData()
+///
+/// \return array of data with these keys:\n
+/// \b computer - hostname of computer (without domain)\n
+/// \b image - image being loaded\n
+/// \b id - id of request\n
+/// \b start - start date\n
+/// \b state - current and last state\n
+/// \b installtype - install for reservation\n
+/// \b managementnode - hostname of mangementnode
+///
+/// \brief gets information about management nodes
+///
+////////////////////////////////////////////////////////////////////////////////
+function getManagementNodeData() {
+	$affilid = getDashboardAffilID();
+	$query = "SELECT m.hostname, "
+	       .        "UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(m.lastcheckin) AS checkin, "
+	       .        "COUNT(rs2.id) as processing, "
+	       .        "m.stateid "
+	       . "FROM managementnode m "
+	       . "LEFT JOIN reservation rs ON (rs.managementnodeid = m.id) "
+	       . "LEFT JOIN request rq ON (rq.id = rs.requestid) "
+	       . "LEFT JOIN reservation rs2 ON (rs.id = rs2.id AND "
+	       .                               "rs2.requestid = rq.id AND "
+	       .                               "rq.start < NOW() AND "
+	       .                               "rq.end > NOW()) "
+	       . "LEFT JOIN user u ON (u.id = m.ownerid) "
+			 . "WHERE m.stateid IN (2, 10) ";
+	if($affilid)
+		$query .= "AND u.affiliationid = $affilid ";
+	$query .= "GROUP BY m.id "
+	       .  "ORDER BY m.stateid, m.hostname";
+	$qh = doQuery($query);
+	$current = array();
+	$old = array();
+	$never = array();
+	while($row = mysql_fetch_assoc($qh)) {
+		$tmp = explode('.', $row['hostname']);
+		$row['hostname'] = $tmp[0];
+		if($row['checkin'] < 0)
+			$row['checkin'] = 0;
+		if($row['checkin'] === null)
+			$never[] = $row;
+		elseif($row['checkin'] < 86400)
+			$current[] = $row;
+		else
+			$old[] = $row;
+	}
+	$data = array_merge($current, $old, $never);
+	return $data;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+///
 /// \fn restartImageCapture()
 ///
 /// \return array of data with these keys:\n

Modified: vcl/trunk/web/.ht-inc/utils.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/utils.php?rev=1631812&r1=1631811&r2=1631812&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/utils.php (original)
+++ vcl/trunk/web/.ht-inc/utils.php Tue Oct 14 16:31:53 2014
@@ -12826,17 +12826,9 @@ function getDojoHTML($refresh) {
 			                      'dojox.charting.widget.Chart2D',
 			                      'dojox.charting.action2d.Tooltip',
 			                      'dojox.charting.action2d.Magnify',
-			                      'dojox.charting.themes.ThreeD');
+			                      'dojox.charting.themes.ThreeD',
+			                      'dojox.string.sprintf');
 			break;
-		# TODO clean up
-		/*case 'testDojoREST':
-			$filename = '';
-			$dojoRequires = array('dojo.parser',
-			                      'dijit.form.FilteringSelect',
-			                      'dijit.form.Button',
-			                      'dojo.data.ObjectStore',
-			                      'dojo.store.JsonRest');
-			break;*/
 		case 'siteconfig':
 			$filename = 'siteconfig.js';
 			$dojoRequires = array('dojo.parser',
@@ -12849,6 +12841,15 @@ function getDojoHTML($refresh) {
 			                      'dijit.layout.ContentPane',
 			                      'dijit.layout.TabContainer');
 			break;
+		# TODO clean up
+		/*case 'testDojoREST':
+			$filename = '';
+			$dojoRequires = array('dojo.parser',
+			                      'dijit.form.FilteringSelect',
+			                      'dijit.form.Button',
+			                      'dojo.data.ObjectStore',
+			                      'dojo.store.JsonRest');
+			break;*/
 	}
 	# END DOJO PARSING
 	if(empty($dojoRequires))

Modified: vcl/trunk/web/js/dashboard.js
URL: http://svn.apache.org/viewvc/vcl/trunk/web/js/dashboard.js?rev=1631812&r1=1631811&r2=1631812&view=diff
==============================================================================
--- vcl/trunk/web/js/dashboard.js (original)
+++ vcl/trunk/web/js/dashboard.js Tue Oct 14 16:31:53 2014
@@ -43,7 +43,9 @@ function updateDashboardCB(data, ioArgs)
 		updateNewReservations(data.items.newreservations);
 	if(dojo.byId('failedimaging'))
 		updateFailedImaging(data.items.failedimaging);
+	clearTimeout(refreshtimer);
 	refreshtimer = setTimeout(updateDashboard, 15000);
+	updateManagementNodes(data.items.managementnodes);
 }
 
 function updateStatus(data) {
@@ -199,6 +201,7 @@ function updateNewReservations(data) {
 	txt += '<tr>'
 	    +  '<th>Start</th>'
 	    +  '<th>ReqID</th>'
+	    +  '<th>User</th>'
 	    +  '<th>Computer</th>'
 	    +  '<th>States</th>'
 	    +  '<th>Image</th>'
@@ -215,6 +218,8 @@ function updateNewReservations(data) {
 		    + '</td><td style=\"padding: 1px; border-right: 1px solid;\">'
 		    + data[i].id
 		    + '</td><td style=\"padding: 1px; border-right: 1px solid;\">'
+		    + data[i].user
+		    + '</td><td style=\"padding: 1px; border-right: 1px solid;\">'
 		    + data[i].computer
 		    + '</td><td style=\"padding: 1px; border-right: 1px solid;\">'
 		    + data[i].state
@@ -285,6 +290,50 @@ function updateFailedImaging(data) {
 	}
 }
 
+function updateManagementNodes(data) {
+	var obj = dojo.byId('managementnodes');
+	var txt = '<table>';
+	txt += '<tr>'
+	    +  '<td></td>'
+	    +  '<th>Time Since<br>Check-in</th>'
+	    +  '<th>Reservations<br>Processing</th>'
+	    +  '</tr>';
+	for(var i = 0; i < data.length; i++) {
+		txt += '<tr><th align="right">'
+		if(data[i].stateid == 10)
+			txt += '<span class=dashmnmaint>'
+			    +  '[ ' + data[i].hostname
+			    + ' ]</span></th><td>';
+		else
+			txt += data[i].hostname
+			    + '</th><td>';
+		if(data[i].checkin == null)
+			txt += '<span>never'
+		else if(data[i].checkin < 60)
+			txt += '<span class="ready">'
+			    + data[i].checkin
+			    + ' second(s)';
+		else if(data[i].checkin < 120)
+			txt += '<span class="wait">'
+			    + data[i].checkin
+			    + ' seconds';
+		else if(data[i].checkin < 86400) {
+			txt += '<span class="rederrormsg">';
+			if(data[i].checkin < 3600)
+				txt += secToMin(data[i].checkin);
+			else
+				txt += secToHour(data[i].checkin);
+		}
+		else
+			txt += '<span class="rederrormsg">&gt; 24 hours';
+		txt += '</span></td><td>'
+		    +  data[i].processing
+		    +  '</td></tr>';
+	}
+	txt += '</table>';
+	obj.innerHTML = txt;
+}
+
 function restartImagingCB(data, ioArgs) {
 	if(data.items.status == 'noaccess') {
 		alert('You do not have access to restart the imaging process for this reservation');
@@ -305,3 +354,15 @@ function timestampToTime(val) {
 		var data = dijit.byId('reschart').chart.labeldata;
 	return data[val]['text'];
 }
+
+function secToMin(time) {
+	var min = parseInt(time / 60);
+	var sec = time - (min * 60);
+	return dojox.string.sprintf('%d:%02d minute(s)', min, sec);
+}
+
+function secToHour(time) {
+	var hour = parseInt(time / 3600);
+	var min = parseInt((time - (hour * 3600)) / 60);
+	return dojox.string.sprintf('%d:%02d hour(s)', hour, min);
+}