svn commit: r995535 - in /incubator/vcl/trunk/managementnode/lib/VCL/Module: OS/Windows/Version_5.pm OS/Windows/Version_6.pm Provisioning.pm

2010-09-09 Thread arkurth
Author: arkurth
Date: Thu Sep  9 18:43:46 2010
New Revision: 995535

URL: http://svn.apache.org/viewvc?rev=995535view=rev
Log:
VCL-164
Added commands to Version_6.pm::run_sysprep to set the interfaces to use DHCP 
immediately before Sysprep.exe is run since the call to enable DHCP in 
Windows.pm::pre_capture was removed.  Also added commands to delete the default 
routes so that the persistent routes are not saved in the image.  This now 
matches the way sysprep.exe is called for version 5.x.

Added Provisioning.pm::wait_for_power_off() subroutine. Updated run_sysprep 
subroutines to call wait_for_power_off after sysprep.exe is executed.

Modified:
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning.pm

Modified: 
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm?rev=995535r1=995534r2=995535view=diff
==
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm 
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm 
Thu Sep  9 18:43:46 2010
@@ -292,7 +292,7 @@ sub run_sysprep {
# Run Sysprep.exe
$sysprep_command .= C:/Sysprep/sysprep.exe /quiet /reseal /mini 
/forceshutdown  ;

-   # Shutdown the computer - Sysprep does not always shut the computer down
+   # Shutdown the computer - Sysprep does not always shut the computer 
down automatically
$sysprep_command .= $system32_path/shutdown.exe -s -t 0 -f;
$sysprep_command .= \;

@@ -315,19 +315,19 @@ sub run_sysprep {
notify($ERRORS{'WARNING'}, 0, $computer_node_name never became 
unresponsive to ping);
return 0;
}
-
-   # Wait for 3 minutes then call provisioning module's power_off() 
subroutine
-   # Sysprep does not always shut down the computer when it is done
-   notify($ERRORS{'OK'}, 0, sleeping for 3 minutes to allow Sysprep.exe 
to finish);
-   sleep 180;
-
-   # Call power_off() to make sure computer is shut down
-   if (!$self-provisioner-power_off()) {
-   # Computer could not be shut off
-   notify($ERRORS{'WARNING'}, 0, unable to power off 
$computer_node_name);
-   return 0;
+   
+   # Wait maximum of 10 minutes for computer to power off
+   my $power_off = $self-provisioner-wait_for_power_off(600);
+   if (!defined($power_off)) {
+   # wait_for_power_off result will be undefined if the 
provisioning module doesn't implement a power_status subroutine
+   notify($ERRORS{'OK'}, 0, unable to determine power status of 
$computer_node_name from provisioning module, sleeping 5 minutes to allow 
computer time to power off);
+   sleep 300;
}
-
+   elsif (!$power_off) {
+   notify($ERRORS{'WARNING'}, 0, $computer_node_name never 
powered off after running sysprep.exe);
+   return;
+   }
+   
return 1;
 }
 

Modified: 
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm?rev=995535r1=995534r2=995535view=diff
==
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm 
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm 
Thu Sep  9 18:43:46 2010
@@ -1583,7 +1583,32 @@ EOF
$self-run_slmgr_dlv();

# Run Sysprep.exe, use cygstart to lauch the .exe and return immediately
-   my $sysprep_command = /bin/cygstart.exe cmd.exe /c 
\$system32_path_dos\\sysprep\\sysprep.exe /generalize /oobe /shutdown /quiet 
/unattend:$system32_path_dos\\sysprep\\Unattend.xml\;
+   my $sysprep_command = /bin/cygstart.exe cmd.exe /c \;
+   
+   # First enable DHCP on the private and public interfaces and delete the 
default route
+   my $private_interface_name = $self-get_private_interface_name();
+   my $public_interface_name = $self-get_public_interface_name();
+   if (!$private_interface_name || !$public_interface_name) {
+   notify($ERRORS{'WARNING'}, 0, unable to determine private and 
public interface names, failed to enable DHCP and shut down 
$computer_node_name);
+   return;
+   }
+   
+   # Release any DHCP addresses and delete the default route
+   $sysprep_command .= $system32_path/ipconfig.exe /release  ;
+   $sysprep_command .= $system32_path/route.exe DELETE 0.0.0.0 MASK 
0.0.0.0  ;
+   
+   # Disable DHCP
+   

svn commit: r995564 - /incubator/vcl/trunk/web/.ht-inc/utils.php

2010-09-09 Thread jfthomps
Author: jfthomps
Date: Thu Sep  9 20:23:14 2010
New Revision: 995564

URL: http://svn.apache.org/viewvc?rev=995564view=rev
Log:
VCL-378
reservation can be extended into a block allocation for user not in block group

-modified isAvailable - changed $skipRemoveUsedBlock to $altRemoveBlockCheck, 
then toward end of foreach, if $altRemoveBlockCheck is true, call 
editRequestBlockCheck and return 0 if it returns true
-added editRequestBlockCheck - checks to see if $compid is part of an upcoming 
block that user is not part of or for a different image

-modified maintenanceCheck - if no files in maintenance directory, $files is 
not an array and is then invalid for foreach; added check for it being an array 
to surpress the warning

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

Modified: incubator/vcl/trunk/web/.ht-inc/utils.php
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/web/.ht-inc/utils.php?rev=995564r1=995563r2=995564view=diff
==
--- incubator/vcl/trunk/web/.ht-inc/utils.php (original)
+++ incubator/vcl/trunk/web/.ht-inc/utils.php Thu Sep  9 20:23:14 2010
@@ -554,6 +554,8 @@ function maintenanceCheck() {
$search = preg_replace($reg, '', $_SERVER['SCRIPT_FILENAME']);
$search .= /.ht-inc/maintenance/;
$files = glob($search*);
+   if(! is_array($files))
+   return;
$inmaintenance = 0;
foreach($files as $file) {
if(! 
preg_match(|^$search([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$|, 
$file, $matches))
@@ -3475,11 +3477,11 @@ function isAvailable($images, $imageid, 
$computerids = array();
$currentids = array();
$blockids = array();
-   $skipRemoveUsedBlock = 0;
+   $altRemoveBlockCheck = 0;
// if we are modifying a request and it is after the start 
time, only allow
// the scheduled computer(s) to be modified
if($requestid  datetimeToUnix($requestData[start]) = 
time()) {
-   $skipRemoveUsedBlock = 1;
+   $altRemoveBlockCheck = 1;
foreach($requestData[reservations] as $key2 = $res) {
if($res[imageid] == $imageid) {
$compid = $res[computerid];
@@ -3576,7 +3578,13 @@ function isAvailable($images, $imageid, 
$blockids = array_diff($blockids, $usedComputerids);
 
# remove computers from list that are allocated to block 
allocations
-   if(! count($blockids)  ! $skipRemoveUsedBlock) {
+   if($altRemoveBlockCheck) {
+   if(editRequestBlockCheck($computerids[0], $imageid, 
$start, $end)) {
+   semUnlock();
+   return 0;
+   }
+   }
+   elseif(! count($blockids)) {  #  ! $altRemoveBlockCheck
$usedBlockCompids = getUsedBlockComputerids($start, 
$end);
$computerids = array_diff($computerids, 
$usedBlockCompids);
$currentids = array_diff($currentids, 
$usedBlockCompids);
@@ -3812,6 +3820,46 @@ function checkOverlap($start, $end, $max
 
 

 ///
+/// \fn editRequestBlockCheck($compid, $imageid, $start, $end)
+///
+/// \param $compid - id of computer to check
+/// \param $imageid - id of image being checked
+/// \param $start - start of time period in unix timestamp format
+/// \param $end - end of time period in unix timestamp format
+///
+/// \return 1 if time period overlaps with a block allocation unavailable to 
the
+/// logged in user; 0 if not
+///
+/// \brief checks to see if $compid is part of a block allocation that the
+/// current user is not part of or is set for a different image than what the
+/// user is currently using on the computer
+///
+
+function editRequestBlockCheck($compid, $imageid, $start, $end) {
+   global $user;
+   $groupids = implode(',', array_keys($user['groups']));
+   if(! count($user['groups']))
+   $groupids = '';
+   $startdt = unixToDatetime($start);
+   $enddt = unixToDatetime($end);
+   $query = SELECT bc.computerid 
+  . FROM blockComputers bc, 
+  .  blockTimes bt, 
+  .  blockRequest r 
+  . WHERE bc.blockTimeid = bt.id AND 
+  .   bt.blockRequestid = r.id AND 
+  .   bc.computerid = $compid AND 
+  .   (bt.start - INTERVAL 15 MINUTE)  '$enddt' AND 
+  .   bt.end  '$startdt' AND 
+  .   (r.groupid NOT IN ($groupids) OR 
+  .   r.imageid != $imageid) AND 
+