From ee5d0166667a7288876f77add46ded2a5333e291 Mon Sep 17 00:00:00 2001 From: cjhardee Date: Mon, 1 Nov 2010 17:56:57 +0000 Subject: [PATCH] unlinked files for nodeset offline git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7993 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/pxe.pm | 44 ++++++++++++++++++++++++++++ xCAT-server/lib/xcat/plugins/xnba.pm | 4 +++ 2 files changed, 48 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/pxe.pm b/xCAT-server/lib/xcat/plugins/pxe.pm index 2e602a680..01fad97f5 100644 --- a/xCAT-server/lib/xcat/plugins/pxe.pm +++ b/xCAT-server/lib/xcat/plugins/pxe.pm @@ -496,6 +496,50 @@ sub process_request { } } + #unlink the files for 'offline' command + if($args[0] eq 'offline') { + foreach my $node (@nodes) { + my %ipaddrs; + unless (inet_aton($node)) { + syslog("local1|err","xCAT unable to resolve IP in pxe plugin"); + return; + } + my $ip = inet_ntoa(inet_aton($node));; + unless ($ip) { + syslog("local1|err","xCAT unable to resolve IP in pxe plugin"); + return; + } + $ipaddrs{$ip} = 1; + if ($mactab) { + my $ment = $machash{$node}->[0]; #$mactab->getNodeAttribs($node,['mac']); + if ($ment and $ment->{mac}) { + my @macs = split(/\|/,$ment->{mac}); + foreach (@macs) { + if (/!(.*)/) { + if (inet_aton($1)) { + $ipaddrs{inet_ntoa(inet_aton($1))} = 1; + } + } + } + } + } + my $hassymlink = eval { symlink("",""); 1 }; + + unlink($tftpdir."/pxelinux.cfg/".$node); + + foreach $ip (keys %ipaddrs) { + my @ipa=split(/\./,$ip); + my $pname = sprintf("%02X%02X%02X%02X",@ipa); + unlink($tftpdir."/pxelinux.cfg/".$pname); + #if ($hassymlink) { + #symlink($node,$tftpdir."/pxelinux.cfg/".$pname); + #} else { + #link($tftpdir."/pxelinux.cfg/".$node,$tftpdir."/pxelinux.cfg/".$pname); + #} + } + } + } + #now run the end part of the prescripts unless ($args[0] eq 'stat') { # or $args[0] eq 'enact') $errored=0; diff --git a/xCAT-server/lib/xcat/plugins/xnba.pm b/xCAT-server/lib/xcat/plugins/xnba.pm index 139e4da5c..0b2e633ce 100644 --- a/xCAT-server/lib/xcat/plugins/xnba.pm +++ b/xCAT-server/lib/xcat/plugins/xnba.pm @@ -509,6 +509,10 @@ sub process_request { $response{node}->[0]->{errorc}->[0]= $errstr; $callback->(\%response); } + if($args[0] eq 'offline') { + unlink($tftpdir."/xcat/xnba/nodes/".$node); + unlink($tftpdir."/xcat/xnba/nodes/".$node.".pxelinux"); + } } }