Author: jfthomps
Date: Wed Dec 22 18:06:47 2010
New Revision: 1052017

URL: http://svn.apache.org/viewvc?rev=1052017&view=rev
Log:
VCL-152
problem removing vm from vmhost when vm in reloading state without a reservation

modified AJvmFromHost: reworked code so that it doesn't use computer states, 
but does things based on whether or not there is a reservation for the computer

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

Modified: incubator/vcl/trunk/web/.ht-inc/vm.php
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/vm.php?rev=1052017&r1=1052016&r2=1052017&view=diff
==============================================================================
--- incubator/vcl/trunk/web/.ht-inc/vm.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/vm.php Wed Dec 22 18:06:47 2010
@@ -578,10 +578,26 @@ function AJvmFromHost() {
                        continue;
                }
                # try to remove reservations off of computer
-               if(($compdata[$compid]['state'] == 'available' ||
-                       $compdata[$compid]['state'] == 'maintenance' ||
-                       $compdata[$compid]['state'] == 'failed') &&
-                       moveReservationsOffComputer($compid)) {
+               moveReservationsOffComputer($compid);
+
+               # check for unmovable or active reservations
+               $query = "SELECT DATE_FORMAT(rq.end, '%l:%i%p %c/%e/%y') AS 
end, "
+                      .        "rq.end AS end2 "
+                      . "FROM request rq, "
+                      .      "reservation rs "
+                      . "WHERE rs.requestid = rq.id AND "
+                      .       "rs.computerid = $compid AND "
+                      .       "rq.stateid NOT IN (1,5,12) "
+                      . "ORDER BY end DESC "
+                      . "LIMIT 1";
+               $qh = doQuery($query, 101);
+               if($row = mysql_fetch_assoc($qh)) {
+                       $checks[] = array('id' => $compid,
+                                         'hostname' => 
$compdata[$compid]['hostname'],
+                                         'end' => strtolower($row['end']),
+                                         'end2' => $row['end2']);
+               }
+               else {
                        // if no reservations on computer, submit reload 
                        #    reservation so vm gets stopped on host
                        $reqid = simpleAddRequest($compid, $imageid, 
$imagerevisionid, $start, $end, 18, $vclreloadid);
@@ -597,28 +613,6 @@ function AJvmFromHost() {
                                                'time' => 'immediately');
                        }
                }
-               else {
-                       # existing reservation on computer, find end time and 
prompt user
-                       #   if ok to wait until then to move it
-                       $query = "SELECT DATE_FORMAT(rq.end, '%l:%i%p 
%c/%e/%y') AS end, "
-                              .        "rq.end AS end2 "
-                              . "FROM request rq, "
-                              .      "reservation rs "
-                              . "WHERE rs.requestid = rq.id AND "
-                              .       "rs.computerid = $compid AND "
-                              .       "rq.stateid NOT IN (1,5,12) "
-                              . "ORDER BY end DESC "
-                              . "LIMIT 1";
-                       $qh = doQuery($query, 101);
-                       if($row = mysql_fetch_assoc($qh)) {
-                               $checks[] = array('id' => $compid,
-                                                 'hostname' => 
$compdata[$compid]['hostname'],
-                                                 'end' => 
strtolower($row['end']),
-                                                 'end2' => $row['end2']);
-                       }
-                       else
-                               $rems[] = array('id' => $compid);
-               }
        }
        if(count($checks))
                $cont = addContinuationsEntry('AJvmFromHostDelayed', $checks, 
120, 1, 0);


Reply via email to