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
This commit is contained in:
jjhua 2010-03-09 06:42:23 +00:00
parent 5a2aa5a53a
commit d4e7353ace

View File

@ -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";