Author: arkurth
Date: Thu Aug 18 16:39:06 2011
New Revision: 1159305
URL: http://svn.apache.org/viewvc?rev=1159305&view=rev
Log:
VCL-500
Updated new.pm to make sure the computer is not being used before processing a
tomaintenance request. Updated utils.pm::check_time to return 'start' for
tomaintenance request only when the start time has been reached.
Modified:
incubator/vcl/trunk/managementnode/lib/VCL/new.pm
incubator/vcl/trunk/managementnode/lib/VCL/utils.pm
Modified: incubator/vcl/trunk/managementnode/lib/VCL/new.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/new.pm?rev=1159305&r1=1159304&r2=1159305&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/new.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/new.pm Thu Aug 18 16:39:06 2011
@@ -103,55 +103,43 @@ sub process {
my $imagerevision_id =
$self->data->get_imagerevision_id();
my $user_standalone =
$self->data->get_user_standalone();
- # If state is tomaintenance, place machine into maintenance state and
set request to complete
- if ($request_state_name =~ /tomaintenance/) {
- notify($ERRORS{'OK'}, 0, "this is a 'tomaintenance' request");
-
- # Update the request state to complete, update the computer
state to maintenance, exit
- # Do not update log.ending for tomaintenance reservations
- if (switch_state($request_data, 'complete', 'maintenance', '',
'0')) {
- notify($ERRORS{'OK'}, 0, "$computer_short_name set to
maintenance");
+ #If reload state is reload and computer is part of block allocation
confirm imagerevisionid is the production image.
+ if ($request_state_name eq 'reload' && is_inblockrequest($computer_id))
{
+ notify($ERRORS{'OK'}, 0, "request state is
'$request_state_name', computer $computer_id is in blockrequest, making sure
reservation is assigned production image revision");
+ my $imagerev_info =
get_production_imagerevision_info($image_id);
+
+ unless($imagerevision_id == $imagerev_info->{id}){
+ notify($ERRORS{'OK'}, 0, "imagerevision_id does not
match imagerevision_id= $imagerevision_id imagerev_info $imagerev_info->{id}");
+ $self->data->set_imagerevision_id($imagerev_info->{id});
+
$self->data->set_sublog_imagerevisionid($imagerev_info->{id});
+
$self->data->set_image_name($imagerev_info->{imagename});
+
$self->data->set_imagerevision_revision($imagerev_info->{revision});
+
+ # Reset variables in this scope
+ $imagerevision_id = $imagerev_info->{id};
+ $image_name = $imagerev_info->{imagename};
}
-
- if ($self->provisioner->can("post_maintenance_action")) {
- if ($self->provisioner->post_maintenance_action()) {
- notify($ERRORS{'OK'}, 0, "post action completed
$computer_short_name");
- }
+ }
+
+ # Confirm requested computer is available
+ if ($self->computer_not_being_used()) {
+ notify($ERRORS{'OK'}, 0, "$computer_short_name is not being
used");
+ }
+ elsif ($request_state_name eq 'tomaintenance') {
+ notify($ERRORS{'CRITICAL'}, 0, "$computer_short_name could not
be put into maintenance because it is NOT available");
+
+ # Return request state back to the original
+ if (update_request_state($request_id, 'failed',
$request_state_name)) {
+ notify($ERRORS{'OK'}, 0, "request state set to
'failed'/'$request_state_name'");
}
else {
- notify($ERRORS{'OK'}, 0, "post action skipped,
post_maintenance_action not implemented by " . ref($self->provisioner) . ",
assuming no steps required");
+ notify($ERRORS{'WARNING'}, 0, "failed to set request
state back to 'failed'/'$request_state_name'");
}
notify($ERRORS{'OK'}, 0, "exiting");
exit;
}
-
- #If reload state is not new (reload) and computer is part of block
allocation
- #confirm imagerevisionid is the production image.
- if($request_state_name !~ /^(new|reinstall)$/) {
- notify($ERRORS{'OK'}, 0, "request_state_name is not new");
- if(is_inblockrequest($computer_id)){
- notify($ERRORS{'OK'}, 0, "computer_id $computer_id is
in blockrequest");
- my $imagerev_info =
get_production_imagerevision_info($image_id);
- unless($imagerevision_id == $imagerev_info->{id}){
- notify($ERRORS{'OK'}, 0, "imagerevision_id does
not match imagerevision_id= $imagerevision_id imagerev_info
$imagerev_info->{id}");
-
$self->data->set_imagerevision_id($imagerev_info->{id});
-
$self->data->set_sublog_imagerevisionid($imagerev_info->{id});
-
$self->data->set_image_name($imagerev_info->{imagename});
-
$self->data->set_imagerevision_revision($imagerev_info->{revision});
-
- #reset variables in this scope
- $imagerevision_id = $imagerev_info->{id};
- $image_name = $imagerev_info->{imagename};
- }
- }
- }
-
- # Confirm requested computer is available
- if ($self->computer_not_being_used()) {
- notify($ERRORS{'OK'}, 0, "$computer_short_name is not being
used");
- }
elsif ($request_state_name ne 'new') {
# Computer is not available, not a new request (most likely a
simple reload)
notify($ERRORS{'WARNING'}, 0, "request
state=$request_state_name, $computer_short_name is NOT available");
@@ -201,8 +189,7 @@ sub process {
# Only the parent reservation is allowed to modify the request
state in this module
if (!$reservation_is_parent) {
- notify($ERRORS{'OK'}, 0, "child preload reservation,
computer is not available, states will be changed by the parent");
- notify($ERRORS{'OK'}, 0, "exiting");
+ notify($ERRORS{'OK'}, 0, "child preload reservation,
computer is not available, states will be changed by the parent, exiting");
exit;
}
@@ -239,11 +226,52 @@ sub process {
else {
# Computer not available, state=new, PRELOADONLY = false
notify($ERRORS{'WARNING'}, 0, "$computer_short_name is NOT
available");
-
+
# Call reservation_failed
$self->reservation_failed("process failed because computer is
not available");
}
+ # If state is tomaintenance, place machine into maintenance state and
set request to complete
+ if ($request_state_name =~ /tomaintenance/) {
+ notify($ERRORS{'OK'}, 0, "setting computer $computer_short_name
state to 'maintenance'");
+
+ # Set the computer state to 'maintenance' first
+ if (update_computer_state($computer_id, 'maintenance')) {
+ notify($ERRORS{'OK'}, 0, "$computer_short_name state
set to 'maintenance'");
+ }
+ else {
+ notify($ERRORS{'CRITICAL'}, 0, "failed to set
$computer_short_name state to 'maintenance', exiting");
+ exit;
+ }
+
+ if ($self->provisioner->can("post_maintenance_action")) {
+ notify($ERRORS{'DEBUG'}, 0, "attempting to perform post
maintenance actions for provisioning engine: " . ref($self->provisioner));
+
+ if ($self->provisioner->post_maintenance_action()) {
+ notify($ERRORS{'OK'}, 0, "post maintenance
actions completed $computer_short_name");
+ }
+ else {
+ notify($ERRORS{'CRITICAL'}, 0, "failed to
complete post maintenance actions on $computer_short_name");
+ }
+ }
+ else {
+ notify($ERRORS{'DEBUG'}, 0, "post maintenance actions
skipped, post_maintenance_action subroutine not implemented by " .
ref($self->provisioner));
+ }
+
+
+ # Update the request state to complete
+ # Do not update log.ending for tomaintenance reservations
+ if (update_request_state($request_id, 'complete',
$request_state_name)) {
+ notify($ERRORS{'OK'}, 0, "request state set to
'complete'/'$request_state_name'");
+ }
+ else {
+ notify($ERRORS{'WARNING'}, 0, "failed to set request
state to 'complete'/'$request_state_name'");
+ }
+
+ notify($ERRORS{'OK'}, 0, "exiting");
+ exit;
+ }
+
# Confirm requested resouces are available
if ($self->reload_image()) {
notify($ERRORS{'OK'}, 0, "$computer_short_name is loaded with
$image_name");
Modified: incubator/vcl/trunk/managementnode/lib/VCL/utils.pm
URL:
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1159305&r1=1159304&r2=1159305&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/utils.pm Thu Aug 18 16:39:06 2011
@@ -289,7 +289,6 @@ INIT {
my $cwd = getcwd();
our $CONF_FILE_PATH = "$cwd/$hostname.conf";
if (!-f $CONF_FILE_PATH) {
- print STDOUT "file does not exist: $CONF_FILE_PATH\n";
if ($BIN_PATH =~ /dev/) {
$CONF_FILE_PATH = "/etc/vcl/vcldev.conf";
}
@@ -1020,9 +1019,7 @@ sub check_blockrequest_time {
sub check_time {
my ($request_start, $request_end, $reservation_lastcheck,
$request_state_name, $request_laststate_name) = @_;
-
- my ($package, $filename, $line, $sub) = caller(0);
-
+
# Check the arguments
if (!defined($request_state_name)) {
notify($ERRORS{'WARNING'}, 0, "\$request_state_name argument is
not defined");
@@ -1075,10 +1072,10 @@ sub check_time {
#notify($ERRORS{'OK'}, 0, "request end time difference:
$end_diff_minutes minutes");
# Check the state, and then figure out the return code
- if ($request_state_name =~
/new|imageprep|reload|tomaintenance|tovmhostinuse/) {
+ if ($request_state_name =~ /new|imageprep|reload|tovmhostinuse/) {
if ($start_diff_minutes > 0) {
# Start time is either now or in future,
$start_diff_minutes is positive
-
+
if ($start_diff_minutes > 35) {
#notify($ERRORS{'DEBUG'}, 0, "reservation will
start in more than 35 minutes ($start_diff_minutes)");
return "0";
@@ -1094,18 +1091,29 @@ sub check_time {
} ## end if ($start_diff_minutes > 0)
else {
# Start time is in past, $start_diff_minutes is negative
-
+
#Start time is fairly old - something is off
#send warning to log for tracking purposes
if ($start_diff_minutes < -17) {
notify($ERRORS{'WARNING'}, 0, "reservation
start time was in the past 17 minutes ($start_diff_minutes)");
}
-
+
return "start";
-
+
} ## end else [ if ($start_diff_minutes > 0)
- } ## end if ($request_state_name =~
/new|imageprep|reload|tomaintenance|tovmhostinuse/)
-
+ }
+ elsif ($request_state_name =~ /tomaintenance/) {
+ if ($start_diff_minutes > 0) {
+ # Start time is either now or in future,
$start_diff_minutes is positive
+ notify($ERRORS{'DEBUG'}, 0, "$request_state_name
request will be processed in $start_diff_minutes minutes");
+ return "0";
+ }
+ else {
+ # Start time is in past, $start_diff_minutes is negative
+ notify($ERRORS{'DEBUG'}, 0, "$request_state_name
request will be processed now");
+ return "start";
+ }
+ }
elsif ($request_state_name =~ /inuse/) {
if ($end_diff_minutes <= 10) {
notify($ERRORS{'DEBUG'}, 0, "reservation will end in 10
minutes or less ($end_diff_minutes)");
@@ -7600,16 +7608,16 @@ sub firewall_compare_update {
my @sshcmd1 =
run_ssh_command($node, $identity, $netshcmd, "root");
foreach my $line
(@{$sshcmd1[1]}) {
if ($line =~ /Ok./) {
-
notify($ERRORS{'OK'}, 0, "firewall_compare_update: firewall updated with
$scopeaddress");
+
notify($ERRORS{'OK'}, 0, "firewall updated with $scopeaddress");
return 1;
}
else {
-
notify($ERRORS{'DEBUG'}, 0, "firewall_compare_update netsh output $line ");
+
notify($ERRORS{'DEBUG'}, 0, "netsh output: $line ");
}
}
} ## end if ($update_scope)
else {
- notify($ERRORS{'DEBUG'}, 0,
"firewall_compare_update scope of ipaddess matches no change needed");
+ notify($ERRORS{'DEBUG'}, 0,
"scope of ipaddess matches no change needed");
}
} ## end if ($l =~
/(\s*Scope:\s*)([.0-9]*)(\/)([.0-9]*)/)
} ## end if ($scopelook)