Author: arkurth
Date: Thu Jan 29 20:03:28 2015
New Revision: 1655840
URL: http://svn.apache.org/r1655840
Log:
VCL-564
Renamed OS.pm::run_scripts to run_management_node_tools_scripts to make it
clear what it does. Made a few minor changes to this subroutine.
Added call to run_management_node_tools_scripts('post_load') in:
Linux.pm::post_load
Version_5.pm::post_load
Version_6.pm::post_load
Added call to run_management_node_tools_scripts('post_reserve') in:
Linux.pm::post_reserve
Windows.pm::post_reserve
Updated OS.pm::pre_capture to delete the node configuration directory so that
old scripts and log files are removed. Added call to
run_management_node_tools_scripts('pre_capture').
Other
Added timeout values to Windows activation commands in Version_6.pm.
Modified:
vcl/trunk/managementnode/lib/VCL/Module/OS.pm
vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm
vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm
vcl/trunk/managementnode/lib/VCL/reserved.pm
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS.pm?rev=1655840&r1=1655839&r2=1655840&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS.pm Thu Jan 29 20:03:28 2015
@@ -117,12 +117,21 @@ sub pre_capture {
}
}
+ # Delete an existing node configuration directory to clear out any
scripts and log files from a previous image revision
+ my $node_configuration_directory =
$self->get_node_configuration_directory();
+ if ($node_configuration_directory) {
+ $self->delete_file($node_configuration_directory);
+ }
+
# Create the currentimage.txt file
if (!$self->create_currentimage_txt()) {
notify($ERRORS{'WARNING'}, 0, "failed to create
currentimage.txt on $computer_node_name");
return 0;
}
+ # Run custom pre_capture scripts residing on the management node
+ $self->run_management_node_tools_scripts('pre_capture');
+
notify($ERRORS{'OK'}, 0, "completed common image capture preparation
tasks");
return 1;
}
@@ -2610,7 +2619,6 @@ sub execute_new {
);
if ($ssh) {
-
notify($ERRORS{'DEBUG'}, 0, "created "
. ref($ssh) . " object to control $computer_string, SSH options: $ssh_options");
}
else {
@@ -3570,7 +3578,7 @@ sub get_timings {
#/////////////////////////////////////////////////////////////////////////////
-=head2 run_scripts
+=head2 run_management_node_tools_scripts
Parameters : $stage
Returns : boolean
@@ -3612,7 +3620,7 @@ sub get_timings {
=cut
-sub run_scripts {
+sub run_management_node_tools_scripts {
my $self = shift;
if (ref($self) !~ /VCL::Module/) {
notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method");
@@ -3622,7 +3630,7 @@ sub run_scripts {
# Get the stage argument
my $stage = shift;
if (!$stage) {
- notify($ERRORS{'WARNING'}, 0, "unable to run scripts, stage
argument was not supplied");
+ notify($ERRORS{'WARNING'}, 0, "stage argument was not
supplied");
return;
}
elsif ($stage !~ /(pre_capture|post_load|post_reserve)/) {
@@ -3631,12 +3639,22 @@ sub run_scripts {
}
my $computer_node_name = $self->data->get_computer_node_name();
+ my $image_name = $self->data->get_image_name();
- my @computer_tools_files =
$self->get_tools_file_paths("/Scripts/$stage/");
+ if (!$self->can('run_script')) {
+ notify($ERRORS{'DEBUG'}, 0, "custom $stage scripts not executed
on $computer_node_name, " . ref($self) . " module does not implement a
'run_script' subroutine");
+ return 1;
+ }
+ # Loop through all tools files on the computer
my @failed_file_paths;
+ my @computer_tools_files =
$self->get_tools_file_paths("/Scripts/$stage/");
+ if (!@computer_tools_files) {
+ notify($ERRORS{'DEBUG'}, 0, "no custom scripts reside on this
management node for $image_name");
+ return 1;
+ }
- # Loop through all tools files on the computer
+ notify($ERRORS{'DEBUG'}, 0, "attempting to execute custom scripts
residing on the management node for $image_name on $computer_node_name:\n" .
join("\n", @computer_tools_files));
for my $computer_tools_file_path (@computer_tools_files) {
notify($ERRORS{'DEBUG'}, 0, "executing script on
$computer_node_name: $computer_tools_file_path");
if (!$self->run_script($computer_tools_file_path)) {
@@ -3646,7 +3664,7 @@ sub run_scripts {
# Check if any scripts failed
if (@failed_file_paths) {
- notify($ERRORS{'CRITICAL'}, 0, "failed to run the following
scripts on $computer_node_name, stage: $stage\n" . join("\n",
@failed_file_paths));
+ notify($ERRORS{'WARNING'}, 0, "failed to run the following
scripts on $computer_node_name, stage: $stage\n" . join("\n",
@failed_file_paths));
return;
}
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm?rev=1655840&r1=1655839&r2=1655840&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm Thu Jan 29 20:03:28 2015
@@ -482,6 +482,9 @@ sub post_load {
# Update Hostname to match Public assigned name
$self->update_public_hostname();
+ # Run custom post_load scripts residing on the management node
+ $self->run_management_node_tools_scripts('post_load');
+
# Run the vcl_post_load script if it exists in the image
my @post_load_script_paths = ('/usr/local/vcl/vcl_post_load',
'/etc/init.d/vcl_post_load');
@@ -529,7 +532,9 @@ sub post_reserve {
my @post_reserve_script_paths = ('/usr/local/vcl/vcl_post_reserve',
'/etc/init.d/vcl_post_reserve');
notify($ERRORS{'OK'}, 0, "initiating Linux post_reserve: $image_name on
$computer_short_name");
-
+
+ # Run custom post_reserve scripts residing on the management node
+ $self->run_management_node_tools_scripts('post_reserve');
# User supplied data
#check if variable is set
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm?rev=1655840&r1=1655839&r2=1655840&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm Thu Jan 29 20:03:28
2015
@@ -970,9 +970,12 @@ sub post_reserve {
my $image_name = $self->data->get_image_name();
my $computer_short_name = $self->data->get_computer_short_name();
- my $script_path = '$SYSTEMROOT/vcl_post_reserve.cmd';
- # Check if script exists
+ # Run custom post_reserve scripts residing on the management node
+ $self->run_management_node_tools_scripts('post_reserve');
+
+ # Check if script exists in the image
+ my $script_path = '$SYSTEMROOT/vcl_post_reserve.cmd';
if (!$self->file_exists($script_path)) {
notify($ERRORS{'DEBUG'}, 0, "post_reserve script does NOT
exist: $script_path");
return 1;
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm?rev=1655840&r1=1655839&r2=1655840&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_5.pm Thu Jan 29
20:03:28 2015
@@ -130,6 +130,61 @@ sub pre_capture {
return 1;
} ## end sub pre_capture
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 post_load
+
+ Parameters : none
+ Returns : boolean
+ Description : Performs steps after an image is loaded which are specific to
+ Windows version 5.x.
+
+=over 3
+
+=cut
+
+sub post_load {
+ my $self = shift;
+
+ # Check if subroutine was called as an object method
+ unless (ref($self) && $self->isa('VCL::Module')) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine can only be called
as a VCL::Module object method");
+ return;
+ }
+
+ notify($ERRORS{'DEBUG'}, 0, "beginning Windows version 5.x post-load
tasks");
+
+=item 1
+
+Call parent class's post_load() subroutine
+
+=cut
+
+ notify($ERRORS{'DEBUG'}, 0, "calling parent class post_load()
subroutine");
+ if ($self->SUPER::post_load()) {
+ notify($ERRORS{'OK'}, 0, "successfully executed parent class
post_load() subroutine");
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "failed to execute parent class
post_load() subroutine");
+ return;
+ }
+
+=item *
+
+Run custom post_load scripts residing on the management node
+
+=cut
+
+ $self->run_management_node_tools_scripts('post_load');
+
+=back
+
+=cut
+
+ notify($ERRORS{'DEBUG'}, 0, "Windows version 5.x post-load tasks
complete");
+ return 1;
+}
+
##############################################################################
=head1 AUXILIARY OBJECT METHODS
Modified: vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm?rev=1655840&r1=1655839&r2=1655840&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS/Windows/Version_6.pm Thu Jan 29
20:03:28 2015
@@ -272,6 +272,14 @@ Activate Windows license
$self->activate();
+=item *
+
+Run custom post_load scripts residing on the management node
+
+=cut
+
+ $self->run_management_node_tools_scripts('post_load');
+
=back
=cut
@@ -523,7 +531,11 @@ sub run_slmgr_ipk {
# Run cscript.exe slmgr.vbs -ipk to install the product key
my $ipk_command = "$system32_path/cscript.exe //NoLogo
\$SYSTEMROOT/System32/slmgr.vbs -ipk $product_key";
- my ($ipk_exit_status, $ipk_output) = $self->execute($ipk_command);
+ my ($ipk_exit_status, $ipk_output) = $self->execute({
+ command => $ipk_command,
+ timeout_seconds => 240,
+ display_output => 1
+ });
if (defined($ipk_exit_status) && $ipk_exit_status == 0 &&
grep(/successfully/i, @$ipk_output)) {
notify($ERRORS{'OK'}, 0, "installed product key: $product_key");
}
@@ -562,7 +574,11 @@ sub run_slmgr_ckms {
# Run slmgr.vbs -ckms to clear an existing KMS server from a computer
# slmgr.vbs must be run in a command shell using the correct System32
path or the task it's supposed to do won't really take effect
my $skms_command = "$system32_path/cscript.exe //NoLogo
\$SYSTEMROOT/System32/slmgr.vbs -ckms";
- my ($skms_exit_status, $skms_output) = $self->execute($skms_command);
+ my ($skms_exit_status, $skms_output) = $self->execute({
+ command => $skms_command,
+ timeout_seconds => 240,
+ display_output => 1
+ });
if (defined($skms_exit_status) && $skms_exit_status == 0 &&
grep(/successfully/i, @$skms_output)) {
notify($ERRORS{'OK'}, 0, "cleared kms server");
}
@@ -601,7 +617,11 @@ sub run_slmgr_cpky {
# Run slmgr.vbs -cpky to clear an existing product key from a computer
# slmgr.vbs must be run in a command shell using the correct System32
path or the task it's supposed to do won't really take effect
my $skms_command = "$system32_path/cscript.exe //NoLogo
\$SYSTEMROOT/System32/slmgr.vbs -cpky";
- my ($skms_exit_status, $skms_output) = $self->execute($skms_command);
+ my ($skms_exit_status, $skms_output) = $self->execute({
+ command => $skms_command,
+ timeout_seconds => 240,
+ display_output => 1
+ });
if (defined($skms_exit_status) && $skms_exit_status == 0 &&
grep(/successfully/i, @$skms_output)) {
notify($ERRORS{'OK'}, 0, "cleared product key");
}
@@ -650,8 +670,11 @@ sub run_slmgr_skms {
# Run slmgr.vbs -skms to configure the computer to use the KMS server
# slmgr.vbs must be run in a command shell using the correct System32
path or the task it's supposed to do won't really take effect
my $skms_command = "$system32_path/cscript.exe //NoLogo
\$SYSTEMROOT/System32/slmgr.vbs -skms $kms_address:$kms_port";
-
- my ($skms_exit_status, $skms_output) = $self->execute($skms_command);
+ my ($skms_exit_status, $skms_output) = $self->execute({
+ command => $skms_command,
+ timeout_seconds => 240,
+ display_output => 1
+ });
if (defined($skms_exit_status) && $skms_exit_status == 0 &&
grep(/successfully/i, @$skms_output)) {
notify($ERRORS{'OK'}, 0, "set kms server to
$kms_address:$kms_port");
}
@@ -689,7 +712,11 @@ sub run_slmgr_ato {
# Run cscript.exe slmgr.vbs -ato to install the product key
my $ato_command = "$system32_path/cscript.exe //NoLogo
\$SYSTEMROOT/System32/slmgr.vbs -ato";
- my ($ato_exit_status, $ato_output) = $self->execute($ato_command);
+ my ($ato_exit_status, $ato_output) = $self->execute({
+ command => $ato_command,
+ timeout_seconds => 240,
+ display_output => 1
+ });
if (defined($ato_exit_status) && $ato_exit_status == 0 &&
grep(/successfully/i, @$ato_output)) {
notify($ERRORS{'OK'}, 0, "activated license");
}
@@ -727,7 +754,11 @@ sub run_slmgr_dlv {
# Run cscript.exe slmgr.vbs -dlv to install the product key
my $dlv_command = "$system32_path/cscript.exe //NoLogo
\$SYSTEMROOT/System32/slmgr.vbs -dlv";
- my ($dlv_exit_status, $dlv_output) = $self->execute($dlv_command);
+ my ($dlv_exit_status, $dlv_output) = $self->execute({
+ command => $dlv_command,
+ timeout_seconds => 120,
+ display_output => 1
+ });
if (defined($dlv_exit_status) && $dlv_exit_status == 0) {
notify($ERRORS{'OK'}, 0, "licensing information:\n" .
join("\n", @$dlv_output));
}
Modified: vcl/trunk/managementnode/lib/VCL/reserved.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reserved.pm?rev=1655840&r1=1655839&r2=1655840&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reserved.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reserved.pm Thu Jan 29 20:03:28 2015
@@ -132,7 +132,7 @@ sub process {
insertloadlog($reservation_id, $computer_id, "noinitialconnection",
"user clicked Connect");
delete_computerloadlog_reservation($reservation_id,
'acknowledgetimeout');
- # The frontend should have inserted an '' computerloadlog entry,
retrieve its timestamp
+ # The frontend should have inserted an 'initialconnecttimeout'
computerloadlog entry, retrieve its timestamp
my $connection_check_start_epoch_seconds =
get_reservation_computerloadlog_time($reservation_id, 'initialconnecttimeout');
if ($connection_check_start_epoch_seconds) {
notify($ERRORS{'DEBUG'}, 0, "retrieved timestamp of
computerloadlog 'initialconnecttimeout' entry inserted by web frontend:
$connection_check_start_epoch_seconds");