Author: arkurth
Date: Thu May 25 18:56:46 2017
New Revision: 1796183

URL: http://svn.apache.org/viewvc?rev=1796183&view=rev
Log:
VCL-887
Removed utils.pm::switch_state. It's no longer called.

Modified:
    vcl/trunk/managementnode/lib/VCL/new.pm
    vcl/trunk/managementnode/lib/VCL/utils.pm

Modified: vcl/trunk/managementnode/lib/VCL/new.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/new.pm?rev=1796183&r1=1796182&r2=1796183&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/new.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/new.pm Thu May 25 18:56:46 2017
@@ -645,7 +645,7 @@ sub computer_not_being_used {
        my $image_reloadtime                = 
$self->data->get_image_reload_time();
        my $request_state_name              = 
$self->data->get_request_state_name();
        
-       my $attempt_limit = 10;
+       my $attempt_limit = 24;
        ATTEMPT: for (my $attempt = 1; $attempt <= $attempt_limit; $attempt++) {
                if ($attempt > 2) {
                        notify($ERRORS{'OK'}, 0, "attempt 
$attempt/$attempt_limit: sleeping 5 seconds before checking if 
$computer_short_name is not being used");

Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1796183&r1=1796182&r2=1796183&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Thu May 25 18:56:46 2017
@@ -264,7 +264,6 @@ our @EXPORT = qw(
        sort_by_file_name
        stopwatch
        string_to_ascii
-       switch_state
        switch_vmhost_id
        update_blockrequest_processing
        update_changelog_request_user_remote_ip
@@ -6109,166 +6108,6 @@ sub set_logfile_path {
 
 #//////////////////////////////////////////////////////////////////////////////
 
-=head2 switch_state
-
- Parameters  : $request_data, $request_state_name_new, 
$computer_state_name_new, $request_log_ending, $exit
- Returns     : 0 if something goes wrong, exits if successful
- Description : Changes the state of this request to the state specified
-               terminates. The vcld process will then pick up the switched
-               request. It is important that this process sets the request
-               laststate to the original state and that vcld does not alter it.
-
-=cut
-
-sub switch_state {
-       my ($request_data, $request_state_name_new, $computer_state_name_new, 
$request_log_ending, $exit) = @_;
-
-       my ($package,        $filename,        $line,        $sub)        = 
caller(0);
-       my ($caller_package, $caller_filename, $caller_line, $caller_sub) = 
caller(1);
-
-       my $caller_info = "$caller_sub($line)";
-
-       my $caller = scalar caller;
-       notify($ERRORS{'OK'}, 0, "called from $caller_info");
-
-       # Check the arguments
-       if (!defined($request_data)) {
-               notify($ERRORS{'CRITICAL'}, 0, "request data hash reference is 
undefined");
-               return 0;
-       }
-       elsif (!ref($request_data) eq "HASH") {
-               notify($ERRORS{'CRITICAL'}, 0, "1st argument is not a hash 
reference to the request data");
-               return 0;
-       }
-
-       # Set the default value for exit
-       $exit = 0 if (!defined($exit));
-
-       # Store some hash variables into local variables
-       my $request_id                 = $request_data->{id};
-       my $request_logid              = $request_data->{logid};
-       my $reservation_id             = $request_data->{RESERVATIONID};
-       my $request_state_name_old     = $request_data->{state}{name} || '';
-       my $request_laststate_name_old = $request_data->{laststate}{name} || '';
-       my $computer_id                = 
$request_data->{reservation}{$reservation_id}{computer}{id};
-       my $computer_type              = 
$request_data->{reservation}{$reservation_id}{computer}{type};
-       my $computer_state_name_old    = 
$request_data->{reservation}{$reservation_id}{computer}{state}{name};
-       my $computer_shortname         = 
$request_data->{reservation}{$reservation_id}{computer}{SHORTNAME};
-       
-       if ($request_state_name_old eq 'reload') {
-               $request_logid = 0;
-       }
-
-       # Figure out if this is the parent reservation
-       my @reservation_ids = sort keys %{$request_data->{reservation}};
-       # The parent reservation has the lowest ID
-       my $parent_reservation_id = min @reservation_ids;
-       my $is_parent_reservation;
-       if ($reservation_id == $parent_reservation_id) {
-               notify($ERRORS{'DEBUG'}, 0, "parent: parent reservation ID for 
this request: $parent_reservation_id");
-               $is_parent_reservation = 1;
-       }
-       else {
-               notify($ERRORS{'DEBUG'}, 0, "child: parent reservation ID for 
this request: $parent_reservation_id");
-               $is_parent_reservation = 0;
-       }
-       
-       # Don't set request state to failed if previous state is image or inuse
-       if ($request_state_name_new && $request_state_name_new eq 'failed') {
-               if ($request_state_name_old =~ /(image|checkpoint)/) {
-                       notify($ERRORS{'DEBUG'}, 0, "previous request state is 
$request_state_name_old, not setting request state to $request_state_name_new, 
setting request state to maintenance");
-                       $request_state_name_new = 'maintenance';
-                       $computer_state_name_new = 'maintenance';
-               }
-               elsif ($request_state_name_old =~ /(inuse|reboot|server)/) {
-                       notify($ERRORS{'DEBUG'}, 0, "previous request state is 
$request_state_name_old, not setting request state to $request_state_name_new, 
setting request state back to inuse");
-                       $request_state_name_new = 'inuse';
-                       $computer_state_name_new = 'inuse';
-               }
-       }
-       
-       # Don't set log.ending to failed for inuse - this throws off the counts 
on the dashboard page
-       # Don't set log.ending to failed for image or checkpoint
-       if ($request_log_ending && $request_log_ending =~ /(failed)/) {
-               if ($request_state_name_old =~ 
/(image|checkpoint|inuse|reboot|server)/) {
-                       notify($ERRORS{'DEBUG'}, 0, "request state is 
$request_state_name_old, not setting log.ending to $request_log_ending");
-                       $request_log_ending = 0;
-               }
-       }
-       
-       # Check if new request state was passed
-       if (!$request_state_name_new) {
-               notify($ERRORS{'DEBUG'}, 0, "request state was not specified, 
state not changed");
-       }
-       elsif (!$is_parent_reservation) {
-               notify($ERRORS{'DEBUG'}, 0, "child reservation, request state 
not changed");
-       }
-       else {
-               # Add an entry to the loadlog
-               insertloadlog($reservation_id, $computer_id, "info", "$caller: 
switching request state to $request_state_name_new");
-
-               # Update the request state to $request_state_name_new and set 
laststate to current state
-               if (update_request_state($request_id, $request_state_name_new, 
$request_state_name_old)) {
-                       notify($ERRORS{'OK'}, 0, "request state changed: 
$request_state_name_old->$request_state_name_new, laststate: 
$request_laststate_name_old->$request_state_name_old");
-                       insertloadlog($reservation_id, $computer_id, "info", 
"$caller: request state changed to $request_state_name_new, laststate to 
$request_state_name_old");
-               }
-               else {
-                       notify($ERRORS{'WARNING'}, 0, "request state could not 
be changed: $request_state_name_old --> $request_state_name_new, laststate: 
$request_laststate_name_old->$request_state_name_old");
-                       insertloadlog($reservation_id, $computer_id, "info", 
"$caller: unable to change request state to $request_state_name_new, laststate 
to $request_state_name_old");
-               }
-       } ## end else [ if (!$request_state_name_new)  [elsif 
(!$is_parent_reservation)
-
-       # Update the computer state
-       if (!$computer_state_name_new) {
-               notify($ERRORS{'DEBUG'}, 0, "computer state not specified, 
$computer_shortname state not changed");
-       }
-       else {
-               # Add an entry to the loadlog
-               insertloadlog($reservation_id, $computer_id, "info", "$caller: 
switching computer state to $computer_state_name_new");
-
-               # Update the computer state
-               if (update_computer_state($computer_id, 
$computer_state_name_new)) {
-                       notify($ERRORS{'OK'}, 0, "computer $computer_shortname 
state changed: $computer_state_name_old->$computer_state_name_new");
-               }
-               else {
-                       notify($ERRORS{'CRITICAL'}, 0, "unable to computer 
$computer_shortname state: $computer_state_name_old->$computer_state_name_new");
-               }
-       } ## end else [ if (!$computer_state_name_new)
-
-       # Update log table for this request
-       # Ending can be deleted, released, failed, noack, nologin, timeout, 
EOR, none
-       if (!$request_log_ending) {
-               notify($ERRORS{'DEBUG'}, 0, "log table id=$request_logid will 
not be updated");
-       }
-       elsif (!$request_logid) {
-               # Log ID may not be defined for base image captures
-               notify($ERRORS{'DEBUG'}, 0, "log table ending will not be 
updated, log ID is not defined");
-       }
-       elsif (!$is_parent_reservation) {
-               notify($ERRORS{'DEBUG'}, 0, "child reservation, log table 
id=$request_logid will not be updated");
-       }
-       elsif (update_log_ending($request_logid, $request_log_ending)) {
-               notify($ERRORS{'OK'}, 0, "log table id=$request_logid, ending 
set to $request_log_ending");
-       }
-       else {
-               notify($ERRORS{'CRITICAL'}, 0, "unable to set log table 
id=$request_logid, ending to $request_log_ending");
-       }
-
-       # Call exit if the state changed, return otherwise
-       if ($exit) {
-               insertloadlog($reservation_id, $computer_id, "info", "$caller: 
process exiting");
-               notify($ERRORS{'OK'}, 0, "process exiting");
-               exit;
-       }
-       else {
-               notify($ERRORS{'OK'}, 0, "returning");
-               return;
-       }
-
-} ## end sub switch_state
-
-#//////////////////////////////////////////////////////////////////////////////
-
 =head2 get_management_node_blockrequests
 
  Parameters  : $managementnode_id


Reply via email to