diff --git a/perl-xCAT/xCAT/InstUtils.pm b/perl-xCAT/xCAT/InstUtils.pm index abb2b8273..ed2148727 100644 --- a/perl-xCAT/xCAT/InstUtils.pm +++ b/perl-xCAT/xCAT/InstUtils.pm @@ -643,7 +643,7 @@ sub get_server_nodes else { # get ip facing node - $serv = xCAT::Utils->getFacingIP($node); + $serv = xCAT::Utils->my_ip_facing($node); } chomp $serv; diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index 80b158185..d20824ed7 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -142,7 +142,7 @@ sub makescript { $value = $et->{'xcatmaster'}; } else { my $sitemaster_value = $value; - $value=xCAT::Utils->getFacingIP($node); + $value=xCAT::Utils->my_ip_facing($node); if ($value eq "0") { $value = $sitemaster_value; } diff --git a/xCAT-server/lib/xcat/plugins/yaboot.pm b/xCAT-server/lib/xcat/plugins/yaboot.pm index 917f90a97..91a6331fd 100644 --- a/xCAT-server/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server/lib/xcat/plugins/yaboot.pm @@ -3,6 +3,7 @@ package xCAT_plugin::yaboot; use Data::Dumper; use Sys::Syslog; use xCAT::Scope; +use xCAT::NetworkUtils; use File::Path; use Socket; use Getopt::Long; @@ -125,7 +126,7 @@ sub setstate { print $pcfg "\tappend=\"".$kern->{kcmdline}."\"\n"; } close($pcfg); - my $inetn = inet_aton($node); + my $inetn = xCAT::NetworkUtils->getipaddr($node); unless ($inetn) { syslog("local1|err","xCAT unable to resolve IP for $node in yaboot plugin"); return; @@ -134,7 +135,7 @@ sub setstate { print $pcfg "bye\n"; close($pcfg); } - my $ip = inet_ntoa(inet_aton($node));; + my $ip = xCAT::NetworkUtils->getipaddr($node); unless ($ip) { syslog("local1|err","xCAT unable to resolve IP in yaboot plugin"); return; @@ -148,8 +149,9 @@ sub setstate { my @macs = split(/\|/,$ment->{mac}); foreach (@macs) { if (/!(.*)/) { - if (inet_aton($1)) { - $ipaddrs{inet_ntoa(inet_aton($1))} = 1; + my $ipaddr = xCAT::NetworkUtils->getipaddr($1); + if ($ipaddr) { + $ipaddrs{$ipaddr} = 1; } } } diff --git a/xCAT-server/sbin/xcat_traphandler b/xCAT-server/sbin/xcat_traphandler index d38b800f1..116360d4f 100755 --- a/xCAT-server/sbin/xcat_traphandler +++ b/xCAT-server/sbin/xcat_traphandler @@ -8,6 +8,7 @@ use lib "$::XCATROOT/lib/perl"; use Sys::Syslog; use xCAT::Table; use xCAT::Utils; +use xCAT::NetworkUtils; use xCAT_plugin::ipmi; use xCAT_monitoring::monitorctrl; use Socket; @@ -182,8 +183,7 @@ while ($temp=) { # get the host name if it is unknown if ($node1 =~//) { - my $iaddr = inet_aton($ip1); - my ($name) = gethostbyaddr($iaddr, AF_INET); + my $name = xCAT::NetworkUtils->gethostname($iaddr); if ($name) { $node1=$name; $host=$name; diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index 6a9192c96..4e4d1a589 100644 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -23,6 +23,7 @@ BEGIN use lib "$::XCATROOT/lib/perl"; use strict; use xCAT::Utils; +use xCAT::NetworkUtils; use Getopt::Long; use xCAT::MsgUtils; use Socket; @@ -826,32 +827,11 @@ sub initDB my $tftpdir = "$::TFTPDIR"; my $installdir = "$::INSTALLDIR"; my $master; - my ($name, $aliases, $addrtype, $length, @addrs) = gethostbyname($hname); - if ($? == 0) - { - my $len= scalar(@addrs); - if ($len > 0 ) { # we got some ip addresses - for (my $i = 0 ; $i < $len ; $i++){ - my @ipaddr=inet_ntoa($addrs[$i]); - if (!grep(/127.0.0/, @ipaddr)) { - $master = inet_ntoa($addrs[$i]); - last; - } - } - if (!defined($master)) { - xCAT::MsgUtils->message("E", "Hostname resolution for $hname failed."); - $master = "NORESOLUTION"; - } - } else { - xCAT::MsgUtils->message("E", "Hostname resolution for $hname failed."); - $master = "NORESOLUTION"; - } - } - else - { + $master = xCAT::NetworkUtils->getipaddr($hname); + if (!$master) { xCAT::MsgUtils->message("E", "Hostname resolution for $hname failed."); $master = "NORESOLUTION"; - } + } # for policy table # get hostname from the /etc/xcat/cert/server-cert.pem my $MNname;