Added toIP() function - Line #2054
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@968 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
a78132c113
commit
6e8b437328
@ -2049,4 +2049,20 @@ sub get_ServiceNode
|
||||
|
||||
}
|
||||
|
||||
|
||||
# IPv4 function to convert hostname to IP address
|
||||
sub toIP {
|
||||
|
||||
if ($_[0] =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/) {
|
||||
return([0,$_[0]]);
|
||||
}
|
||||
my $packed_ip = gethostbyname($_[0]);
|
||||
if( !$packed_ip or $! ) {
|
||||
return([1,"Cannot Resolve: $_[0]\n"]);
|
||||
}
|
||||
return([0,inet_ntoa($packed_ip)]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user