Author: arkurth
Date: Tue May 10 15:28:24 2011
New Revision: 1101506

URL: http://svn.apache.org/viewvc?rev=1101506&view=rev
Log:
VCL-469
Updated Windows.pm get_public_ip_address to handle a rare condition where a 
valid public IP address as well as an auto-generated IP address are both bound 
to the same interface name.  Under this condition, the auto-generated address 
may have been returned causing problems. Code was updated to return the valid 
address if one is assigned.

Modified:
    incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm

Modified: incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm?rev=1101506&r1=1101505&r2=1101506&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm (original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/OS/Windows.pm Tue May 10 
15:28:24 2011
@@ -5367,7 +5367,21 @@ sub get_public_ip_address {
        my $interface_name = (keys(%{$network_configuration}))[0];
        
        my $ip_address_config = 
$network_configuration->{$interface_name}{ip_address};
-       my $ip_address = (keys(%$ip_address_config))[0];
+       
+       my $ip_address;
+       
+       # If multiple IP addresses were found, loop through them until a public 
IP address was found
+       # If none of the addresses are public, use the first one found
+       for my $ip_address_check (keys(%$ip_address_config)) {
+               if (is_public_ip_address($ip_address_check)) {
+                       $ip_address = $ip_address_check;
+                       last;
+               }
+               elsif (!$ip_address) {
+                       # Only set $ip_address for the first non-public address 
found
+                       $ip_address = $ip_address_check;
+               }
+       }
        
        my $dhcp_enabled = 
$network_configuration->{$interface_name}{dhcp_enabled};
        


Reply via email to