diff --git a/perl-xCAT/xCAT/FSPUtils.pm b/perl-xCAT/xCAT/FSPUtils.pm index 397f50fe2..4eb296a61 100644 --- a/perl-xCAT/xCAT/FSPUtils.pm +++ b/perl-xCAT/xCAT/FSPUtils.pm @@ -139,7 +139,7 @@ sub getIPaddress my $type = shift; my $nodetocheck = shift; my $port = shift; - if (xCAT::NetworkUtils::isIpaddr($nodetocheck)) { + if (xCAT::NetworkUtils::isIpv4addr($nodetocheck)) { return $nodetocheck; } my $side = "[A|B]"; @@ -201,7 +201,7 @@ sub getIPaddress if ($tmp_s and $tmp_s =~ /^$side-$port$/i) { $tmp_s =~ s/a/A/; $tmp_s =~ s/b/B/; - if (xCAT::NetworkUtils::isIpaddr($tmp_n)) { + if (xCAT::NetworkUtils::isIpv4addr($tmp_n)) { $node_side_pairs{$tmp_s} = $tmp_n; $children_num++; } else { diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 02b0fe8ea..b007789e2 100644 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -1687,7 +1687,7 @@ sub getNodeIPaddress } # Quick return if pass in an IP - return $nodetocheck if (xCAT::NetworkUtils->isIpaddr($nodetocheck)); + return $nodetocheck if (xCAT::NetworkUtils->isIpv4addr($nodetocheck)); my $nodeip = xCAT::NetworkUtils->getipaddr($nodetocheck); if (!$nodeip) @@ -2132,7 +2132,7 @@ sub validate_ip #------------------------------------------------------------------------------- -=head3 isIpaddr +=head3 isIpv4addr returns 1 if parameter is has a valid IP address form. @@ -2154,7 +2154,7 @@ sub validate_ip =cut #------------------------------------------------------------------------------- -sub isIpaddr +sub isIpv4addr { my $addr = shift; if (($addr) && ($addr =~ /xCAT::NetworkUtils/)) @@ -2183,6 +2183,20 @@ sub isIpaddr } } +#------------------------------------------------------------------------------- + +=head3 isIpaddr + + Deprecated alias for isIpv4addr, kept for external callers. + +=cut + +#------------------------------------------------------------------------------- +sub isIpaddr +{ + return isIpv4addr(@_); +} + diff --git a/perl-xCAT/xCAT/PPCconn.pm b/perl-xCAT/xCAT/PPCconn.pm index 84c3dad9c..47d396e1e 100644 --- a/perl-xCAT/xCAT/PPCconn.pm +++ b/perl-xCAT/xCAT/PPCconn.pm @@ -520,7 +520,7 @@ sub mkhwconn for my $nn (@newnodes) { my $node_ip; - unless (xCAT::NetworkUtils->isIpaddr($nn)) { + unless (xCAT::NetworkUtils->isIpv4addr($nn)) { $node_ip = xCAT::NetworkUtils::getNodeIPaddress($nn); } else { $node_ip = $nn; diff --git a/perl-xCAT/xCAT/PPCdb.pm b/perl-xCAT/xCAT/PPCdb.pm index 51967544d..ff8226a55 100644 --- a/perl-xCAT/xCAT/PPCdb.pm +++ b/perl-xCAT/xCAT/PPCdb.pm @@ -1106,7 +1106,7 @@ sub get_host { } if ($tmpmtm eq $mtm and $tmpsn eq $sn) { - my $ifip = xCAT::NetworkUtils->isIpaddr($oldnode); + my $ifip = xCAT::NetworkUtils->isIpv4addr($oldnode); if ($ifip) { # which means that the node is defined by the new lsslp if ($tmpside eq $side) { # match! which means that node is the same as the new one if ($ip eq $tmpip) { #which means that the ip is not changed @@ -1230,7 +1230,7 @@ sub get_host { } # not matched, use the new name - my $ifip = xCAT::NetworkUtils->isIpaddr($nodename); + my $ifip = xCAT::NetworkUtils->isIpv4addr($nodename); unless ($ifip) { return $nodename; } else { @@ -1338,7 +1338,7 @@ sub read_from_table { @{ $::OLD_DATA_CACHE{ $entry->{node} } }[1] = @{ $vpdhash{ $entry->{node} } }[1]; #sn @{ $::OLD_DATA_CACHE{ $entry->{node} } }[2] = @{ $vpdhash{ $entry->{node} } }[2]; #side # find node ip address, check node name first, then check hosts table - my $ifip = xCAT::NetworkUtils->isIpaddr($entry->{node}); + my $ifip = xCAT::NetworkUtils->isIpv4addr($entry->{node}); if ($ifip) { @{ $::OLD_DATA_CACHE{ $entry->{node} } }[3] = $entry->{node}; #ip diff --git a/xCAT-probe/lib/perl/LogParse.pm b/xCAT-probe/lib/perl/LogParse.pm index c2a9f6273..ba0b350b6 100644 --- a/xCAT-probe/lib/perl/LogParse.pm +++ b/xCAT-probe/lib/perl/LogParse.pm @@ -487,7 +487,7 @@ sub obtain_log_content { if ($split_line[0] =~ /(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+)(.+)-(.+)/) { $log_content{time_record} = "$4:$5:$6"; $log_content{time} = $self->convert_to_epoch_seconds($split_line[0]); - if (!xCAT::NetworkUtils->isIpaddr($split_line[1])) { + if (!xCAT::NetworkUtils->isIpv4addr($split_line[1])) { my @sender_tmp = split(/\./, $split_line[1]); $log_content{sender} = $sender_tmp[0]; } else { @@ -515,7 +515,7 @@ sub obtain_log_content { my $timestamp = join(" ", @split_line[ 0 .. 2 ]); $log_content{time_record} = $split_line[2]; $log_content{time} = $self->convert_to_epoch_seconds($timestamp); - if (!xCAT::NetworkUtils->isIpaddr($split_line[3])) { + if (!xCAT::NetworkUtils->isIpv4addr($split_line[3])) { my @sender_tmp = split(/\./, $split_line[3]); $log_content{sender} = $sender_tmp[0]; } else { @@ -546,7 +546,7 @@ sub obtain_log_content { $log_content{time_record} = "$4:$5:$6"; } $log_content{time} = $self->convert_to_epoch_seconds($split_line[3]); - if (!xCAT::NetworkUtils->isIpaddr($split_line[0])) { + if (!xCAT::NetworkUtils->isIpv4addr($split_line[0])) { my @sender_tmp = split(/\./, $split_line[0]); $log_content{sender} = $sender_tmp[0]; } else { diff --git a/xCAT-probe/subcmds/discovery b/xCAT-probe/subcmds/discovery index b8a82df6c..f352c18f2 100755 --- a/xCAT-probe/subcmds/discovery +++ b/xCAT-probe/subcmds/discovery @@ -478,7 +478,7 @@ sub do_pre_check { exit 1; } - if (!xCAT::NetworkUtils->isIpaddr("$masteripinsite")) { + if (!xCAT::NetworkUtils->isIpv4addr("$masteripinsite")) { probe_utils->send_msg("stdout", "f", $msg); probe_utils->send_msg("stdout", "d", "The value of 'master' in 'site' table isn't an IP address"); exit 1; diff --git a/xCAT-probe/subcmds/xcatmn b/xCAT-probe/subcmds/xcatmn index a52209fe1..8b5e1b950 100755 --- a/xCAT-probe/subcmds/xcatmn +++ b/xCAT-probe/subcmds/xcatmn @@ -401,7 +401,7 @@ sub check_site_table { $rst = 1; } } else { - if (($attr eq "master") and (!xCAT::NetworkUtils->isIpaddr("$value"))) { + if (($attr eq "master") and (!xCAT::NetworkUtils->isIpv4addr("$value"))) { my $masterip = xCAT::NetworkUtils->getipaddr("$value"); if (! defined $masterip){ push @$error_ref, "The value of 'master' in 'site' table isn't an IP address and can not be resolved to a IP address"; @@ -571,7 +571,7 @@ sub check_directory { my $mountip; if ($mountoutput =~ /(.+):$sitetable_ref->{$dir} on $sitetable_ref->{$dir} /) { my $mountsource = $1; - if (xCAT::NetworkUtils->isIpaddr($mountsource)) { + if (xCAT::NetworkUtils->isIpv4addr($mountsource)) { $mountip = $mountsource; } else { $mountip = xCAT::NetworkUtils->getipaddr($mountsource); diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 6c154768a..c0bfdc2a9 100644 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -4932,7 +4932,7 @@ sub isobjnamevalid{ $objtype="node" unless(defined $objtype and ($objtype ne "")); if($objtype eq "node"){ #the ip address as a valid node object name is a hack for p7IH support - if(($objname !~ /^[a-zA-Z0-9-_]+$/) and !xCAT::NetworkUtils->isIpaddr($objname)){ + if(($objname !~ /^[a-zA-Z0-9-_]+$/) and !xCAT::NetworkUtils->isIpv4addr($objname)){ return 0; } } elsif ($objtype eq "group"){ diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index c6afb2adb..03115a2a3 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -2424,7 +2424,7 @@ sub process_request foreach my $node (@{ $req->{node} }) { #need to change the way of finding IP for nodes - my $ifip = xCAT::NetworkUtils->isIpaddr($node); + my $ifip = xCAT::NetworkUtils->isIpv4addr($node); if ($ifip) { $ip_hash->{$node} = $node; diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index 596b73ac0..8ed4c68c8 100644 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -297,7 +297,7 @@ sub addotherinterfaces } else { ($itf, $ip) = split(/:/, $_); } - if ($ip && xCAT::NetworkUtils->isIpaddr($ip)) + if ($ip && xCAT::NetworkUtils->isIpv4addr($ip)) { if ($itf =~ /^-/) { @@ -330,7 +330,7 @@ sub delotherinterfaces } else { ($itf, $ip) = split(/:/, $_); } - if ($ip && xCAT::NetworkUtils->isIpaddr($ip)) + if ($ip && xCAT::NetworkUtils->isIpv4addr($ip)) { if ($itf =~ /^-/) { @@ -393,7 +393,7 @@ sub add_hosts_content { } else { - if (xCAT::NetworkUtils->isIpaddr($ip)) + if (xCAT::NetworkUtils->isIpv4addr($ip)) { addnode $callback, $nodename, $ip, $ref->{hostnames}, $domain; } @@ -632,7 +632,7 @@ sub process_request $domain = $::XCATSITEVALS{domain}; } - if (xCAT::NetworkUtils->isIpaddr($_->{ip})) + if (xCAT::NetworkUtils->isIpv4addr($_->{ip})) { addnode $callback, $_->{node}, $_->{ip}, $_->{hostnames}, $domain; } diff --git a/xCAT-server/lib/xcat/plugins/openbmc.pm b/xCAT-server/lib/xcat/plugins/openbmc.pm index f02436a79..0dc450910 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc.pm @@ -1359,7 +1359,7 @@ sub rspconfig_parse_address_port { return (undef, undef, "Invalid parameter: $value"); } - return (undef, undef, "Invalid parameter: $address") if (!xCAT::NetworkUtils->isIpaddr($address)); + return (undef, undef, "Invalid parameter: $address") if (!xCAT::NetworkUtils->isIpv4addr($address)); return (undef, undef, "Invalid parameter: $port") if (!rspconfig_valid_port($port) or $port == 0); return ($address, $port, undef); } @@ -1678,12 +1678,12 @@ sub parse_args { my $nodes_num = @$noderange; return ([ 1, "Invalid parameter for option $key" ]) if (!$value and $key ne ("ntpservers")); - return ([ 1, "Invalid parameter for option $key: $value" ]) if (($key eq "netmask") and !xCAT::NetworkUtils->isIpaddr($value)); - return ([ 1, "Invalid parameter for option $key: $value" ]) if (($key eq "gateway") and ($value !~ "0.0.0.0" and !xCAT::NetworkUtils->isIpaddr($value))); + return ([ 1, "Invalid parameter for option $key: $value" ]) if (($key eq "netmask") and !xCAT::NetworkUtils->isIpv4addr($value)); + return ([ 1, "Invalid parameter for option $key: $value" ]) if (($key eq "gateway") and ($value !~ "0.0.0.0" and !xCAT::NetworkUtils->isIpv4addr($value))); if ($key eq "ip") { return ([ 1, "Can not configure more than 1 nodes' ip at the same time" ]) if ($nodes_num >= 2 and $value ne "dhcp"); if ($value ne "dhcp" ) { - if (!xCAT::NetworkUtils->isIpaddr($value)) { + if (!xCAT::NetworkUtils->isIpv4addr($value)) { return ([ 1, "Invalid parameter for option $key: $value" ]); } else { $all_subcommand .= $key . ","; diff --git a/xCAT-server/lib/xcat/plugins/openbmc2.pm b/xCAT-server/lib/xcat/plugins/openbmc2.pm index 6bf4f8e28..0b1ff6183 100644 --- a/xCAT-server/lib/xcat/plugins/openbmc2.pm +++ b/xCAT-server/lib/xcat/plugins/openbmc2.pm @@ -324,12 +324,12 @@ sub parse_args { return([1, "Invalid parameter for option $key: $value"]); } } elsif ($key eq "netmask") { - if (!xCAT::NetworkUtils->isIpaddr($value)) { + if (!xCAT::NetworkUtils->isIpv4addr($value)) { return ([ 1, "Invalid parameter for option $key: $value" ]); } $set_net_info{"netmask"} = 1; } elsif ($key eq "gateway") { - if ($value ne "0.0.0.0" and !xCAT::NetworkUtils->isIpaddr($value)) { + if ($value ne "0.0.0.0" and !xCAT::NetworkUtils->isIpv4addr($value)) { return ([ 1, "Invalid parameter for option $key: $value" ]); } $set_net_info{"gateway"} = 1; @@ -339,7 +339,7 @@ sub parse_args { if ($value ne "dhcp") { if (@$noderange > 1) { return ([ 1, "Can not configure more than 1 nodes' ip at the same time" ]); - } elsif (!xCAT::NetworkUtils->isIpaddr($value)) { + } elsif (!xCAT::NetworkUtils->isIpv4addr($value)) { return ([ 1, "Invalid parameter for option $key: $value" ]); } $set_net_info{"ip"} = 1;