ipv6 support
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5988 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -1813,7 +1813,6 @@ sub getGroupMembers | ||||
|                 %nethash = xCAT::DBobjUtils->getNetwkInfo(\@targetnodes); | ||||
|  | ||||
| 		Comments: | ||||
| 			      Not supporting IPv6 yet | ||||
|  | ||||
| =cut | ||||
|  | ||||
| @@ -1845,11 +1844,11 @@ sub getNetwkInfo | ||||
|     { | ||||
|  | ||||
| 		# get, check, split the node IP | ||||
| 		my $IP = inet_ntoa(inet_aton($node)); | ||||
| 		my $IP = xCAT::Utils->getipaddr($node); | ||||
| 		chomp $IP; | ||||
| 		unless ($IP =~ /\d+\.\d+\.\d+\.\d+/) | ||||
| 		unless (($IP =~ /\d+\.\d+\.\d+\.\d+/) || ($IP =~ /:/)) | ||||
| 		{ | ||||
|     		next;    #Not supporting IPv6 yet | ||||
|     		next; | ||||
| 		} | ||||
| 		my ($ia, $ib, $ic, $id) = split('\.', $IP); | ||||
|  | ||||
| @@ -1861,25 +1860,18 @@ sub getNetwkInfo | ||||
| 			my $net=$_->{'net'}; | ||||
| 			chomp $NM; | ||||
| 			chomp $net; | ||||
| 			my ($n1, $n2, $n3, $n4) = split('\.', $net); | ||||
| 			my ($na, $nb, $nc, $nd) = split('\.', $NM); | ||||
|  | ||||
| 			# Convert to integers so the bitwise and (&) works correctly. | ||||
| 			my $sa     = (int($ia) & int($na)); | ||||
| 			my $sb     = (int($ib) & int($nb)); | ||||
| 			my $sc     = (int($ic) & int($nc)); | ||||
| 			my $sd     = (int($id) & int($nd)); | ||||
|  | ||||
| 			# if all the octals match then we have the right network | ||||
| 			if ( ($n1 == $sa) && ($n2 ==$sb) && ($n3 == $sc) && ($n4 == $sd) ) { | ||||
|                         if(xCAT::Utils->ishostinsubnet($IP, $NM, $net)) | ||||
|                         { | ||||
| 				# fill in the hash -  | ||||
| 				foreach my $attr (@attrnames) { | ||||
| 					if ( defined($_->{$attr}) ) { | ||||
| 						$nethash{$node}{$attr} = $_->{$attr}; | ||||
| 					} | ||||
| 				} | ||||
| 				next; | ||||
| 			} | ||||
|                                 } | ||||
|                                 next; | ||||
|                         } | ||||
|                              | ||||
| 		} | ||||
|  | ||||
| 	} #end - for each node | ||||
|   | ||||
| @@ -185,14 +185,14 @@ sub is_me | ||||
|     my ($class, $name) = @_; | ||||
|  | ||||
|     # convert to IP | ||||
|     my $nameIP = inet_ntoa(inet_aton($name)); | ||||
|     my $nameIP = xCAT::Utils->getipaddr($name); | ||||
|     chomp $nameIP; | ||||
|  | ||||
|     # split into octets | ||||
|     my ($b1, $b2, $b3, $b4) = split /\./, $nameIP; | ||||
|     #my ($b1, $b2, $b3, $b4) = split /\./, $nameIP; | ||||
|  | ||||
|     # get all the possible IPs for the node I'm running on | ||||
|     my $ifcmd = "ifconfig -a | grep 'inet '"; | ||||
|     my $ifcmd = "ifconfig -a | grep 'inet'"; | ||||
|     my $result = xCAT::Utils->runcmd($ifcmd, 0, 1); | ||||
|     if ($::RUNCMD_RC != 0) | ||||
|     { | ||||
| @@ -207,11 +207,10 @@ sub is_me | ||||
|     { | ||||
|         my ($inet, $myIP, $str) = split(" ", $int); | ||||
|         chomp $myIP; | ||||
|         $myIP =~ s/\/.*//; # ipv6 address 4000::99/64 | ||||
|         $myIP =~ s/\%.*//; # ipv6 address ::1%1/128 | ||||
|  | ||||
|         # Split the two ip addresses up into octets | ||||
|         my ($a1, $a2, $a3, $a4) = split /\./, $myIP; | ||||
|  | ||||
|         if (($a1 == $b1) && ($a2 == $b2) && ($a3 == $b3) && ($a4 == $b4)) | ||||
|         if ($myIP eq $nameIP) | ||||
|         { | ||||
|             return 1; | ||||
|         } | ||||
|   | ||||
| @@ -96,7 +96,7 @@ sub parse_args { | ||||
|             push @network, $_; | ||||
|         } else { | ||||
|             # get, check the node IP | ||||
|             $client_ip = inet_ntoa(inet_aton(@$node[0])); | ||||
|             $client_ip = xCAT::Utils->getipaddr(@$node[0]); | ||||
|             chomp $client_ip; | ||||
|             if ( $client_ip ) { | ||||
|                 $opt{C} = $client_ip; | ||||
| @@ -118,7 +118,7 @@ sub parse_args { | ||||
|                     # Service node is returned as hostname, Convert  | ||||
|                     # hostname to IP   | ||||
|                     #################################### | ||||
|                     $server_ip = inet_ntoa(inet_aton($key)); | ||||
|                     $server_ip = xCAT::Utils->getipaddr($key); | ||||
|                     chomp $server_ip; | ||||
|                 } else { | ||||
|                     #################################### | ||||
| @@ -139,7 +139,9 @@ sub parse_args { | ||||
|         # Fulfill in the server network information for gateway resolving | ||||
|         #################################################################### | ||||
|         if ( exists($opt{S}) ) { | ||||
|             $server = gethostbyaddr( inet_aton($opt{S}), AF_INET ); | ||||
|             # why convert to hostname?? | ||||
|             #$server = gethostbyaddr( inet_aton($opt{S}), AF_INET ); | ||||
|             $server = $opt{S}; | ||||
|             if ( $server ) { | ||||
|                 %server_nethash = xCAT::DBobjUtils->getNetwkInfo( [$server] ); | ||||
|             } | ||||
|   | ||||
| @@ -107,7 +107,7 @@ sub getshorthost { | ||||
|  | ||||
|     my $ip = shift; | ||||
|  | ||||
|     my $host = gethostbyaddr( inet_aton($ip), AF_INET ); | ||||
|     my $host = xCAT::Utils->gethostname($ip); | ||||
|     if ( $host and !$! ) { | ||||
|         ############################## | ||||
|         # Get short-hostname | ||||
|   | ||||
		Reference in New Issue
	
	Block a user