You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by ar...@apache.org on 2012/01/20 20:08:20 UTC
svn commit: r1234080 - in
/incubator/vcl/trunk/managementnode/lib/VCL/Module: OS.pm OS/Linux.pm
OS/Windows.pm
Author: arkurth
Date: Fri Jan 20 19:08:19 2012
New Revision: 1234080
URL: http://svn.apache.org/viewvc?rev=1234080&view=rev
Log:
VCL-554
Added pre_capture subroutine to OS.pm. This is called as the first step from the Windows.pm and Linux.pm pre_capture subroutines. It checks to make sure the computer is responding. If not responding, it checks if the computer is powered off and attempts to power it on. OS::pre_capture also creates the currentimage.txt file so this step no longer needs to be done in every provisioning module's capture subroutine.
Also changed the timing of the wait_for_response call in Linux::post_load. It had been waiting 60 seconds for the computer to boot. Some computers take less time. Changed to 30 seconds.
Modified:
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm?rev=1234080&r1=1234079&r2=1234080&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm Fri Jan 20 19:08:19 2012
@@ -64,6 +64,70 @@ use VCL::utils;
#/////////////////////////////////////////////////////////////////////////////
+=head2 pre_capture
+
+ Parameters : $arguments->{end_state}
+ Returns : boolean
+ Description : Performs the tasks common to all OS's that must be done to the
+ computer prior to capturing an image:
+ -Check if the computer is responding to SSH
+ -If not responding, check if computer is powered on
+ -Power on computer if powered off and wait for SSH to respond
+ -Create currentimage.txt file
+
+=cut
+
+sub pre_capture {
+ my $self = shift;
+ my $args = shift;
+ if (ref($self) !~ /VCL::Module/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();
+ notify($ERRORS{'OK'}, 0, "beginning common image capture preparation tasks");
+
+ # Make sure the computer is responding to SSH
+ # If it is not, check if it is powered on
+ if (!$self->is_ssh_responding()) {
+ notify($ERRORS{'OK'}, 0, "$computer_node_name is not responding to SSH, checking if it is powered on");
+ my $power_status = $self->provisioner->power_status();
+ if (!$power_status) {
+ notify($ERRORS{'WARNING'}, 0, "unable to complete capture preparation tasks, $computer_node_name is not responding to SSH and the power status could not be determined");
+ return;
+ }
+ elsif ($power_status =~ /on/i) {
+ notify($ERRORS{'WARNING'}, 0, "unable to complete capture preparation tasks, $computer_node_name is powered on but not responding to SSH");
+ return;
+ }
+ else {
+ notify($ERRORS{'DEBUG'}, 0, "$computer_node_name is powered off, attempting to power it on");
+ if (!$self->provisioner->power_on()) {
+ notify($ERRORS{'WARNING'}, 0, "unable to complete capture preparation tasks, $computer_node_name could not be powered on");
+ return;
+ }
+
+ # Wait for computer to respond to SSH
+ if (!$self->wait_for_response(30, 300, 10)) {
+ notify($ERRORS{'WARNING'}, 0, "unable to complete capture preparation tasks, $computer_node_name never responded to SSH after it was powered on");
+ return;
+ }
+ }
+ }
+
+ # 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;
+ }
+
+ notify($ERRORS{'OK'}, 0, "completed common image capture preparation tasks");
+ return 1;
+}
+
+#/////////////////////////////////////////////////////////////////////////////
+
=head2 get_source_configuration_directories
Parameters : None
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm?rev=1234080&r1=1234079&r2=1234080&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Linux.pm Fri Jan 20 19:08:19 2012
@@ -133,8 +133,15 @@ sub pre_capture {
}
my $computer_node_name = $self->data->get_computer_node_name();
+
+ # Call OS::pre_capture to perform the pre-capture tasks common to all OS's
+ if (!$self->SUPER::pre_capture($args)) {
+ notify($ERRORS{'WARNING'}, 0, "failed to execute parent class pre_capture() subroutine");
+ return 0;
+ }
+
notify($ERRORS{'OK'}, 0, "beginning Linux-specific image capture preparation tasks");
-
+
if (!$self->file_exists("/root/.vclcontrol/vcl_exclude_list.sample")) {
notify($ERRORS{'DEBUG'}, 0, "/root/.vclcontrol/vcl_exclude_list.sample does not exists");
if(!$self->generate_vclcontrol_sample_files() ){
@@ -270,7 +277,7 @@ sub post_load {
notify($ERRORS{'OK'}, 0, "initiating Linux post_load: $image_name on $computer_short_name");
# Wait for computer to respond to SSH
- if (!$self->wait_for_response(60, 600)) {
+ if (!$self->wait_for_response(30, 600, 10)) {
notify($ERRORS{'WARNING'}, 0, "$computer_node_name never responded to SSH");
return 0;
}
Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm?rev=1234080&r1=1234079&r2=1234080&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm Fri Jan 20 19:08:19 2012
@@ -228,6 +228,12 @@ sub pre_capture {
my $computer_node_name = $self->data->get_computer_node_name();
my $image_os_install_type = $self->data->get_image_os_install_type();
+
+ # Call OS::pre_capture to perform the pre-capture tasks common to all OS's
+ if (!$self->SUPER::pre_capture($args)) {
+ notify($ERRORS{'WARNING'}, 0, "failed to execute parent class pre_capture() subroutine");
+ return 0;
+ }
notify($ERRORS{'OK'}, 0, "beginning Windows image capture preparation tasks on $computer_node_name");