From f0c90622d0c6296778bcc177c54cabaebdbf7e28 Mon Sep 17 00:00:00 2001 From: ligc Date: Wed, 2 Jun 2010 08:01:31 +0000 Subject: [PATCH] ipv6 fix: toIP git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6306 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 0fc07a59d..dca55f905 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -3661,18 +3661,16 @@ sub getSNformattedhash sub toIP { - # does not support IPV6 IPV6TODO - if ($_[0] =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/) + if (($_[0] =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/) || ($_[0] =~ /:/)) { return ([0, $_[0]]); } - $!=undef; - my $packed_ip = gethostbyname($_[0]); - if (!$packed_ip or $!) + my $ip = xCAT::NetworkUtils->getipaddr($_[0]); + if (!$ip) { return ([1, "Cannot Resolve: $_[0]\n"]); } - return ([0, inet_ntoa($packed_ip)]); + return ([0, $ip]); } #-----------------------------------------------------------------------------