mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-08-17 08:40:24 +00:00
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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user