You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by fa...@apache.org on 2013/12/10 21:38:04 UTC

svn commit: r1549959 - in /vcl/trunk/managementnode/lib/VCL: Module/Predictive/Level_0.pm Module/Predictive/Level_1.pm new.pm utils.pm

Author: fapeeler
Date: Tue Dec 10 20:38:04 2013
New Revision: 1549959

URL: http://svn.apache.org/r1549959
Log:
VCL-739

use nextimageid if set
clear nextimageid after pulling info
removed updating of nextimageid for reload


Modified:
    vcl/trunk/managementnode/lib/VCL/Module/Predictive/Level_0.pm
    vcl/trunk/managementnode/lib/VCL/Module/Predictive/Level_1.pm
    vcl/trunk/managementnode/lib/VCL/new.pm
    vcl/trunk/managementnode/lib/VCL/utils.pm

Modified: vcl/trunk/managementnode/lib/VCL/Module/Predictive/Level_0.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Predictive/Level_0.pm?rev=1549959&r1=1549958&r2=1549959&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Predictive/Level_0.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Predictive/Level_0.pm Tue Dec 10 20:38:04 2013
@@ -172,6 +172,11 @@ sub get_next_image {
 	AND computer.id = $computer_id
 	";
 
+	#Clear next_imageid
+	if(!clear_next_image_id($computer_id)){
+	   notify($ERRORS{'WARNING'}, 0, "$notify_prefix failed to clear next_image_id for computerid $computer_id");
+	}
+
 	# Call the database select subroutine
 	# This will return an array of one or more rows based on the select statement
 	my @next_selected_rows = database_select($select_nextimage);

Modified: vcl/trunk/managementnode/lib/VCL/Module/Predictive/Level_1.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Predictive/Level_1.pm?rev=1549959&r1=1549958&r2=1549959&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Predictive/Level_1.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Predictive/Level_1.pm Tue Dec 10 20:38:04 2013
@@ -84,6 +84,7 @@ sub get_next_image {
 	my $reservation_id      = $self->data->get_reservation_id();
 	my $computer_id         = $self->data->get_computer_id();
 	my $computer_short_name = $self->data->get_computer_short_name();
+	my $computer_nextimage_id = $self->data->get_computer_nextimage_id();
 
 	my @ret_array;
 	my $notify_prefix = "predictive_reload_Level_1 :";
@@ -93,7 +94,7 @@ sub get_next_image {
 	#check if node is part of block reservation 
 	if(is_inblockrequest($computer_id)){
 		notify($ERRORS{'DEBUG'}, 0, "computer id $computer_id is in blockComputers table");
-		 my @block_ret_array = get_block_request_image_info($computer_id);
+		my @block_ret_array = get_block_request_image_info($computer_id);
 
 		if(defined($block_ret_array[0]) && $block_ret_array[0]){
 			return @block_ret_array;
@@ -101,6 +102,47 @@ sub get_next_image {
 		else{
 			notify($ERRORS{'WARNING'}, 0, "computer $computer_id is part of blockComputers, failed to return image info"); 
 		}
+	}
+
+	#If nextimageid set, set to default 0 and return the imageid
+	if(defined($computer_nextimage_id) && $computer_nextimage_id) {
+		#Get computer_nextimage_id info
+		my $select_nextimage = " 
+		SELECT DISTINCT
+		imagerevision.imagename AS imagename,
+		imagerevision.id AS imagerevisionid,
+		image.id AS imageid
+		FROM
+		image,
+		computer,
+		imagerevision
+		WHERE
+		imagerevision.imageid = computer.nextimageid
+		AND imagerevision.production = 1
+		AND computer.nextimageid = image.id
+		AND computer.id = $computer_id
+		";
+		
+		#Clear next_imageid
+		if(!clear_next_image_id($computer_id)){
+			notify($ERRORS{'WARNING'}, 0, "$notify_prefix failed to clear next_image_id for computerid $computer_id");
+		}
+
+		# Call the database select subroutine
+		# This will return an array of one or more rows based on the select statement
+		my @next_selected_rows = database_select($select_nextimage);
+		# Check to make sure at least 1 row were returned
+		if (scalar @next_selected_rows == 0) {
+			notify($ERRORS{'WARNING'}, 0, "$notify_prefix failed to fetch next image for computerid $computer_id");
+		}   
+		elsif (scalar @next_selected_rows > 1) {      notify($ERRORS{'WARNING'}, 0, "" . scalar @next_selected_rows . " rows were returned from database select");
+		}
+		else {
+			notify($ERRORS{'OK'}, 0, "$notify_prefix returning nextimage image=$next_selected_rows[0]{imagename} imageid=$next_selected_rows[0]{imageid}");
+			my @next_image_ret_array;
+			push(@next_image_ret_array, $next_selected_rows[0]{imagename}, $next_selected_rows[0]{imageid}, $next_selected_rows[0]{imagerevisionid});
+			return @next_image_ret_array;
+		}
 
 	}
 

Modified: vcl/trunk/managementnode/lib/VCL/new.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/new.pm?rev=1549959&r1=1549958&r2=1549959&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/new.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/new.pm Tue Dec 10 20:38:04 2013
@@ -671,7 +671,7 @@ sub reload_image {
 	}
 	
 	# Update the current image ID in the computer table
-	if (update_currentimage($computer_id, $image_id, $imagerevision_id, $image_id)) {
+	if (update_currentimage($computer_id, $image_id, $imagerevision_id)) {
 		notify($ERRORS{'OK'}, 0, "updated computer table for $computer_short_name: currentimageid=$image_id");
 	}
 	else {

Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1549959&r1=1549958&r2=1549959&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Tue Dec 10 20:38:04 2013
@@ -87,6 +87,7 @@ our @EXPORT = qw(
   check_ssh
   check_time
   clearfromblockrequest
+  clear_next_image_id
   convert_to_datetime
   convert_to_epoch_seconds
   create_management_node_directory
@@ -3490,7 +3491,7 @@ EOF
 	my $imagemeta_id = $image_info->{imagemetaid};
 	my $imagemeta_info = get_imagemeta_info($imagemeta_id);
 	$image_info->{imagemeta} = $imagemeta_info;
-	
+
 	my $image_owner_id = $image_info->{ownerid};
 	my $image_owner_user_info = get_user_info($image_owner_id);
 	$image_info->{owner} = $image_owner_user_info;
@@ -5631,6 +5632,46 @@ sub update_blockrequest_processing {
 	}
 } ## end sub update_blockrequest_processing
 
+
+
+#/////////////////////////////////////////////////////////////////////////////
+
+=head2 clear_next_image_id
+
+ Parameters  : $computer_id
+ Returns     : 0 or 1
+ Description : sets next_image_id to 0
+
+=cut
+sub clear_next_image_id {
+	my ($computer_id) = @_;
+	my ($package, $filename, $line, $sub) = caller(0);
+	# Check the passed parameter
+	if (!(defined($computer_id))) {
+		notify($ERRORS{'WARNING'}, 0, "computer_id was not specified");
+		return 0;
+	}
+
+	my $update_statement = "
+	UPDATE
+	computer
+	SET
+	nextimageid = '0'
+	WHERE
+	id = $computer_id
+	";
+
+	if (database_execute($update_statement)) {
+		notify($ERRORS{'OK'}, 0, "updated nextimageid to 0 for computer id $computer_id");
+		return 1;
+	}
+	else {
+		notify($ERRORS{'WARNING'}, 0, "unable to update database, failed to set nextimageid=0 for computerid $computer_id");
+		return 0;
+	}
+
+}
+
 #/////////////////////////////////////////////////////////////////////////////
 
 =head2 clearfromblockrequest