Author: arkurth
Date: Tue May 2 23:08:04 2017
New Revision: 1793593
URL: http://svn.apache.org/viewvc?rev=1793593&view=rev
Log:
VCL-866
Added State.pm::request_state_changed subroutine. It returns true if
request/lastrequest is different than that of the current process.
Replaced calls to is_request_deleted and check_imaging_request with a call to
request_state_changed in State.pm::user_connected and inuse.pm::process.
Removed State.pm::check_imaging_request since it's no longer called.
Other
Added optional $provisioning_perl_package argument to
Module.pm::create_provisioning_object. This is only used for
testing/development.
Modified:
vcl/trunk/managementnode/lib/VCL/Module.pm
vcl/trunk/managementnode/lib/VCL/Module/State.pm
vcl/trunk/managementnode/lib/VCL/inuse.pm
Modified: vcl/trunk/managementnode/lib/VCL/Module.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module.pm?rev=1793593&r1=1793592&r2=1793593&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module.pm Tue May 2 23:08:04 2017
@@ -775,7 +775,7 @@ my $self = shift;
=head2 create_provisioning_object
- Parameters : none
+ Parameters : $provisioning_perl_package (optional)
Returns : VCL::Module::Provisioning object reference
Description : Creates an provisioning module object if one has not already
been
created for the calling object.
@@ -804,7 +804,7 @@ sub create_provisioning_object {
}
# Get the Perl package for the provisioning module
- my $provisioning_perl_package =
$self->data->get_computer_provisioning_module_perl_package();
+ my $provisioning_perl_package = shift ||
$self->data->get_computer_provisioning_module_perl_package();
if (!$provisioning_perl_package) {
notify($ERRORS{'WARNING'}, 0, "provisioning object could not be
created, provisioning module Perl package could not be retrieved");
return;
Modified: vcl/trunk/managementnode/lib/VCL/Module/State.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/State.pm?rev=1793593&r1=1793592&r2=1793593&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/State.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/State.pm Tue May 2 23:08:04 2017
@@ -269,11 +269,11 @@ sub user_connected {
my $ignore_connections_gte_min =
$self->os->get_timings('ignore_connections_gte');
my $ignore_connections_gte = floor($ignore_connections_gte_min /
60);
- # Check if user deleted the request
- $self->state_exit() if is_request_deleted($request_id);
-
- # Check if this is an imaging request, causes process to exit if state
or laststate = image
- $self->check_imaging_request();
+ # Check if the request state changed for any reason
+ # This will occur if the user deletes the request, makeproduction is
initiated, reboot is initiated, image capture is started
+ if ($self->request_state_changed()) {
+ $self->state_exit();
+ }
# Check if this is a server request, causes process to exit if server
request
if ($server_request_id) {
@@ -317,23 +317,43 @@ sub user_connected {
#/////////////////////////////////////////////////////////////////////////////
-=head2 check_imaging_request
+=head2 request_state_changed
Parameters : none
Returns : boolean
- Description : The inuse process exits if the request state or laststate are
set
- to image, or if the forimaging flag has been set.
+ Description : Returns true if the neither current request state changed after
+ the process began, including:
+ * Request deleted
+ * Request deleted and makeproduction initiated
+ * Image capture initiated
+ * Checkpoint capture initiated
+ * Reboot initiated
=cut
-sub check_imaging_request {
+sub request_state_changed {
my $self = shift;
+ if (ref($self) !~ /VCL::/) {
+ notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a
function, it must be called as a class method, reservation failure tasks not
attempted, process exiting");
+ exit 1;
+ }
+
my $request_id = $self->data->get_request_id();
+ my $processing_request_state_name =
$self->data->get_request_state_name();
- my $imaging_result = is_request_imaging($request_id);
- if ($imaging_result eq 'image') {
- notify($ERRORS{'OK'}, 0, "image creation process has begun,
exiting");
- $self->state_exit();
+ my ($current_state_name, $current_laststate_name) =
get_request_current_state_name($request_id);
+ if (!$current_state_name || !$current_laststate_name) {
+ notify($ERRORS{'WARNING'}, 0, "request $request_id state data
could not be retrieved, assuming request is deleted and was removed from the
database, returning true");
+ return 1;
+ }
+ elsif (($current_state_name ne 'pending' and $current_state_name ne
$processing_request_state_name) ||
+ ($current_state_name eq 'pending' and $current_laststate_name
ne $processing_request_state_name)) {
+ notify($ERRORS{'OK'}, 0, "request state changed after this
process begain: $processing_request_state_name -->
$current_state_name/$current_laststate_name, returning true");
+ return 1;
+ }
+ else {
+ notify($ERRORS{'OK'}, 0, "request state has NOT changed after
this process begain: $processing_request_state_name -->
$current_state_name/$current_laststate_name, returning false");
+ return 0;
}
}
Modified: vcl/trunk/managementnode/lib/VCL/inuse.pm
URL:
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/inuse.pm?rev=1793593&r1=1793592&r2=1793593&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/inuse.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/inuse.pm Tue May 2 23:08:04 2017
@@ -207,11 +207,11 @@ sub process {
$request_remaining_minutes = ($end_time_notify_minutes
- $iteration);
notify($ERRORS{'OK'}, 0, "minutes until end of end of
request: $request_remaining_minutes");
- # Check if user deleted the request
- $self->state_exit() if is_request_deleted($request_id);
-
- # Check if this is an imaging request, causes process
to exit if state or laststate = image
- $self->check_imaging_request();
+ # Check if the request state changed for any reason
+ # This will occur if the user deletes the request,
makeproduction is initiated, reboot is initiated, image capture is started
+ if ($self->request_state_changed()) {
+ $self->state_exit();
+ }
# Get the current request end time from the database
my $current_request_end = get_request_end($request_id);
@@ -436,7 +436,7 @@ sub notify_user_endtime_imminent {
my $user_imtype_name = $self->data->get_user_imtype_name();
my $user_im_id = $self->data->get_user_im_id();
my $is_parent_reservation = $self->data->is_parent_reservation();
- my $request_forimaging = $self->check_imaging_request();
+ my $request_forimaging =
$self->data->get_request_forimaging();
my $user_message_key;
if ($request_forimaging) {