1. resolve #3283: a typo issue. 2. drop uselessness method isReservedIP. 3. do not validate IP address whlie creating an unmanaged device. 4. Correct some messages
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14887 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -2155,26 +2155,6 @@ sub pingNodeStatus { | ||||
|  | ||||
| #------------------------------------------------------------------------------- | ||||
|  | ||||
| =head3  isReservedIP | ||||
|       Description : Validate whether specified string is a reseved IPv4 string. | ||||
|       Arguments   : ipstr - the string to be validated. | ||||
|       Returns     : 1 - valid reserved String. | ||||
|                     0 - invalid reserved String. | ||||
| =cut | ||||
|  | ||||
| #------------------------------------------------------------------------------- | ||||
| sub isReservedIP | ||||
| { | ||||
|     my ($class, $ipstr) = @_; | ||||
|     my @ipnums = split('\.', $ipstr); | ||||
|     if ($ipnums[3] eq "0" || $ipnums[3] eq "255"){ | ||||
|         return 1; | ||||
|     } | ||||
|     return 0; | ||||
| } | ||||
|  | ||||
| #------------------------------------------------------------------------------- | ||||
|  | ||||
| =head3 isValidMAC | ||||
|       Description : Validate whether specified string is a MAC string. | ||||
|       Arguments   : macstr - the string to be validated. | ||||
| @@ -2274,12 +2254,11 @@ sub int_to_ip | ||||
|       Arguments   : $startip - start IP address | ||||
|                     $endip - end IP address | ||||
|                     $increment - increment factor | ||||
|                     $reservflag - A flag for whether we exclude reserved ips or not | ||||
|       Returns     : IP list in this range. | ||||
|       Example     : | ||||
|                     my $startip = "192.168.0.1"; | ||||
|                     my $endip = "192.168.0.100"; | ||||
|                     xCAT::NetworkUtils->get_allips_in_range($startip, $endip, 1, 1); | ||||
|                     xCAT::NetworkUtils->get_allips_in_range($startip, $endip, 1); | ||||
| =cut | ||||
|  | ||||
| #------------------------------------------------------------------------------- | ||||
| @@ -2289,7 +2268,6 @@ sub get_allips_in_range | ||||
|     my $startip = shift; | ||||
|     my $endip = shift; | ||||
|     my $increment = shift; | ||||
|     my $reservflag = shift; | ||||
|     my @iplist; | ||||
|  | ||||
|     my $startipnum = xCAT::NetworkUtils->ip_to_int($startip); | ||||
| @@ -2297,12 +2275,6 @@ sub get_allips_in_range | ||||
|     while ($startipnum <= $endipnum){ | ||||
|         my $ip = xCAT::NetworkUtils->int_to_ip($startipnum); | ||||
|         $startipnum += $increment; | ||||
|         # Not return reserved IPs | ||||
|         if ($reservflag){ | ||||
|             if(xCAT::NetworkUtils->isReservedIP($ip)){ | ||||
|                 next; | ||||
|             } | ||||
|         } | ||||
|         push (@iplist, $ip); | ||||
|     } | ||||
|     return \@iplist; | ||||
|   | ||||
| @@ -634,20 +634,17 @@ Usage: | ||||
|     }elsif((xCAT::NetworkUtils->validate_ip($args_dict{'ip'}))[0]->[0] ){ | ||||
|         setrsp_errormsg("The specified IP address $args_dict{'ip'} is invalid. You must use a valid IP address."); | ||||
|         return; | ||||
|     }elsif(xCAT::NetworkUtils->isReservedIP($args_dict{'ip'})){ | ||||
|         setrsp_errormsg("The specified IP address $args_dict{'ip'} is invalid. You must use a valid IP address."); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     # validate hostname. | ||||
|     $recordsref = xCAT::ProfiledNodeUtils->get_allnode_singleattrib_hash('nodelist', 'node'); | ||||
|     %allhostnames = %$recordsref; | ||||
|     if (exists $allhostnames{$args_dict{'hostname'}}){ | ||||
|         setrsp_errormsg("The specified node name $args_dict{'hostname'} already exists. You must use a different node name."); | ||||
|         setrsp_errormsg("The specified device name $args_dict{'hostname'} already exists. You must use a different device name."); | ||||
|         return; | ||||
|     } | ||||
|     if (! xCAT::NetworkUtils->isValidFQDN($args_dict{'hostname'})){ | ||||
|         setrsp_errormsg("The specified node name $args_dict{'hostname'} is invalid. You must use a valid node name."); | ||||
|         setrsp_errormsg("The specified device name $args_dict{'hostname'} is invalid. You must use a valid device name."); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
| @@ -1297,7 +1294,7 @@ sub gen_new_hostinfo_string{ | ||||
|             } | ||||
|         } | ||||
|   | ||||
|         my $!icips = $installnic."!".$hostinfo_dict{$item}{"ip"}; | ||||
|         my $nicips = $installnic."!".$hostinfo_dict{$item}{"ip"}; | ||||
|         foreach(keys %ipshash){ | ||||
|             if ( $_ eq $installnic ) {next;} | ||||
|             $nicips = "$_!$ipshash{$_},$nicips"; | ||||
| @@ -1575,8 +1572,6 @@ sub validate_node_entry{ | ||||
|                 $errmsg .= "IP address $node_entry{$_} already exists in the database or in the nodeinfo file.\n"; | ||||
|             }elsif((xCAT::NetworkUtils->validate_ip($node_entry{$_}))[0]->[0] ){ | ||||
|                 $errmsg .= "IP address $node_entry{$_} is invalid. You must use a valid IP address.\n"; | ||||
|             }elsif(xCAT::NetworkUtils->isReservedIP($node_entry{$_})){ | ||||
|                 $errmsg .= "IP address $node_entry{$_} is invalid. You must use a valid IP address.\n"; | ||||
|             }else { | ||||
|                 #push the IP into allips list. | ||||
|                 $allips{$node_entry{$_}} = 0; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user