vcl-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jftho...@apache.org
Subject svn commit: r753339 - in /incubator/vcl/trunk/web/.ht-inc: images.php requests.php utils.php
Date Fri, 13 Mar 2009 18:41:02 GMT
Author: jfthomps
Date: Fri Mar 13 18:40:59 2009
New Revision: 753339

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

utils.php:
-modified isAvailable to have an additional optional argument named forimaging that, when
set, will only allocate a single computer for images that have subimages instead of allocating
the whole cluster
-modified getUserRequests:
  -added forcheckout as a returned index
  -fixed bug in query for subreservations where $id was set to user's numeric id
  -only restrict primary query to include 'forcheckout = 1' when $type = 'normal'
  -added array to track fetched requests so that don't duplicate requests for cluster reservations

requests.php:
-modified viewRequests: added check to keep requests with forcheckout and forimaging both
set to 0 from being displayed (may never happen anyway)
-modified viewRequestInfo, editRequest, confirmEditRequest, confirmDeleteRequest, and submitDeleteRequest
to set $reservation in a way that works with cluster reservations
-modified editRequest to not print option to save/update image if request is an imaging reservation

images.php:
-modified submitCreateImage to call isAvailable with new forimgaging argument

Modified:
    incubator/vcl/trunk/web/.ht-inc/images.php
    incubator/vcl/trunk/web/.ht-inc/requests.php
    incubator/vcl/trunk/web/.ht-inc/utils.php

Modified: incubator/vcl/trunk/web/.ht-inc/images.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/images.php?rev=753339&r1=753338&r2=753339&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/images.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/images.php Fri Mar 13 18:40:59 2009
@@ -949,7 +949,7 @@
 		print "</FORM>\n";
 		return;
 	}
-	$rc = isAvailable($images, $data["imageid"], $start, $end, $data["os"]);
+	$rc = isAvailable($images, $data["imageid"], $start, $end, $data["os"], 0, 0, 0, 1);
 	if($rc == -1) {
 		$printedHTMLheader = 1;
 		print $HTMLheader;

Modified: incubator/vcl/trunk/web/.ht-inc/requests.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/requests.php?rev=753339&r1=753338&r2=753339&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/requests.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/requests.php Fri Mar 13 18:40:59 2009
@@ -1622,6 +1622,9 @@
 		for($i = 0, $noedit = 0, $text = '';
 		   $i < $count;
 		   $i++, $noedit = 0, $text = '') {
+			if($requests[$i]['forcheckout'] == 0 &&
+			   $requests[$i]['forimaging'] == 0)
+				continue;
 			$imageid = $requests[$i]["imageid"];
 			$text .= "  <TR valign=top id=reqrow{$requests[$i]['id']}>\n";
 			if(requestIsReady($requests[$i])) {
@@ -2211,10 +2214,14 @@
 function viewRequestInfo() {
 	$requestid = processInputVar("requestid", ARG_NUMERIC);
 	$request = getRequestInfo($requestid);
-	foreach($request["reservations"] as $res) {
-		if($res["forcheckout"]) {
-			$prettyimage = $res["prettyimage"];
-			break;
+	if($request['forimaging'])
+		$reservation = $request['reservations'][0];
+	else {
+		foreach($request["reservations"] as $res) {
+			if($res["forcheckout"]) {
+				$reservation = $res;
+				break;
+			}
 		}
 	}
 	$states = getStates();
@@ -2228,7 +2235,7 @@
 	print "  </TR>\n";
 	print "  <TR>\n";
 	print "    <TH align=right>Requested&nbsp;Image:</TH>\n";
-	print "    <TD>$prettyimage</TD>\n";
+	print "    <TD>{$reservation['prettyimage']}</TD>\n";
 	print "  </TR>\n";
 	print "  <TR>\n";
 	print "    <TH align=right>Start&nbsp;Time:</TH>\n";
@@ -2316,10 +2323,14 @@
 		viewRequests();
 		return;
 	}
-	foreach($request["reservations"] as $res) {
-		if($res["forcheckout"]) {
-			$reservation = $res;
-			break;
+	if($request['forimaging'])
+		$reservation = $request['reservations'][0];
+	else {
+		foreach($request["reservations"] as $res) {
+			if($res["forcheckout"]) {
+				$reservation = $res;
+				break;
+			}
 		}
 	}
 	if($submitErr) {
@@ -2508,6 +2519,9 @@
 	print "  </TR>\n";
 	print "</table>\n";
 
+	if($request['forimaging'])
+		return;
+
 	printEditNewUpdate($request, $res);
 }
 
@@ -2698,10 +2712,14 @@
 	}
 	$cdata = getContinuationVar();
 	$request = getRequestInfo($cdata["requestid"]);
-	foreach($request["reservations"] as $res) {
-		if($res["forcheckout"]) {
-			$reservation = $res;
-			break;
+	if($request['forimaging'])
+		$reservation = $request['reservations'][0];
+	else {
+		foreach($request["reservations"] as $res) {
+			if($res["forcheckout"]) {
+				$reservation = $res;
+				break;
+			}
 		}
 	}
 	print "<H2>Modify Reservation</H2>\n";
@@ -3041,12 +3059,14 @@
 function confirmDeleteRequest() {
 	$requestid = getContinuationVar('requestid', 0);
 	$request = getRequestInfo($requestid);
-	# FIXME if an imaging reservation for a non-checkout image, this will result
-	#   in $reservation not being set
-	foreach($request["reservations"] as $res) {
-		if($res["forcheckout"]) {
-			$reservation = $res;
-			break;
+	if($request['forimaging'])
+		$reservation = $request['reservations'][0];
+	else {
+		foreach($request["reservations"] as $res) {
+			if($res["forcheckout"]) {
+				$reservation = $res;
+				break;
+			}
 		}
 	}
 	if(datetimeToUnix($request["start"]) > time()) {
@@ -3141,10 +3161,14 @@
 function submitDeleteRequest() {
 	$requestid = getContinuationVar('requestid', 0);
 	$request = getRequestInfo($requestid);
-	foreach($request["reservations"] as $res) {
-		if($res["forcheckout"]) {
-			$reservation = $res;
-			break;
+	if($request['forimaging'])
+		$reservation = $request['reservations'][0];
+	else {
+		foreach($request["reservations"] as $res) {
+			if($res["forcheckout"]) {
+				$reservation = $res;
+				break;
+			}
 		}
 	}
 	deleteRequest($request);

Modified: incubator/vcl/trunk/web/.ht-inc/utils.php
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/utils.php?rev=753339&r1=753338&r2=753339&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/utils.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/utils.php Fri Mar 13 18:40:59 2009
@@ -3373,7 +3373,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 ///
 /// \fn isAvailable($images, $imageid, $start, $end, $os, $requestid,
-///                          $userid, $ignoreprivileges)
+///                          $userid, $ignoreprivileges, $forimaging)
 ///
 /// \param $images - array as returned from getImages
 /// \param $imageid - imageid from the image table
@@ -3388,6 +3388,8 @@
 /// to 1 to look for computers from any that are mapped to be able to run the
 /// image; set to 0 to only look for computers from ones that are both mapped
 /// and that $userid has been granted access to through the privilege tree
+/// \param $forimaging - (optional, default=0) - 0 if normal reservation, 1 if
+/// an imaging reservation
 ///
 /// \return -1 if $imageid is limited in the number of concurrent reservations
 ///         available, and the limit has been reached
@@ -3398,7 +3400,7 @@
 ///
 ////////////////////////////////////////////////////////////////////////////////
 function isAvailable($images, $imageid, $start, $end, $os, $requestid=0,
-                     $userid=0, $ignoreprivileges=0) {
+                     $userid=0, $ignoreprivileges=0, $forimaging=0) {
 	global $requestInfo;
 	$requestInfo["start"] = $start;
 	$requestInfo["end"] = $end;
@@ -3455,7 +3457,7 @@
 	$requestInfo["images"][0] = $imageid;
 
 	# loop to check for available computers for all needed images
-	if($images[$imageid]["imagemetaid"] != NULL) {
+	if(! $forimaging && $images[$imageid]["imagemetaid"] != NULL) {
 		$count = 1;
 		foreach($images[$imageid]["subimages"] as $imgid) {
 			$requestInfo['computers'][$count] = 0;
@@ -4685,6 +4687,7 @@
 /// \b currstateid - current stateid of request\n
 /// \b laststateid - last stateid of request\n
 /// \b forimaging - 0 if an normal request, 1 if imaging request\n
+/// \b forcheckout - 1 if image is available for reservations, 0 if not\n
 /// \b test - test flag - 0 or 1\n
 /// \b longterm - 1 if request length is > 24 hours\n
 /// \b resid - id of primary reservation\n
@@ -4731,6 +4734,7 @@
 	       .        "c.IPaddress, "
 	       .        "c.type AS comptype, "
 	       .        "rq.forimaging, "
+	       .        "i.forcheckout, "
 	       .        "rq.test "
 	       . "FROM request rq, "
 	       .      "reservation rs, "
@@ -4744,15 +4748,16 @@
 	       .       "i.OSid = o.id AND "
 	       .       "c.id = rs.computerid AND "
 	       .       "rq.stateid NOT IN (1, 10, 16, 17) AND "      # deleted, maintenance, complete,
image, makeproduction
-	       .       "rq.laststateid NOT IN (1, 10, 16, 17) AND "  # deleted, maintenance, complete,
image, makeproduction
-	       .       "i.forcheckout = 1 ";
+	       .       "rq.laststateid NOT IN (1, 10, 16, 17) ";  # deleted, maintenance, complete,
image, makeproduction
 	if($type == "normal")
-		$query .=   "AND rq.forimaging = 0 ";
+		$query .=   "AND rq.forimaging = 0 "
+		       .    "AND i.forcheckout = 1 ";
 	if($type == "forimaging")
 		$query .=   "AND rq.forimaging = 1 ";
-	$query .= "ORDER BY rq.start";
+	$query .= "ORDER BY rq.start, "
+	       .           "rs.id";
 
-	$query2 = "SELECT rs.id AS resid, "
+	$qbase2 = "SELECT rs.id AS resid, "
 	        .        "i.name AS image, "
 	        .        "i.prettyname, "
 	        .        "i.id AS imageid, "
@@ -4766,21 +4771,26 @@
 	        .      "image i, "
 	        .      "OS o, "
 	        .      "computer c "
-	        . "WHERE rs.requestid = $id AND "
-	        .       "rs.imageid = i.id AND "
+	        . "WHERE rs.imageid = i.id AND "
 	        .       "rs.computerid = c.id AND "
 	        .       "i.OSid = o.id AND "
-	        .       "i.forcheckout = 0";
+	        .       "rs.id != %d AND "
+	        .       "rs.requestid = %d";
 	$qh = doQuery($query, 160);
 	$count = 0;
 	$data = array();
+	$foundids = array();
 	while($row = mysql_fetch_assoc($qh)) {
+		if(array_key_exists($row['id'], $foundids))
+			continue;
+		$foundids[$row['id']] = 1;
 		$data[$count] = $row;
 		if((datetimeToUnix($row['end']) - datetimeToUnix($row['start'])) > SECINDAY)
 			$data[$count]['longterm'] = 1;
 		else
 			$data[$count]['longterm'] = 0;
 		$data[$count]["reservations"] = array();
+		$query2 = sprintf($qbase2, $row['resid'], $row['id']);
 		$qh2 = doQuery($query2, 160);
 		while($row2 = mysql_fetch_assoc($qh2)) {
 			array_push($data[$count]["reservations"], $row2);
@@ -8413,7 +8423,7 @@
 	global $shibauthed;
 	$setwrapreferer = processInputVar('am', ARG_NUMERIC, 0);
 	if(! $authed && $mode == "auth") {
-		/*if($oldmode != "auth" && $oldmode != "" && array_key_exists('mode', $_GET))
{
+		if($oldmode != "auth" && $oldmode != "" && array_key_exists('mode', $_GET))
{
 			$cookieHeaderString = "WRAP_REFERER=" . BASEURL . SCRIPT . "?mode=$oldmode; path=/; domain="
. COOKIEDOMAIN;
 			$itecscookie = BASEURL . SCRIPT . "?mode=$oldmode";
 		}
@@ -8423,7 +8433,7 @@
 		}
 		header("Set-Cookie: $cookieHeaderString");
 		setcookie("ITECSAUTH_RETURN", "$itecscookie", 0, "/", COOKIEDOMAIN);
-		setcookie("ITECSAUTH_CSS", "vcl.css", 0, "/", COOKIEDOMAIN);*/
+		setcookie("ITECSAUTH_CSS", "vcl.css", 0, "/", COOKIEDOMAIN);
 		header("Location: " . BASEURL . SCRIPT . "?mode=selectauth");
 		dbDisconnect();
 		exit;



Mime
View raw message