Author: arkurth
Date: Thu Jul 31 20:17:42 2014
New Revision: 1614995

URL: http://svn.apache.org/r1614995
Log:
VCL-770
Updated code so that Windows 8/2012 Sysprep works. Modified 8.pm to add a 
scheduled task to configure Sysprep after boot. Copied sysprep_cmdlines.cmd to 
tools/Windows_8/Scripts/sysprep_cmdlines.cmd and updated it.

Added:
    vcl/trunk/managementnode/tools/Windows_8/Scripts/sysprep_cmdlines.cmd
Modified:
    vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6/8.pm

Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6/8.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6/8.pm?rev=1614995&r1=1614994&r2=1614995&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6/8.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6/8.pm Thu Jul 
31 20:17:42 2014
@@ -84,8 +84,6 @@ our $SOURCE_CONFIGURATION_DIRECTORY = "$
  Description : Performs the steps necessary before a Windows 8.x image is
                captured.
 
-=over 3
-
 =cut
 
 sub pre_capture {
@@ -95,14 +93,11 @@ sub pre_capture {
                notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a 
function, it must be called as a class method");
                return;
        }
-
-=item 1
-
-Call parent class's pre_capture subroutine
-
-=cut
-
-       # Call parent class's pre_capture() subroutine
+       
+       my $computer_node_name   = $self->data->get_computer_node_name();
+       my $end_state = $self->{end_state} || 'off';
+       
+       # Call parent class's pre_capture subroutine
        notify($ERRORS{'OK'}, 0, "calling parent class pre_capture() 
subroutine");
        if (!$self->SUPER::pre_capture($args)) {
                notify($ERRORS{'WARNING'}, 0, "failed to execute parent class 
pre_capture() subroutine");
@@ -110,63 +105,6 @@ Call parent class's pre_capture subrouti
        }
        
        notify($ERRORS{'OK'}, 0, "beginning Windows 8 image capture preparation 
tasks");
-
-=item *
-
-Prepare the computer for Sysprep or prepare the non-Sysprep post_load steps
-
-=cut
-
-       if ($self->data->get_imagemeta_sysprep()) {
-               if (!$self->run_sysprep()) {
-                       notify($ERRORS{'WARNING'}, 0, "capture preparation 
failed, failed to run Sysprep");
-                       return;
-               }
-       }
-       else {
-               if (!$self->prepare_post_load()) {
-                       notify($ERRORS{'WARNING'}, 0, "capture preparation 
failed, failed to run prepare post_load");
-                       return;
-               }
-       }
-       
-=back
-
-=cut
-
-       notify($ERRORS{'OK'}, 0, "returning 1");
-       return 1;
-} ## end sub pre_capture
-
-#/////////////////////////////////////////////////////////////////////////////
-
-=head2 prepare_post_load
-
- Parameters  : none
- Returns     : boolean
- Description : This subroutine should be called as the last step before an 
image
-               is captured if Sysprep is not is used. It prepares the computer
-               to perform the necessary tasks after the image is loaded and the
-               computer boots.
-
-=cut
-
-sub prepare_post_load {
-       my $self = shift;
-       if (ref($self) !~ /windows/i) {
-               notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a 
function, it must be called as a class method");
-               return;
-       }
-
-       my $computer_node_name   = $self->data->get_computer_node_name();
-       my $end_state = $self->{end_state} || 'off';
-       
-       # Set the DevicePath registry key
-       # This is used to locate device drivers
-       if (!$self->set_device_path_key()) {
-               notify($ERRORS{'WARNING'}, 0, "failed to set the DevicePath 
registry key");
-               return;
-       }
        
        # Get the node configuration directory
        my $node_configuration_directory = 
$self->get_node_configuration_directory();
@@ -175,15 +113,13 @@ sub prepare_post_load {
                return;
        }
        
-       # Set the sshd service startup mode to disabled so that it does not 
start up until properly configured
-       if (!$self->set_service_startup_mode('sshd', 'disabled')) {
-               notify($ERRORS{'WARNING'}, 0, "sshd service could not be 
disabled before shutting down computer");
+       # Set the DevicePath registry key
+       # This is used to locate device drivers
+       if (!$self->set_device_path_key()) {
+               notify($ERRORS{'WARNING'}, 0, "failed to set the DevicePath 
registry key");
                return;
        }
        
-       # Make sure any old log files are deleted
-       $self->delete_file("$node_configuration_directory/Logs/*");
-       
        # Create a scheduled task to run post_load.cmd when the image boots
        my $task_name     = 'VCL Post Load';
        my $task_command  = 
"$node_configuration_directory/Scripts/post_load.cmd > 
$node_configuration_directory/Logs/post_load.log";
@@ -193,17 +129,32 @@ sub prepare_post_load {
                notify($ERRORS{'WARNING'}, 0, "failed to create '$task_name' 
scheduled task");
                return;
        }
-
-       # Shut down computer unless end_state argument was passed with a value 
other than 'off'
-       if ($end_state eq 'off') {
-               if (!$self->shutdown(1)) {
-                       notify($ERRORS{'WARNING'}, 0, "failed to shut down 
computer");
+       
+       # Set the sshd service startup mode to disabled so that it does not 
start up until properly configured
+       if (!$self->set_service_startup_mode('sshd', 'disabled')) {
+               notify($ERRORS{'WARNING'}, 0, "sshd service could not be 
disabled before shutting down computer");
+               return;
+       }
+       
+       # Prepare the computer for Sysprep or prepare the non-Sysprep post_load 
steps
+       if ($self->data->get_imagemeta_sysprep()) {
+               if (!$self->run_sysprep()) {
+                       notify($ERRORS{'WARNING'}, 0, "capture preparation 
failed, failed to run Sysprep");
                        return;
                }
        }
-       
+       else {
+               if ($end_state eq 'off') {
+                       if (!$self->shutdown(1)) {
+                               notify($ERRORS{'WARNING'}, 0, "failed to shut 
down computer");
+                               return;
+                       }
+               }
+       }
+
+       notify($ERRORS{'OK'}, 0, "completed Windows 8 image capture preparation 
tasks");
        return 1;
-}
+} ## end sub pre_capture
 
 #/////////////////////////////////////////////////////////////////////////////
 

Added: vcl/trunk/managementnode/tools/Windows_8/Scripts/sysprep_cmdlines.cmd
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/tools/Windows_8/Scripts/sysprep_cmdlines.cmd?rev=1614995&view=auto
==============================================================================
--- vcl/trunk/managementnode/tools/Windows_8/Scripts/sysprep_cmdlines.cmd 
(added)
+++ vcl/trunk/managementnode/tools/Windows_8/Scripts/sysprep_cmdlines.cmd Thu 
Jul 31 20:17:42 2014
@@ -0,0 +1,70 @@
+@echo off
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+rem DESCRIPTION:
+rem This script runs automatically during Sysprep's minisetup stage. It gets
+rem called by the Sysprep process because this script has been specified in
+rem the Sysprep\i386\$oem$\cmdlines.txt file.
+rem It performs steps that cannot be done prior to running Sysprep but before
+rem loading Windows for the first time. The steps include setting the computer
+rem name and enabling AutoAdminLogon.
+
+set /A STATUS=0
+
+rem Get the name of this batch file and the directory it is running from
+set SCRIPT_NAME=%~n0
+set SCRIPT_FILENAME=%~nx0
+set SCRIPT_DIR=%~dp0
+rem Remove trailing slash from SCRIPT_DIR
+set SCRIPT_DIR=%SCRIPT_DIR:~0,-1%
+
+set LOGS_DIR=%SCRIPT_DIR%\..\Logs\%SCRIPT_NAME%
+if not exist %LOGS_DIR% mkdir %LOGS_DIR%
+
+echo ======================================================================
+echo %SCRIPT_FILENAME% beginning to run at: %DATE% %TIME%
+echo Directory %SCRIPT_FILENAME% is running from: %SCRIPT_DIR%
+echo.
+
+echo ----------------------------------------------------------------------
+
+echo %TIME%: Calling %SCRIPT_DIR%\debug_info.cmd...
+echo *** %SCRIPT_FILENAME% start: *** >> %LOGS_DIR%\debug_info.log
+start "debug_info.cmd" /WAIT cmd.exe /c "%SCRIPT_DIR%\debug_info.cmd >> 
%LOGS_DIR%\debug_info.log 2>&1"
+echo.
+
+echo ----------------------------------------------------------------------
+
+echo %TIME%: Executing %SCRIPT_DIR%\set_computer_name.vbs...
+start "set_computer_name.vbs" /WAIT cmd.exe /c 
"C:\Windows\system32\cscript.exe //NoLogo %SCRIPT_DIR%\set_computer_name.vbs >> 
%LOGS_DIR%\set_computer_name.log 2>&1"
+echo ERRORLEVEL: %ERRORLEVEL%
+set /A STATUS+=%ERRORLEVEL%
+echo.
+
+echo ----------------------------------------------------------------------
+
+echo %TIME%: Calling %SCRIPT_DIR%\debug_info.cmd...
+echo *** %SCRIPT_FILENAME% end: *** >> %LOGS_DIR%\debug_info.log
+start "debug_info.cmd" /WAIT cmd.exe /c "%SCRIPT_DIR%\debug_info.cmd >> 
%LOGS_DIR%\debug_info.log 2>&1"
+echo.
+
+echo ----------------------------------------------------------------------
+
+echo %SCRIPT_FILENAME% finished at: %DATE% %TIME%
+echo exiting with status: %STATUS%
+"%SystemRoot%\system32\eventcreate.exe" /T INFORMATION /L APPLICATION /SO 
%SCRIPT_FILENAME% /ID 555 /D "exit status: %STATUS%" 2>&1
+
+exit /B %STATUS%


Reply via email to