Author: arkurth
Date: Tue Jun 16 17:15:49 2009
New Revision: 785304

URL: http://svn.apache.org/viewvc?rev=785304&view=rev
Log:
VCL-158
Added multiple netsh attempts to Windows_mod.pm::set_static_public_address(). 
The netsh command occasionally fails but can be successfully run on subsequent 
attempts.

VCL-153
xCAT21.pm::get_image_size() was failing because of the way the output was being 
parsed. I updated how  xCAT.pm::get_image_size() parses the du command output. 
This subroutine also works for xCAT 2.1 so the xCAT21.pm::get_image_size() was 
removed.

Modified:
    incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm
    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/OS/Windows_mod.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm?rev=785304&r1=785303&r2=785304&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm 
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows_mod.pm Tue Jun 
16 17:15:49 2009
@@ -7159,32 +7159,45 @@
        
        notify($ERRORS{'DEBUG'}, 0, "network configuration:\ninterface: 
$public_interface_name\npublic IP address: $public_ip_address\nsubnet 
mask=$subnet_mask\ndefault gateway=$default_gateway\ndns server=$dns_server");
        
-       # Assemble the commands
-       my $address_command      = "netsh interface ip set address 
name=\"$public_interface_name\" source=static addr=$public_ip_address 
mask=$subnet_mask gateway=$default_gateway gwmetric=0";
-       my $dns_command          = "netsh interface ip set dns 
name=\"$public_interface_name\" source=static addr=$dns_server register=none";
-       
        # Set the static public IP address
-       my ($address_exit_status, $address_output) = 
run_ssh_command($computer_node_name, $management_node_keys, $address_command);
-       if (defined($address_exit_status) && $address_exit_status == 0) {
-               notify($ERRORS{'DEBUG'}, 0, "set static public IP address to 
$public_ip_address");
-       }
-       elsif (defined($address_exit_status)) {
-               notify($ERRORS{'WARNING'}, 0, "failed to set static public IP 
address to $public_ip_address, exit status: $address_exit_status, 
output:\...@{$address_output}");
-               return;
-       }
-       else {
-               notify($ERRORS{'WARNING'}, 0, "failed to run ssh command to set 
static public IP address to $public_ip_address");
-               return;
+       my $address_command = "netsh interface ip set address 
name=\"$public_interface_name\" source=static addr=$public_ip_address 
mask=$subnet_mask gateway=$default_gateway gwmetric=0";
+       
+       # Set number of attempts to try netsh commands
+       my $max_attempts = 3;
+       my $address_attempts = 0;
+       while ($address_attempts < $max_attempts) {
+               $address_attempts++;
+               my ($address_exit_status, $address_output) = 
run_ssh_command($computer_node_name, $management_node_keys, $address_command);
+               if (defined($address_exit_status) && $address_exit_status == 0) 
{
+                       notify($ERRORS{'DEBUG'}, 0, "set static public IP 
address to $public_ip_address");
+                       last;
+               }
+               elsif (defined($address_exit_status)) {
+                       notify($ERRORS{'WARNING'}, 0, "attempt 
$address_attempts/$max_attempts: failed to set static public IP address to 
$public_ip_address, exit status: $address_exit_status, 
output:\...@{$address_output}");
+               }
+               else {
+                       notify($ERRORS{'WARNING'}, 0, "attempt 
$address_attempts/$max_attempts: failed to run ssh command to set static public 
IP address to $public_ip_address");
+                       return;
+               }
+               
+               # Check if max attempts has been reached.
+               if ($address_attempts >= $max_attempts) {
+                       notify($ERRORS{'WARNING'}, 0, "failed to set static 
public IP address after making $address_attempts attempts");
+                       return 0;
+               }
+               
+               sleep 2;
        }
        
        # Set the static DNS server address
+       my $dns_command = "netsh interface ip set dns 
name=\"$public_interface_name\" source=static addr=$dns_server register=none";
        my ($dns_exit_status, $dns_output) = 
run_ssh_command($computer_node_name, $management_node_keys, $dns_command);
        if (defined($dns_exit_status) && $dns_exit_status == 0) {
                notify($ERRORS{'DEBUG'}, 0, "set static DNS server address to 
$dns_server");
        }
        elsif (defined($dns_exit_status)) {
                notify($ERRORS{'WARNING'}, 0, "failed to set static DNS server 
address to $dns_server, exit status: $dns_exit_status, 
output:\...@{$dns_output}");
-               return;
+               return 0;
        }
        else {
                notify($ERRORS{'WARNING'}, 0, "failed to run ssh command to set 
static DNS server address to $dns_server");

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=785304&r1=785303&r2=785304&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm 
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT.pm Tue 
Jun 16 17:15:49 2009
@@ -3173,37 +3173,30 @@
        }
 
        # Execute the command
-       my $du_command = "du -c $image_repository_path/$image_name* 2>&1";
+       my $du_command = "du -c $image_repository_path/$image_name.* 2>&1";
        notify($ERRORS{'DEBUG'}, 0, "du command: $du_command");
        my $du_output = `$du_command`;
 
        # Save the exit status
        my $du_exit_status = $? >> 8;
-
-       # Check if $? = -1, this likely means a Perl CHLD signal bug was 
encountered
-       if ($? == -1) {
-               notify($ERRORS{'OK'}, 0, "\$? is set to $?, setting exit status 
to 0, Perl bug likely encountered");
-               $du_exit_status = 0;
-       }
-
-       # Check the du command output
-       if ($du_exit_status > 0) {
-               notify($ERRORS{'WARNING'}, 0, "du exit status > 0: 
$du_exit_status, output:\n$du_output");
-               return 0;
+       
+       # Make sure du produced output
+       if (!defined($du_output) || length($du_output) == 0) {
+               notify($ERRORS{'WARNING'}, 0, "du did not product any output, 
du exit status: $du_exit_status");
+               return;
        }
-       elsif ($du_output !~ /total/s) {
-               notify($ERRORS{'WARNING'}, 0, "du command did not produce 
expected output, du exit staus: $du_exit_status, output:\n$du_output");
-               return 0;
+       
+       # 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;
        }
-
-       # Find the du output line containing 'total'
-       $du_output =~ /(\d+)\s+total/s;
-       my $size_bytes = $1;
-
+       
        # Check the du command output
-       if (!$size_bytes) {
-               notify($ERRORS{'WARNING'}, 0, "du produced unexpected output: 
$du_exit_status, output:\n$du_output");
-               return 0;
+       my ($size_bytes) = $du_output =~ /(\d+)\s+total/s;
+       if (!defined $size_bytes) {
+               notify($ERRORS{'WARNING'}, 0, "du command did not produce 
expected output, du exit staus: $du_exit_status, output:\n$du_output");
+               return;
        }
 
        # Calculate the size in MB

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=785304&r1=785303&r2=785304&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm 
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/xCAT21.pm 
Tue Jun 16 17:15:49 2009
@@ -2771,80 +2771,6 @@
 
 #/////////////////////////////////////////////////////////////////////////////
 
-=head2  get_image_size
-
- Parameters  : $image_name (optional)
- Returns     : 0 failure or size of image
- Description : in size of Kilobytes
-
-=cut
-
-sub get_image_size {
-       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;
-       }
-
-       # Either use a passed parameter as the image name or use the one stored 
in this object's DataStructure
-       my $image_name = shift;
-       $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;
-       }
-       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;
-       }
-
-       # Execute the command
-       # TODO add gzip support
-       my $du_command = "du -c $image_repository_path/$image_name*.img 
$image_repository_path/$image_name*.gz* 2>&1";
-       notify($ERRORS{'DEBUG'}, 0, "du command: $du_command");
-       my $du_output = `$du_command`;
-
-       # Save the exit status
-       my $du_exit_status = $? >> 8;
-
-       # Check if $? = -1, this likely means a Perl CHLD signal bug was 
encountered
-       if ($? == -1) {
-               notify($ERRORS{'OK'}, 0, "\$? is set to $?, setting exit status 
to 0, Perl bug likely encountered");
-               $du_exit_status = 0;
-       }
-
-       # Check the du command output
-       if ($du_exit_status > 0) {
-               notify($ERRORS{'WARNING'}, 0, "du exit status > 0: 
$du_exit_status, output:\n$du_output");
-               return 0;
-       }
-       elsif ($du_output !~ /total/s) {
-               notify($ERRORS{'WARNING'}, 0, "du command did not produce 
expected output, du exit staus: $du_exit_status, output:\n$du_output");
-               return 0;
-       }
-
-       # Find the du output line containing 'total'
-       $du_output =~ /(\d+)\s+total/s;
-       my $size_bytes = $1;
-
-       # Check the du command output
-       if (!$size_bytes) {
-               notify($ERRORS{'WARNING'}, 0, "du produced unexpected output: 
$du_exit_status, output:\n$du_output");
-               return 0;
-       }
-
-       # Calculate the size in MB
-       my $size_mb = int($size_bytes / 1024);
-       notify($ERRORS{'DEBUG'}, 0, "returning image size: $size_mb MB 
($size_bytes bytes)");
-       return $size_mb;
-
-} ## end sub get_image_size
-
-#/////////////////////////////////////////////////////////////////////////////
-
 =head2 _get_image_repository_path
 
  Parameters  : none, must be called as an xCAT object method


Reply via email to