From d4e7353aced9b57a0be09caf188b36b9f90ce9c2 Mon Sep 17 00:00:00 2001 From: jjhua Date: Tue, 9 Mar 2010 06:42:23 +0000 Subject: [PATCH] fsp-api should 1st try to resolve nodenames to IP addresses using the system's name resolution (i.e. /etc/hosts or DNS) and if that fails, then try the xcat hosts table git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5416 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Utils.pm | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/perl-xCAT/xCAT/Utils.pm b/perl-xCAT/xCAT/Utils.pm index 37e3a0c3e..97ce5744f 100644 --- a/perl-xCAT/xCAT/Utils.pm +++ b/perl-xCAT/xCAT/Utils.pm @@ -5281,17 +5281,20 @@ sub get_hdwr_ip my $node = shift; my $ip = undef; my $Rc = undef; - my $hosttab = xCAT::Table->new( 'hosts' ); - if ( $hosttab) { - my $node_ip_hash = $hosttab->getNodeAttribs( $node,[qw(ip)]); - $ip = $node_ip_hash->{ip}; + + my $ip_tmp_res = xCAT::Utils::toIP($node); + ($Rc, $ip) = @$ip_tmp_res; + if ( $Rc ) { + my $hosttab = xCAT::Table->new( 'hosts' ); + if ( $hosttab) { + my $node_ip_hash = $hosttab->getNodeAttribs( $node,[qw(ip)]); + $ip = $node_ip_hash->{ip}; + } + } + if (!$ip) { - my $ip_tmp_res = xCAT::Utils::toIP($node); - ($Rc, $ip) = @$ip_tmp_res; - if ( $Rc ) { - return -1; - } + return undef; } return $ip; @@ -5503,7 +5506,7 @@ sub fsp_api_action { my %myhash = xCAT::DBobjUtils->getobjdefs(\%objhash); # my $password = $myhash{$fsp_name}{"passwd.hscroot"}; my $password = $myhash{$fsp_name}{"passwd.HMC"}; - print "fspname:$fsp_name password:$password\n"; + #print "fspname:$fsp_name password:$password\n"; if(!$password ) { $res = "The password.hscroot of $fsp_name in ppcdirect table is empty"; return ([$node_name, $res, -1]); @@ -5523,11 +5526,20 @@ sub fsp_api_action { ############################ # Get IP address ############################ - $fsp_ip = xCAT::Utils::get_hdwr_ip($fsp_name); - if($fsp_ip == -1) { + #$fsp_ip = xCAT::Utils::get_hdwr_ip($fsp_name); + #if($fsp_ip == 0) { + # $res = "Failed to get the $fsp_name\'s ip"; + # return ([$node_name, $res, -1]); + #} + $fsp_ip = getNodeIPaddress( $fsp_name ); + if(!defined($fsp_ip)) { $res = "Failed to get the $fsp_name\'s ip"; return ([$node_name, $res, -1]); } + unless ($fsp_ip =~ /\d+\.\d+\.\d+\.\d+/) { + $res = "Not supporting IPv6 here"; #Not supporting IPv6 here IPV6TODO + return ([$node_name, $res, -1]); + } print "fsp name: $fsp_name\n"; print "fsp ip: $fsp_ip\n";