diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index 85ebf4de4..70ac3de85 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -129,10 +129,36 @@ sub delnode my $mac; my $hname; ($mac, $hname) = split(/!/, $mace); - unless ($hname) { $hname = $node; } + + unless ($hname) + { + $hname = $node; + } #Default to hostname equal to nodename + unless ($mac) { next; } #Skip corrupt format + + if ( !grep /:/,$mac ) { + $mac = lc($mac); + $mac =~ s/(\w{2})/$1:/g; + $mac =~ s/:$//; + } + my $hostname = $hname; + my %client_nethash = xCAT::DBobjUtils->getNetwkInfo( [$node] ); + if ( $client_nethash{$node}{mgtifname} =~ /hf/ ) + { + if ( scalar(@macs) > 1 ) { + if ( $hname !~ /^(.*)-hf(.*)$/ ) { + $hostname = $hname . "-hf" . $count; + } else { + $hostname = $1 . "-hf" . $count; + } + } + } + $count = $count + 2; + + unless ($hostname) { $hostname = $node; } print $omshell "new host\n"; print $omshell - "set name = \"$hname\"\n"; #Find and destroy conflict name + "set name = \"$hostname\"\n"; #Find and destroy conflict name print $omshell "open\n"; print $omshell "remove\n"; print $omshell "close\n"; @@ -149,9 +175,9 @@ sub delnode if ($inetn) { my $ip; - if (inet_aton($hname)) + if (inet_aton($hostname)) { - $ip = inet_ntoa(inet_aton($hname)); + $ip = inet_ntoa(inet_aton($hostname)); } if ($ip) {