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 2010/04/08 16:02:29 UTC

svn commit: r931949 - in /incubator/vcl/trunk/web: .ht-inc/computers.php .ht-inc/vm.php js/vm.js

Author: jfthomps
Date: Thu Apr  8 14:02:29 2010
New Revision: 931949

URL: http://svn.apache.org/viewvc?rev=931949&view=rev
Log:
VCL-233

computers.php: modified submitCompStateChange - added $fails array to track any computers for which simpleAddRequest returned 0 which are then reported by the page output

vm.php:
-modified AJvmFromHost - if simpleAddRequest returns 0, add computer to $fails array with a reason of 'nomgtnode'
-modified AJvmFromHostDelayed - added $fails array to track computers for which simpleAddRequest returns 0 and return with JSON data

vm.js: modified vmFromHostCB and reloadVMhostCB - changed section dealing with fails to print two different messages based on the failed reason

Modified:
    incubator/vcl/trunk/web/.ht-inc/computers.php
    incubator/vcl/trunk/web/.ht-inc/vm.php
    incubator/vcl/trunk/web/js/vm.js

Modified: incubator/vcl/trunk/web/.ht-inc/computers.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/computers.php?rev=931949&r1=931948&r2=931949&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/computers.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/computers.php Thu Apr  8 14:02:29 2010
@@ -2453,9 +2453,6 @@ function submitCompStateChange() {
 		$data["notes"] = $user["unityid"] . " " . unixToDatetime(time()) . "@"
 		               . $data["notes"];
 		$vclreloadid = getUserlistID('vclreload@Local');
-		// get semaphore lock
-		if(! semLock())
-			abort(3);
 		$noaction = array();
 		$changenow = array();
 		$changeasap = array();
@@ -2468,6 +2465,9 @@ function submitCompStateChange() {
 		}
 		$passes = array();
 		$fails = array();
+		// get semaphore lock
+		if(! semLock())
+			abort(3);
 		foreach($changeasap as $compid) {
 			# TODO what about blockComputers?
 			# try to move future reservations off of computer
@@ -2550,7 +2550,7 @@ function submitCompStateChange() {
 		}
 		if(count($fails)) {
 			print "The following computers currently have reservations on them ";
-			print "but no functional management node was found for them. Nothing ";
+			print "but no functional management node was found for them. Nothing will ";
 			print "be done with them at this time:\n";
 			print "<TABLE>\n";
 			print "  <TR>\n";
@@ -2585,16 +2585,20 @@ function submitCompStateChange() {
 			$keys = array_keys($data['profiles']);
 			$profileid = $keys[0];
 		}
+		$vclreloadid = getUserlistID('vclreload@Local');
+		$imagerevisionid = getProductionRevisionid($data['profiles'][$profileid]['imageid']);
 		$noaction = array();
 		$changenow = array();
 		$changeasap = array();
 		$changetimes = array();
+		$fails = array();
 		foreach($data['computerids'] as $compid) {
 			if($computers[$compid]['state'] == 'vmhostinuse')
 				array_push($noaction, $compid);
 			else
 				array_push($changeasap, $compid);
 		}
+		// get semaphore lock
 		if(! semLock())
 			abort(3);
 		foreach($changeasap as $compid) {
@@ -2625,12 +2629,13 @@ function submitCompStateChange() {
 				$end = $start + SECINYEAR; # don't want anyone making a future reservation for this machine
 				$start = unixToDatetime($start);
 				$end = unixToDatetime($end);
-				$imagerevisionid = getProductionRevisionid($data['profiles'][$profileid]['imageid']);
-				$vclreloadid = getUserlistID('vclreload@Local');
-				simpleAddRequest($compid, $data['profiles'][$profileid]['imageid'],
-				                 $imagerevisionid, $start, $end, 21, $vclreloadid);
+				if(simpleAddRequest($compid, $data['profiles'][$profileid]['imageid'],
+				                    $imagerevisionid, $start, $end, 21, $vclreloadid)) {
+					$changenow[] = $compid;
+				}
+				else
+					$fails[] = $compid;
 				unset_by_val($compid, $changeasap);
-				array_push($changenow, $compid);
 
 				# check for existing vmhost entry
 				$query = "SELECT id, "
@@ -2674,6 +2679,19 @@ function submitCompStateChange() {
 			print "</TABLE>\n";
 			print "<br>\n";
 		}
+		if(count($fails)) {
+			print "The following computers had no reservations on them but no ";
+			print "functional management node was found to reload them with the ";
+			print "VM host image. Nothing will be done with them at this time:\n";
+			print "<TABLE>\n";
+			foreach($passes as $compid) {
+				print "  <TR>\n";
+				print "    <TD align=center><font color=\"ff0000\">{$computers[$compid]['hostname']}</font></TD>\n";
+				print "  </TR>\n";
+			}
+			print "</TABLE>\n";
+			print "<br>\n";
+		}
 		if(count($changeasap)) {
 			print "The following computers currently have reservations on them ";
 			print "and cannot be placed in the vmhostinuse state at this time:\n";

Modified: incubator/vcl/trunk/web/.ht-inc/vm.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/vm.php?rev=931949&r1=931948&r2=931949&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/vm.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/vm.php Thu Apr  8 14:02:29 2010
@@ -580,10 +580,17 @@ function AJvmFromHost() {
 			// if no reservations on computer, submit reload 
 			#    reservation so vm gets stopped on host
 			$reqid = simpleAddRequest($compid, 4, 3, $start, $end, 18, $vclreloadid);
-			$rems[] = array('id' => $compid,
-			                'hostname' => $compdata[$compid]['hostname'],
-			                'reqid' => $reqid,
-			                'time' => 'immediately');
+			if($reqid == 0) {
+				$fails[] = array('id' => $compid,
+				                 'name' => $compdata[$compid]['hostname'],
+				                 'reason' => 'nomgtnode');
+			}
+			else {
+				$rems[] = array('id' => $compid,
+				                'hostname' => $compdata[$compid]['hostname'],
+				                'reqid' => $reqid,
+				                'time' => 'immediately');
+			}
 		}
 		else {
 			# existing reservation on computer, find end time and prompt user
@@ -632,14 +639,17 @@ function AJvmFromHost() {
 function AJvmFromHostDelayed() {
 	$data = getContinuationVar();
 	$vclreloadid = getUserlistID('vclreload@Local');
+	$fails = array();
 	foreach($data as $comp) {
 		$end = datetimeToUnix($comp['end2']) + SECINMONTH;
 		$end = unixToDatetime($end);
-		simpleAddRequest($comp['id'], 4, 3, $comp['end2'], $end, 18, $vclreloadid);
+		if(! simpleAddRequest($comp['id'], 4, 3, $comp['end2'], $end, 18, $vclreloadid))
+			$fails[] = array('name' => $comp['hostname'],
+			                 'reason' => 'nomgtnode');
 	}
 	header('Content-Type: text/json-comment-filtered; charset=utf-8');
 	$cont = addContinuationsEntry('vmhostdata');
-	$arr = array('msg' => 'SUCCESS', 'cont' => $cont);
+	$arr = array('msg' => 'SUCCESS', 'cont' => $cont, 'fails' => $fails);
 	print '/*{"items":' . json_encode($arr) . '}*/';
 }
 

Modified: incubator/vcl/trunk/web/js/vm.js
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/js/vm.js?rev=931949&r1=931948&r2=931949&view=diff
==============================================================================
--- incubator/vcl/trunk/web/js/vm.js (original)
+++ incubator/vcl/trunk/web/js/vm.js Thu Apr  8 14:02:29 2010
@@ -431,11 +431,18 @@ function vmFromHostCB(data, ioArgs) {
 	}
 
 	if(fails.length) {
-		var msg = 'You do not have access to remove the following vm(s):\n\n';
+		var msg1 = '';
+		var msg2 = '';
 		for(var i = 0; i < fails.length; i++) {
-			msg += fails[i].name + '\n';
+			if(fails[i].reason == 'noaccess')
+				msg1 += fails[i].name + '\n';
+			else if(fails[i].reason == 'nomgtnode')
+				msg2 += fails[i].name + '\n';
 		}
-		alert(msg);
+		if(msg1.length)
+			alert('You do not have access to remove the following vm(s):\n\n' + msg1);
+		if(msg2.length)
+			alert('The following vms could not be removed because no management node was available for them:\n\n' + msg2);
 	}
 
 	var checks = data.items.checks;
@@ -471,12 +478,19 @@ function reloadVMhostCB(data, ioArgs) {
 		document.body.style.cursor = 'default';
 		return;
 	}
-	if(data.items.failed && data.items.fails.length) {
-		var msg = 'You do not have access to remove the following vm(s):\n\n';
+	if(data.items.fails.length) {
+		var msg1 = '';
+		var msg2 = '';
 		for(var i = 0; i < data.items.fails.length; i++) {
-			msg += data.items.fails[i].name + '\n';
+			if(data.items.fails[i].reason == 'noaccess')
+				msg1 += data.items.fails[i].name + '\n';
+			else if(data.items.fails[i].reason == 'nomgtnode')
+				msg2 += data.items.fails[i].name + '\n';
 		}
-		alert(msg);
+		if(msg1.length)
+			alert('You do not have access to remove the following vm(s):\n\n' + msg1);
+		if(msg2.length)
+			alert('No management node was available to move the following VMs off of this host; therefore, nothing will be done at this time:\n\n' + msg2);
 	}
 	if(data.items.msg == 'SUCCESS')
 		getVMHostData(data.items.cont);