Author: arkurth Date: Thu Feb 26 14:18:04 2009 New Revision: 748160 URL: http://svn.apache.org/viewvc?rev=748160&view=rev Log: VCL-94 Added set_provisioner() and provisioner() subroutines to OS.pm, allowing OS modules to access the provisioning module object.
Added set_os() and os() subroutines to Provisioning.pm, allowing provisioning modules to access the OS module object. Added code to State.pm::initialize() calling the above-mentioned subroutines. This allows provisioning and OS module objects to access each other via $self->os and $self->provisioner. Added a block to the beginning of image.pm::process() to call the provisioning module's capture() subroutine if it has been implemented. If it hasn't, the block is ignored and process() behaves exactly as it did before. Made 2 minor changes in utils.pm. Added run_command to the EXPORT list. Added a check in run_scp_command() for the existence of 'no such file' in the output. This wasn't being caught. Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning.pm incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm incubator/vcl/trunk/managementnode/lib/VCL/image.pm incubator/vcl/trunk/managementnode/lib/VCL/utils.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=748160&r1=748159&r2=748160&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS.pm Thu Feb 26 14:18:04 2009 @@ -63,6 +63,45 @@ #///////////////////////////////////////////////////////////////////////////// +=head2 set_provisioner + + Parameters : None + Returns : Process's provisioner object + Description : Sets the provisioner object for the OS module to access. + +=cut + +sub set_provisioner { + my $self = shift; + my $provisioner = shift; + $self->{provisioner} = $provisioner; +} + +#///////////////////////////////////////////////////////////////////////////// + +=head2 provisioner + + Parameters : None + Returns : Process's provisioner object + Description : Allows OS modules to access the reservation's provisioner + object. + +=cut + +sub provisioner { + my $self = shift; + + if (!$self->{provisioner}) { + notify($ERRORS{'WARNING'}, 0, "unable to return provisioner object, \$self->{provisioner} is not set"); + return; + } + else { + return $self->{provisioner}; + } +} + +#///////////////////////////////////////////////////////////////////////////// + 1; __END__ Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning.pm?rev=748160&r1=748159&r2=748160&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning.pm Thu Feb 26 14:18:04 2009 @@ -63,6 +63,45 @@ #///////////////////////////////////////////////////////////////////////////// +=head2 set_os + + Parameters : None + Returns : Process's OS object + Description : Sets the OS object for the provisioner module to access. + +=cut + +sub set_os { + my $self = shift; + my $os = shift; + $self->{os} = $os; +} + +#///////////////////////////////////////////////////////////////////////////// + +=head2 os + + Parameters : None + Returns : Process's OS object + Description : Allows provisioning modules to access the reservation's OS + object. + +=cut + +sub os { + my $self = shift; + + if (!$self->{os}) { + notify($ERRORS{'WARNING'}, 0, "unable to return OS object, \$self->{os} is not set"); + return; + } + else { + return $self->{os}; + } +} + +#///////////////////////////////////////////////////////////////////////////// + 1; __END__ Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm?rev=748160&r1=748159&r2=748160&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/Module/State.pm Thu Feb 26 14:18:04 2009 @@ -163,28 +163,9 @@ else { notify($ERRORS{'OK'}, 0, "OS module not loaded, Perl package is not defined"); } - - # Attempt to load the predictive loading module - #if ($predictive_perl_package) { - # notify($ERRORS{'OK'}, 0, "attempting to load predictive loading module: $predictive_perl_package"); - # eval "use $predictive_perl_package"; - # if ($EVAL_ERROR) { - # notify($ERRORS{'WARNING'}, 0, "$predictive_perl_package module could not be loaded"); - # notify($ERRORS{'OK'}, 0, "returning 0"); - # return 0; - # } - # if (my $predictor = ($predictive_perl_package)->new({data_structure => $self->data})) { - # notify($ERRORS{'OK'}, 0, ref($predictor) . " predictive loading object successfully created"); - # $self->{predictor} = $predictor; - # } - # else { - # notify($ERRORS{'WARNING'}, 0, "predictive loading object could not be created, returning 0"); - # return 0; - # } - #} ## end if ($predictive_perl_package) - #else { - # notify($ERRORS{'OK'}, 0, "predictive loading module not loaded, Perl package is not defined"); - #} + + $self->{provisioner}->set_os($self->{os}); + $self->{os}->set_provisioner($self->{provisioner}); notify($ERRORS{'OK'}, 0, "returning 1"); return 1; Modified: incubator/vcl/trunk/managementnode/lib/VCL/image.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/image.pm?rev=748160&r1=748159&r2=748160&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/image.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/image.pm Thu Feb 26 14:18:04 2009 @@ -151,10 +151,26 @@ my $timestamp = makedatestring(); $self->data->set_image_lastupdate($timestamp); $self->data->set_imagerevision_date_created($timestamp); - - # Call the create image subroutine in utils.pm + my $create_image_result; - if ($computer_type eq "blade" && $self->os) { + + # --- BEGIN NEW MODULARIZED METHOD --- + # Check if capture() subroutine has been implemented by the provisioning module + if ($self->provisioner->can("capture")) { + # Call the provisioning modules's capture() subroutine + # The provisioning module should do everything necessary to capture the image + notify($ERRORS{'OK'}, 0, "calling provisioning module's capture() subroutine"); + if ($create_image_result = $self->provisioner->capture()) { + notify($ERRORS{'OK'}, 0, "$image_name image was successfully captured by the provisioning module"); + } + else { + notify($ERRORS{'WARNING'}, 0, "$image_name image failed to be captured by provisioning module"); + $self->image_creation_failed(); + } + } + # --- END NEW MODULARIZED METHOD --- + + elsif ($computer_type eq "blade" && $self->os) { $create_image_result = 1; notify($ERRORS{'OK'}, 0, "OS modularization supported, beginning OS module capture prepare"); Modified: incubator/vcl/trunk/managementnode/lib/VCL/utils.pm URL: http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=748160&r1=748159&r2=748160&view=diff ============================================================================== --- incubator/vcl/trunk/managementnode/lib/VCL/utils.pm (original) +++ incubator/vcl/trunk/managementnode/lib/VCL/utils.pm Thu Feb 26 14:18:04 2009 @@ -161,6 +161,7 @@ reservations_ready restoresshkeys round + run_command run_scp_command run_ssh_command set_hash_process_id @@ -6982,7 +6983,7 @@ # Check the output for known error messages # Check the exit status # scp exits with 0 on success or >0 if an error occurred - if ($scp_exit_status > 0 || $scp_output =~ /lost connection|failed|reset by peer|no route to host/i) { + if ($scp_exit_status > 0 || $scp_output =~ /lost connection|failed|reset by peer|no route to host|no such file/i) { notify($ERRORS{'WARNING'}, 0, "scp error occurred: attempt $attempts/$max_attempts, command: $scp_command, exit status: $scp_exit_status, output: $scp_output"); # Temporary fix for problem of nodes using different ports