Author: fapeeler
Date: Wed Oct 31 15:39:54 2012
New Revision: 1404208

URL: http://svn.apache.org/viewvc?rev=1404208&view=rev
Log:
VCL-630
syncing the code section to trunk from vcl-2.3-bugfixes
 
To improve the data collection and improve the use of the currentimage.txt 
contents, the following changes made:

OS.pm:
renamed get_current_image_name to get_current_image_info
get_current_image_info can return any requested variable it contains, by 
default is imagerevision_id
Also it updates the DataStructure with the most current data.

i.e Using, $self->data->get_computer_currentimage_vcld_post_load() will return 
the current post_load status contained in the currentimage.txt on the node. 
This is to store the data and reduce any additional  ssh logins in the future.

Other Modules listed are small changes related to the OS.pm change


Modified:
    vcl/trunk/managementnode/lib/VCL/DataStructure.pm
    vcl/trunk/managementnode/lib/VCL/Module/OS.pm
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning.pm
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vbox.pm
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT2.pm
    vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm
    vcl/trunk/managementnode/lib/VCL/reclaim.pm
    vcl/trunk/managementnode/lib/VCL/utils.pm

Modified: vcl/trunk/managementnode/lib/VCL/DataStructure.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/DataStructure.pm?rev=1404208&r1=1404207&r2=1404208&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/DataStructure.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/DataStructure.pm Wed Oct 31 15:39:54 2012
@@ -272,6 +272,8 @@ $SUBROUTINE_MAPPINGS{vmhost_profile_eth1
 $SUBROUTINE_MAPPINGS{vmhost_repository_imagetype_name} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{repositoryimagetype}{name}';
 $SUBROUTINE_MAPPINGS{vmhost_datastore_imagetype_name} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{vmhost}{datastoreimagetype}{name}';
 
+$SUBROUTINE_MAPPINGS{computer_currentimage_data} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}';
+$SUBROUTINE_MAPPINGS{computer_currentimagerevision_data} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimagerevision}';
 $SUBROUTINE_MAPPINGS{computer_currentimage_architecture} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{architecture}';
 $SUBROUTINE_MAPPINGS{computer_currentimage_deleted} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{deleted}';
 $SUBROUTINE_MAPPINGS{computer_currentimage_forcheckout} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{forcheckout}';
@@ -293,6 +295,7 @@ $SUBROUTINE_MAPPINGS{computer_currentima
 $SUBROUTINE_MAPPINGS{computer_currentimage_reloadtime} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{reloadtime}';
 $SUBROUTINE_MAPPINGS{computer_currentimage_size} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{size}';
 $SUBROUTINE_MAPPINGS{computer_currentimage_test} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{test}';
+$SUBROUTINE_MAPPINGS{computer_currentimage_vcld_post_load} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimage}{vcld_post_load}';
  
 $SUBROUTINE_MAPPINGS{computer_currentimagerevision_comments} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimagerevision}{comments}';
 $SUBROUTINE_MAPPINGS{computer_currentimagerevision_datecreated} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimagerevision}{datecreated}';
 $SUBROUTINE_MAPPINGS{computer_currentimagerevision_deleted} = 
'$self->request_data->{reservation}{RESERVATION_ID}{computer}{currentimagerevision}{deleted}';

Modified: vcl/trunk/managementnode/lib/VCL/Module/OS.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/OS.pm?rev=1404208&r1=1404207&r2=1404208&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/OS.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/OS.pm Wed Oct 31 15:39:54 2012
@@ -275,33 +275,60 @@ sub get_currentimage_txt_contents {
        else {
                notify($ERRORS{'DEBUG'}, 0, "retrieved currentimage.txt 
contents from $computer_node_name:\n" . join("\n", @$cat_output));
        }
-       return @{$cat_output};
+
+       my %output;
+       my @current_image_txt_contents = @{$cat_output};
+
+       my $current_image_name; 
+       if(defined $current_image_txt_contents[0]) {
+               $output{"current_image_name"} = $current_image_txt_contents[0];
+       }
+       
+       foreach my $l (@current_image_txt_contents) {
+               #remove any line break characters
+               $l =~ s/[\r\n]*//g;
+               my ($a, $b) = split(/=/, $l);
+               if(defined $b) {
+         $output{$a} = $b; 
+      }   
+   }
+       
+       return %output;
 } ## end sub get_currentimage_txt_contents
 
 #/////////////////////////////////////////////////////////////////////////////
 
-=head2 get_current_image_name
+=head2 get_current_image_info
 
- Parameters  : None
- Returns     : If successful: string
+ Parameters  : optional 
+                                       
id,computer_hostname,computer_id,current_image_name,imagerevision_datecreated,imagerevision_id,prettyname,vcld_post_load
 
+ Returns     : If successful: 
+                                       if no parameter return the 
imagerevision_id
+                                       return the value of parameter input
                If failed: false
- Description : Reads the currentimage.txt file on a computer and returns a
-               string containing the name of the loaded image.
-
+ Description : Collects currentimage hash on a computer and returns a
+               value containing of the input paramter or the imagerevision_id 
if no inputs.
+                                       This also updates the DataStructure.pm 
so data matches what is currently loaded.
 =cut
 
-sub get_current_image_name {
+sub get_current_image_info {
        my $self = shift;
        if (ref($self) !~ /VCL::Module/i) {
                notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a 
function, it must be called as a class method");
                return;
        }
 
+       my $input = shift;
+
+       if(!defined $input) {
+               $input = "imagerevision_id";
+       }
+
        my $computer_node_name = $self->data->get_computer_node_name();
 
        # Get the contents of the currentimage.txt file
-       my @current_image_txt_contents;
-       if (@current_image_txt_contents = 
$self->get_currentimage_txt_contents()) {
+       my %current_image_txt_contents;
+       if (%current_image_txt_contents = 
$self->get_currentimage_txt_contents()) {
                notify($ERRORS{'DEBUG'}, 0, "retrieved currentimage.txt 
contents from $computer_node_name");
        }
        else {
@@ -309,18 +336,29 @@ sub get_current_image_name {
                return;
        }
 
-       # Make sure an empty array wasn't returned
-       if (defined $current_image_txt_contents[0]) {
-               my $current_image_name = $current_image_txt_contents[0];
-
-               # Remove any line break characters
-               $current_image_name =~ s/[\r\n]*//g;
-
-               notify($ERRORS{'DEBUG'}, 0, "name of image currently loaded on 
$computer_node_name: $current_image_name");
-               return $current_image_name;
+       # Make sure an empty hash wasn't returned
+       if (defined $current_image_txt_contents{imagerevision_id}) {
+               notify($ERRORS{'DEBUG'}, 0, "user selected content of image 
currently loaded on $computer_node_name: 
$current_image_txt_contents{current_image_name}");
+       
+               if (my $imagerevision_info = 
get_imagerevision_info($current_image_txt_contents{imagerevision_id})){
+                       
$self->data->set_computer_currentimage_data($imagerevision_info->{image});
+                       
$self->data->set_computer_currentimagerevision_data($imagerevision_info);
+                       
+                       if (defined 
$current_image_txt_contents{"vcld_post_load"}) {
+                               
$self->data->set_computer_currentimage_vcld_post_load($current_image_txt_contents{vcld_post_load});
+                       }
+               }
+               
+               if (defined($current_image_txt_contents{$input})){
+                       return $current_image_txt_contents{$input};
+               }
+               else {
+                       notify($ERRORS{'WARNING'}, 0, "$input was not defined 
in current_image_txt");   
+                       return;
+               }
        }
        else {
-               notify($ERRORS{'WARNING'}, 0, "empty array was returned when 
currentimage.txt contents were retrieved from $computer_node_name");
+               notify($ERRORS{'WARNING'}, 0, "empty hash was returned when 
currentimage.txt contents were retrieved from $computer_node_name");
                return;
        }
 }
@@ -967,62 +1005,6 @@ sub update_public_ip_address {
 
 #/////////////////////////////////////////////////////////////////////////////
 
-=head2 get_vcld_post_load_status
-
- Parameters  : None
- Returns     : If vcld_post_load line exists: 1
-               If vcld_post_load line exists: 0
-               If an error occurred: undefined
- Description : Checks the currentimage.txt file on the computer for a line
-               beginning with 'vcld_post_load='. Returns 1 if this line is 
found
-               indicating that the OS module's post_load tasks have 
successfully
-               run. Returns 0 if the line is not found, and undefined if an
-               error occurred.
-
-=cut
-
-sub get_vcld_post_load_status {
-       my $self = shift;
-       if (ref($self) !~ /VCL::Module/i) {
-               notify($ERRORS{'CRITICAL'}, 0, "subroutine was called as a 
function, it must be called as a class method");
-               return;
-       }
-       
-       # Make sure the OS module implements a post load subroutine
-       if (!$self->can('post_load')) {
-               notify($ERRORS{'DEBUG'}, 0, "OS module " . ref($self) . " does 
not implement a post_load subroutine, returning 1");
-               return 1;
-       }
-       
-       my $management_node_keys = $self->data->get_management_node_keys();
-       my $computer_node_name   = $self->data->get_computer_node_name();
-       
-       # Add a line to the end of currentimage.txt
-       my $command = "grep vcld_post_load= currentimage.txt";
-       
-       my ($exit_status, $output) = run_ssh_command($computer_node_name, 
$management_node_keys, $command, '', '', 0);
-       if (defined($output)) {
-               if (my ($status_line) = grep(/vcld_post_load=/, @$output)) {
-                       notify($ERRORS{'DEBUG'}, 0, "vcld post load tasks have 
run on $computer_node_name: $status_line");
-                       return 1;
-               }
-               else {
-                       notify($ERRORS{'DEBUG'}, 0, "vcld post load tasks have 
NOT run on $computer_node_name");
-                       return 0;
-               }
-       }
-       elsif ($exit_status) {
-               notify($ERRORS{'WARNING'}, 0, "failed to retrieve 
vcld_post_load status line from currentimage.txt on $computer_node_name, exit 
status: $exit_status, output:\n" . join("\n", @$output));
-               return;
-       }
-       else {
-               notify($ERRORS{'WARNING'}, 0, "failed to run SSH command to 
retrieve vcld_post_load status line from currentimage.txt on 
$computer_node_name");
-               return;
-       }
-}
-
-#/////////////////////////////////////////////////////////////////////////////
-
 =head2 set_vcld_post_load_status
 
  Parameters  : none

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning.pm?rev=1404208&r1=1404207&r2=1404208&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning.pm Wed Oct 31 15:39:54 
2012
@@ -157,8 +157,9 @@ sub node_status {
        my $computer_name = $self->data->get_computer_node_name();
        my $image_name = $self->data->get_image_name();
        my $request_forimaging = $self->data->get_request_forimaging();
+       my $imagerevision_id = $self->data->get_imagerevision_id();
        
-       notify($ERRORS{'DEBUG'}, 0, "attempting to check the status of computer 
$computer_name, image: $image_name");
+       notify($ERRORS{'DEBUG'}, 0, "attempting to check the status of computer 
$computer_name, image: $image_name imagerevision_id; $imagerevision_id");
        
        # Create a hash reference and populate it with the default values
        my $status;
@@ -182,24 +183,28 @@ sub node_status {
        }
        
        # Get the contents of currentimage.txt and check if currentimage.txt 
matches the requested image name
-       my $current_image_name = $self->os->get_current_image_name();
-       $status->{currentimage} = $current_image_name;
+       my $current_image_revision_id = $self->os->get_current_image_info();
+       $status->{currentimagerevision_id} = $current_image_revision_id;
+
+       $status->{currentimage} = $self->data->get_computer_currentimage_name();
+       my $vcld_post_load_status = 
$self->data->get_computer_currentimage_vcld_post_load();
        
-       if (!$current_image_name) {
-               notify($ERRORS{'OK'}, 0, "unable to retrieve image name from 
currentimage.txt on $computer_name, returning 'RELOAD'");
+       if (!$current_image_revision_id) {
+               notify($ERRORS{'OK'}, 0, "unable to retrieve currentimage.txt 
contents on $computer_name, returning 'RELOAD'");
                return $status;
        }
-       elsif ($current_image_name eq $image_name) {
-               notify($ERRORS{'DEBUG'}, 0, "currentimage.txt image 
($current_image_name) matches requested image name ($image_name) on 
$computer_name");
+       #elsif ($current_image_name eq $image_name) {
+       elsif ($current_image_revision_id eq $imagerevision_id) {
+               notify($ERRORS{'DEBUG'}, 0, "currentimage.txt image 
$current_image_revision_id ($status->{currentimage}) matches requested image 
$imagerevision_id ($image_name) on $computer_name");
                $status->{image_match} = 1;
        }
        else {
-               notify($ERRORS{'OK'}, 0, "currentimage.txt image 
($current_image_name) does not match requested image name ($image_name) on 
$computer_name, returning 'RELOAD'");
+               notify($ERRORS{'OK'}, 0, "currentimage.txt image 
$current_image_revision_id ($status->{currentimage}) does not match requested 
image name $imagerevision_id ($image_name) on $computer_name, returning 
'RELOAD'");
                return $status;
        }
        
        # Check if the OS post_load tasks have run
-       if ($self->os->get_vcld_post_load_status()) {
+       if ($vcld_post_load_status) {
                notify($ERRORS{'DEBUG'}, 0, "OS module post_load tasks have 
been completed on $computer_name");
                $status->{status} = 'READY';
        }

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm?rev=1404208&r1=1404207&r2=1404208&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm 
(original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/VMware/VMware.pm Wed 
Oct 31 15:39:54 2012
@@ -527,6 +527,7 @@ sub load {
                return;
        }
        
+       
        # Power on the VM
        if (!$self->power_on($vmx_file_path)) {
                notify($ERRORS{'WARNING'}, 0, "failed to power on VM 
$computer_name on VM host: $vmhost_name");
@@ -1157,6 +1158,7 @@ sub node_status {
        my $computer_name = $self->data->get_computer_node_name();
        my $image_name = $self->data->get_image_name();
        my $request_forimaging = $self->data->get_request_forimaging();
+   my $imagerevision_id = $self->data->get_imagerevision_id();
        
        notify($ERRORS{'OK'}, 0, "attempting to check the status of computer 
$computer_name, image: $image_name");
        
@@ -1203,20 +1205,24 @@ sub node_status {
                return $status;
        }
        
-       # Get the contents of currentimage.txt and check if currentimage.txt 
matches the requested image name
-       my $current_image_name = $self->os->get_current_image_name();
-       $status->{currentimage} = $current_image_name;
+       # Get the contents of currentimage.txt and update the datastructure
+       my $current_image_revision_id = $self->os->get_current_image_info();
+   $status->{currentimagerevision_id} = $current_image_revision_id;
+
+   $status->{currentimage} = $self->data->get_computer_currentimage_name();
+       my $current_image_name = $status->{currentimage};
+       my $vcld_post_load_status = 
$self->data->get_computer_currentimage_vcld_post_load();
        
-       if (!$current_image_name) {
+       if (!$current_image_revision_id) {
                notify($ERRORS{'OK'}, 0, "unable to retrieve image name from 
currentimage.txt on VM $computer_name, returning 'RELOAD'");
                return $status;
        }
-       elsif ($current_image_name eq $image_name) {
-               notify($ERRORS{'OK'}, 0, "currentimage.txt image 
($current_image_name) matches requested image name ($image_name) on VM 
$computer_name");
+       elsif ($current_image_revision_id eq $imagerevision_id) {
+               notify($ERRORS{'OK'}, 0, "currentimage.txt image 
$current_image_revision_id ($current_image_name) matches requested 
imagerevision_id $imagerevision_id ($image_name) on VM $computer_name");
                $status->{image_match} = 1;
        }
        else {
-               notify($ERRORS{'OK'}, 0, "currentimage.txt image 
($current_image_name) does not match requested image name ($image_name) on VM 
$computer_name, returning 'RELOAD'");
+               notify($ERRORS{'OK'}, 0, "currentimage.txt imagerevision_id 
$current_image_revision_id ($current_image_name) does not match requested 
imagerevision_id $imagerevision_id ($image_name) on VM $computer_name, 
returning 'RELOAD'");
                return $status;
        }
        
@@ -1284,7 +1290,7 @@ sub node_status {
        }
        
        # Check if the OS post_load tasks have run
-       if ($self->os->get_vcld_post_load_status()) {
+       if ($vcld_post_load_status) {
                notify($ERRORS{'OK'}, 0, "OS module post_load tasks have been 
completed on VM $computer_name");
                $status->{status} = 'READY';
        }
@@ -1845,25 +1851,25 @@ sub prepare_vmx {
        # ide needed for boot
        # usb needed for mouse
        # monitor, ich7m, smc for darwin
-       if ($image_os_type =~ /osx/i) {
-               %vmx_parameters = (%vmx_parameters, (
-                       "ide1:0.clientDevice" => "TRUE",
-                       "ide1:0.deviceType" => "atapi-cdrom",
-                       "ide1:0.fileName" => "",           
-                       "ide1:0.present" => "TRUE", 
-                       "ide1:0.startConnected" => "FALSE",
-                       "usb.present" => "TRUE",                              
-                       "usb:1.deviceType" => "hub",      
-                       "usb:1.present" => "TRUE",    
-                       "usb:2.deviceType" => "mouse",    
-                       "usb:2.present" => "TRUE", 
-                       "monitor.virtual_exec" => "hardware",
-                       "monitor.virtual_mmu" => "software",
-                       "ich7m.present" => "TRUE",
-                       "smc.present" => "FALSE",
-                       "keyboard.vusb.enable" => "TRUE",
-                       "mouse.vusb.enable" => "TRUE",
-               ));
+       if ($image_os_type =~ /osx/i) {
+                 %vmx_parameters = (%vmx_parameters, (
+                 "ide1:0.clientDevice" => "TRUE",
+        "ide1:0.deviceType" => "atapi-cdrom",
+        "ide1:0.fileName" => "",           
+        "ide1:0.present" => "TRUE", 
+        "ide1:0.startConnected" => "FALSE",
+        "usb.present" => "TRUE",                              
+        "usb:1.deviceType" => "hub",      
+        "usb:1.present" => "TRUE",    
+        "usb:2.deviceType" => "mouse",    
+        "usb:2.present" => "TRUE", 
+        "monitor.virtual_exec" => "hardware",
+        "monitor.virtual_mmu" => "software",
+        "ich7m.present" => "TRUE",
+        "smc.present" => "FALSE",
+        "keyboard.vusb.enable" => "TRUE",
+        "mouse.vusb.enable" => "TRUE",
+         ));
        }
 
        # Check if the API implements 'add_ethernet_adapter'

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vbox.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vbox.pm?rev=1404208&r1=1404207&r2=1404208&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vbox.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vbox.pm Wed Oct 31 
15:39:54 2012
@@ -832,6 +832,7 @@ sub node_status {
         my $request_forimaging = 0;
         my $computer_node_name = 0;
         my $identity_keys      = 0;
+                 my $imagerevision_id   = 0;
 
        # Check if subroutine was called as a class method
         if (ref($self) !~ /vbox/i) {
@@ -872,6 +873,8 @@ sub node_status {
                 $image_os_type      = $self->data->get_image_os_type;
                 $request_forimaging = $self->data->get_request_forimaging();
                 $identity_keys      = $self->data->get_management_node_keys;
+                                        $imagerevision_id      = 
$self->data->get_imagerevision_id();
+                                        
         } ## end else [ if (ref($self) !~ /vbox/i)
 
         notify($ERRORS{'DEBUG'}, $log, "identity_keys= $identity_keys");
@@ -933,13 +936,14 @@ sub node_status {
 
                 $status{ssh} = 1;
 
-                $status{currentimage} = _getcurrentimage($vmclient_shortname);
+                                        $status{currentimage} = 
$self->os->get_current_image_info("current_image_name");
+                                        $status{currentimagerevisionid} = 
$self->os->get_current_image_info();
 
-                if ($status{currentimage}) {
-                        chomp($status{currentimage});
-                        if ($status{currentimage} =~ /$requestedimagename/) {
+                if ($status{currentimagerevisionid}) {
+                        chomp($status{currentimagerevisionid});
+                        if ($status{currentimagerevisionid} eq 
$imagerevision_id) {
                                 $status{image_match} = 1;
-                                notify($ERRORS{'OK'}, $log, 
"$vmclient_shortname is loaded with requestedimagename $requestedimagename");
+                                notify($ERRORS{'OK'}, $log, 
"$vmclient_shortname is loaded with requestedimagename 
imagerevision_id=$imagerevision_id $requestedimagename");
                         }
                         else {
                                 notify($ERRORS{'OK'}, $log, 
"$vmclient_shortname reports current image is currentimage= 
$status{currentimage} requestedimagename= $requestedimagename");

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm?rev=1404208&r1=1404207&r2=1404208&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Wed Oct 31 
15:39:54 2012
@@ -2042,6 +2042,7 @@ sub node_status {
        my $image_os_name           = 0;
        my $image_name              = 0;
        my $image_os_type           = 0;
+       my $imagerevision_id                     = 0;
 
 
        # Check if subroutine was called as a class method
@@ -2082,6 +2083,7 @@ sub node_status {
                $computer_short_name = $self->data->get_computer_short_name();
                $image_name          = $self->data->get_image_name();
                $image_os_type       = $self->data->get_image_os_type();
+               $imagerevision_id       = $self->data->get_imagerevision_id();
                $log                 = 0;
        } ## end else [ if (ref($self) !~ /xcat/i)
 
@@ -2190,7 +2192,7 @@ sub node_status {
 
                # Check the currentimage.txt file on the node
                notify($ERRORS{'DEBUG'}, $log, "checking image specified in 
currentimage.txt file on $computer_short_name");
-               my $status_currentimage = 
_getcurrentimage($computer_short_name);
+               my $status_currentimage = 
$self->os->get_current_image_info("current_image_name");
                if ($status_currentimage) {
                        notify($ERRORS{'OK'}, $log, "$computer_short_name 
currentimage.txt has: $status_currentimage");
                        $status{currentimage} = $status_currentimage;
@@ -2201,6 +2203,8 @@ sub node_status {
        } ## end if ($sshd_status =~ /on/)
        else {
                $status{ssh} = 0;
+               $status{status} = 'RELOAD';
+      return \%status;
        }
        notify($ERRORS{'OK'}, $log, "$computer_short_name sshd status: 
$sshd_status ($status{ssh})");
 
@@ -2242,13 +2246,15 @@ sub node_status {
                $status{status} = 'RELOAD';
                notify($ERRORS{'OK'}, $log, "nodetype.tab does not match 
currentimage.txt, node needs to be reloaded");
        }
+       
+       my $vcld_post_load_status = 
$self->data->get_computer_currentimage_vcld_post_load();
 
        # Node is up and doesn't need to be reloaded
        if ($status{status} =~ /ready/i) {
                notify($ERRORS{'OK'}, $log, "node is up and does not need to be 
reloaded");
                
                # Check if the OS post_load tasks have run
-               if ($self->os->get_vcld_post_load_status()) {
+               if ($vcld_post_load_status) {
                        notify($ERRORS{'DEBUG'}, 0, "OS module post_load tasks 
have been completed on $computer_short_name");
                        $status{status} = 'READY';
                }

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT2.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT2.pm?rev=1404208&r1=1404207&r2=1404208&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT2.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT2.pm Wed Oct 31 
15:39:54 2012
@@ -1812,6 +1812,7 @@ sub node_status {
        }
        else {
                $status{rpower} = 0;
+               
        }
        notify($ERRORS{'OK'}, $log, "$computer_short_name rpower status: 
$rpower_status ($status{rpower})");
 
@@ -1832,7 +1833,7 @@ sub node_status {
 
                # Check the currentimage.txt file on the node
                notify($ERRORS{'OK'}, $log, "checking image specified in 
currentimage.txt file on $computer_short_name");
-               my $status_currentimage = 
_getcurrentimage($computer_short_name);
+               my $status_currentimage = 
$self->os->get_current_image_info("current_image_name");
                if ($status_currentimage) {
                        notify($ERRORS{'OK'}, $log, "$computer_short_name 
currentimage.txt has: $status_currentimage");
                        $status{currentimage} = $status_currentimage;
@@ -1843,6 +1844,8 @@ sub node_status {
        } ## end if ($sshd_status =~ /on/)
        else {
                $status{ssh} = 0;
+               $status{status} = 'RELOAD';
+               return \%status;
        }
        notify($ERRORS{'OK'}, $log, "$computer_short_name sshd status: 
$sshd_status ($status{ssh})");
 
@@ -1884,13 +1887,15 @@ sub node_status {
                $status{status} = 'RELOAD';
                notify($ERRORS{'OK'}, $log, "currentimage.txt does not match 
requested image, node needs to be reloaded");
        }
+       
+       my $vcld_post_load_status = 
$self->data->get_computer_currentimage_vcld_post_load();
 
        # Node is up and doesn't need to be reloaded
        if ($status{status} =~ /ready/i) {
                notify($ERRORS{'OK'}, $log, "node is up and does not need to be 
reloaded");
                
                # Check if the OS post_load tasks have run
-               if ($self->os->get_vcld_post_load_status()) {
+               if ($vcld_post_load_status) {
                        notify($ERRORS{'OK'}, 0, "OS module post_load tasks 
have been completed on $computer_short_name");
                        $status{status} = 'READY';
                }

Modified: vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm?rev=1404208&r1=1404207&r2=1404208&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm Wed Oct 31 
15:39:54 2012
@@ -1816,7 +1816,7 @@ sub node_status {
 
                # Check the currentimage.txt file on the node
                notify($ERRORS{'DEBUG'}, $log, "checking image specified in 
currentimage.txt file on $computer_short_name");
-               my $status_currentimage = 
_getcurrentimage($computer_short_name);
+               my $status_currentimage = 
$self->os->get_current_image_info("current_image_name");
                if ($status_currentimage) {
                        notify($ERRORS{'OK'}, $log, "$computer_short_name 
currentimage.txt has: $status_currentimage");
                        $status{currentimage} = $status_currentimage;
@@ -1827,6 +1827,8 @@ sub node_status {
        } ## end if ($sshd_status =~ /on/)
        else {
                $status{ssh} = 0;
+      $status{status} = 'RELOAD';
+      return \%status;
        }
        notify($ERRORS{'OK'}, $log, "$computer_short_name sshd status: 
$sshd_status ($status{ssh})");
 
@@ -1864,13 +1866,15 @@ sub node_status {
                $status{status} = 'RELOAD';
                notify($ERRORS{'OK'}, $log, "nodetype.tab does not match 
requested image, node needs to be reloaded");
        }
+       
+       my $vcld_post_load_status = 
$self->data->get_computer_currentimage_vcld_post_load();
 
        # Node is up and doesn't need to be reloaded
        if ($status{status} =~ /ready/i) {
                notify($ERRORS{'OK'}, $log, "node is up and does not need to be 
reloaded");
                
                # Check if the OS post_load tasks have run
-               if ($self->os->get_vcld_post_load_status()) {
+               if ($vcld_post_load_status) {
                        notify($ERRORS{'DEBUG'}, 0, "OS module post_load tasks 
have been completed on $computer_short_name");
                        $status{status} = 'READY';
                }

Modified: vcl/trunk/managementnode/lib/VCL/reclaim.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/reclaim.pm?rev=1404208&r1=1404207&r2=1404208&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/reclaim.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/reclaim.pm Wed Oct 31 15:39:54 2012
@@ -150,7 +150,7 @@ sub process {
                }
                
                # Reload the computer if unable to retrieve the current image 
name
-               my $os_current_image_name = $self->os->get_current_image_name();
+               my $os_current_image_name = 
$self->os->get_current_image_info("current_image_name");
                if (!$os_current_image_name) {
                        notify($ERRORS{'WARNING'}, 0, "failed to retrieve name 
of image currently loaded on $computer_shortname, computer will be reloaded");
                        $self->insert_reload_and_exit();

Modified: vcl/trunk/managementnode/lib/VCL/utils.pm
URL: 
http://svn.apache.org/viewvc/vcl/trunk/managementnode/lib/VCL/utils.pm?rev=1404208&r1=1404207&r2=1404208&view=diff
==============================================================================
--- vcl/trunk/managementnode/lib/VCL/utils.pm (original)
+++ vcl/trunk/managementnode/lib/VCL/utils.pm Wed Oct 31 15:39:54 2012
@@ -83,7 +83,6 @@ our @ISA = qw(Exporter);
 
 our @EXPORT = qw(
   _checknstartservice
-  _getcurrentimage
   _machine_os
   _pingnode
   _sshd_status
@@ -2265,44 +2264,6 @@ sub setnextimage {
 
 #/////////////////////////////////////////////////////////////////////////////
 
-=head2 _getcurrentimage
-
- Parameters  : $node
- Returns     : retrieve the currentimage from currentimage.txt file on the node
- Description :
-
-=cut
-
-sub _getcurrentimage {
-       my $node = $_[0];
-       my ($package, $filename, $line, $sub) = caller(0);
-       notify($ERRORS{'WARNING'}, 0, "node is not defined") if 
(!(defined($node)));
-       # TODO - loop through the available ssh keys to figure out which one 
works
-       my $identity_keys = get_management_node_info()->{keys};
-       my @sshcmd = run_ssh_command($node, $identity_keys, "cat 
currentimage.txt");
-       foreach my $s (@{$sshcmd[1]}) {
-               if ($s =~ /Warning: /) {
-                       #need to run makesshgkh
-                       #if 
(VCL::Module::Provisioning::xCAT::makesshgkh($node)) {
-                       #success
-                       #not worth output here
-                       #}
-                       #else {
-                       #}
-               }
-               if ($s =~ /^(rh|win|fc|vmware|cent|fe)/) {
-                       chomp($s);
-                       if ($s =~ s/\x0d//) {
-                               notify($ERRORS{'OK'}, 0, "stripped dos newline 
$s");
-                       }
-                       return $s;
-               }
-       } ## end foreach my $s (@{$sshcmd[1]})
-       return 0;
-} ## end sub _getcurrentimage
-
-#/////////////////////////////////////////////////////////////////////////////
-
 =head2 check_ssh
 
  Parameters  : $node, $port, $log


Reply via email to