From a67083a316eb02c903483b21bc83de4a8ca0cf24 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 14 Jan 2008 20:29:15 +0000 Subject: [PATCH] Fix multi-hostname dhcp definition deletion in dhcp plugin git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@262 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/dhcp.pm | 27 +++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/xCAT-server-2.0/lib/xcat/plugins/dhcp.pm b/xCAT-server-2.0/lib/xcat/plugins/dhcp.pm index 1391cca34..e95663f4b 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/dhcp.pm @@ -28,6 +28,31 @@ sub delnode { my $node = shift; my $inetn = inet_aton($node); + my $mactab = xCAT::Table->new('mac'); + if ($mactab) { $ent = $mactab->getNodeAttribs($node,[qw(mac)]); } + if ($ent and $ent->{mac}) { + my @macs = split(/\|/,$ent->{mac}); + my $mace; + foreach $mace (@macs) { + my $mac; + my $hname; + ($mac,$hname) = split (/!/,$mace); + print $omshell "new host\n"; + print $omshell "set name = \"$hname\"\n"; #Find and destroy conflict name + print $omshell "open\n"; + print $omshell "remove\n"; + print $omshell "close\n"; + if ($inetn) { + my $ip = inet_ntoa(inet_aton($hname));; + unless ($ip) { return; } + print $omshell "new host\n"; + print $omshell "set ip-address = $ip\n"; #find and destroy ip conflict + print $omshell "open\n"; + print $omshell "remove\n"; + print $omshell "close\n"; + } + } + } print $omshell "new host\n"; print $omshell "set name = \"$node\"\n"; #Find and destroy conflict name print $omshell "open\n"; @@ -75,7 +100,7 @@ sub addnode { return; } my $ip = inet_ntoa(inet_aton($hname));; - print "Setting $node ($hname|$ip) to ".$ent->{mac}."\n"; + syslog("local4|err","Setting $node ($hname|$ip) to ".$mac); print $omshell "new host\n"; print $omshell "set name = \"$hname\"\n"; #Find and destroy conflict name print $omshell "open\n";