Author: arkurth
Date: Fri Jun 19 18:55:55 2009
New Revision: 786628

URL: http://svn.apache.org/viewvc?rev=786628&view=rev
Log:
VCL-157
xCAT.pm's image_size() sub was returning undefined if the image didn't exist, 
causing errors if an attempt was made to use the undefined value. I changed 
this sub to return 0 if the image doesn't exist, and undefined only if a 
problem occurred trying to get the image size.

Modified capture_monitor() in xCAT21.pm and xCAT.pm to check if result from 
get_image_size() is defined.

Modified:
    incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm
    incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm

Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm?rev=786628&r1=786627&r2=786628&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm 
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Fri 
Jun 19 18:55:55 2009
@@ -1410,15 +1410,18 @@
                my $current_image_size = $self->get_image_size($image_name);
 
                # Check if image size is larger than the last time it was 
checked
-               if ($current_image_size > $image_size) {
+               if (defined $current_image_size && $current_image_size > 
$image_size) {
                        notify($ERRORS{'OK'}, 0, "image size has increased: 
$image_size -> $current_image_size, still copying");
                        $image_size = $current_image_size;
                        #reset capture_loop_count
                        $capture_loop_count = 0;
                }
-               else {
+               elsif (defined $current_image_size) {
                        notify($ERRORS{'OK'}, 0, "image size is the same: 
$image_size=$current_image_size, copy may be complete");
                }
+               else {
+                       notify($ERRORS{'WARNING'}, 0, "unable to determine 
current image size");
+               }
        } ## end for (my $capture_loop_count = 0; $capture_loop_count...
 
        # Exiting waiting loop, nodeset status should be boot if successful
@@ -3154,7 +3157,7 @@
        my $self = shift;
        if (ref($self) !~ /xCAT/i) {
                notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a 
function, it must be called as a class method");
-               return 0;
+               return;
        }
 
        # Either use a passed parameter as the image name or use the one stored 
in this object's DataStructure
@@ -3162,19 +3165,19 @@
        $image_name = $self->data->get_image_name() if !$image_name;
        if (!$image_name) {
                notify($ERRORS{'CRITICAL'}, 0, "image name could not be 
determined");
-               return 0;
+               return;
        }
        notify($ERRORS{'DEBUG'}, 0, "getting size of image: $image_name");
 
        my $image_repository_path = $self->_get_image_repository_path();
        if (!$image_repository_path) {
                notify($ERRORS{'CRITICAL'}, 0, "unable to determine image 
repository location, returning 0");
-               return 0;
+               return;
        }
 
        # Execute the command
        my $du_command = "du -c $image_repository_path/$image_name.* 2>&1";
-       notify($ERRORS{'DEBUG'}, 0, "du command: $du_command");
+       #notify($ERRORS{'DEBUG'}, 0, "du command: $du_command");
        my $du_output = `$du_command`;
 
        # Save the exit status
@@ -3188,8 +3191,8 @@
        
        # Check if image doesn't exist
        if ($du_output && $du_output =~ /No such file.*0\s+total/is) {
-               notify($ERRORS{'WARNING'}, 0, "image does not exist: 
$image_repository_path/$image_name.*");
-               return;
+               notify($ERRORS{'OK'}, 0, "image does not exist: 
$image_repository_path/$image_name.*, returning 0");
+               return 0;
        }
        
        # Check the du command output

Modified: 
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm?rev=786628&r1=786627&r2=786628&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm 
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm 
Fri Jun 19 18:55:55 2009
@@ -1534,15 +1534,16 @@
                        $status =~ s/$computer_node_name: //;
                } ## end foreach my $l (@file)
        } ## end if (open(NODESTAT, "$XCAT_ROOT/bin/nodestat 
$computer_node_name stat 2>&1 |"...
-       #else {
-               # could not run nodestat command, fall back to watching image 
size
-               # Check the image size to see if it's growing
-               notify($ERRORS{'OK'}, 0, "checking size of image");
-               my $size = $self->get_image_size($image_name);
+       
+       # could not run nodestat command, fall back to watching image size
+       # Check the image size to see if it's growing
+       notify($ERRORS{'OK'}, 0, "checking size of image");
+       my $size = $self->get_image_size($image_name);
+       if (defined $size) {
                notify($ERRORS{'OK'}, 0, "retrieved size of image: $size");
                
                if ($size > $filesize) {
-                       notify($ERRORS{'OK'}, 0, "image size has changed: 
$size, still copying");
+                       notify($ERRORS{'OK'}, 0, "image size has changed: 
$filesize -> $size, still copying");
                        $filesize    = $size;
                        $fullloopcnt = 0;
                }
@@ -1554,8 +1555,10 @@
                        }
                        $filewatchcnt++;
                }
-               
-       #} ## end else [ if (open(NODESTAT, "$XCAT_ROOT/bin/nodestat 
$computer_node_name stat 2>&1 |"...
+       }
+       else {
+               notify($ERRORS{'WARNING'}, 0, "unable to retrieve current size 
of image");
+       }
        
        if ($status =~ /partimage-ng: partition/) {
                if ($status eq $laststatus) {


Reply via email to