From 1ef96686f2ccf5af1be7f8634a5fa93d881dd5d3 Mon Sep 17 00:00:00 2001 From: vallard Date: Tue, 19 Jan 2010 05:49:22 +0000 Subject: [PATCH] removes node configuration to force a node to be autodiscovered on next boot git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4973 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/share/xcat/tools/rmnodecfg | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 xCAT-server/share/xcat/tools/rmnodecfg diff --git a/xCAT-server/share/xcat/tools/rmnodecfg b/xCAT-server/share/xcat/tools/rmnodecfg new file mode 100755 index 000000000..e8728999f --- /dev/null +++ b/xCAT-server/share/xcat/tools/rmnodecfg @@ -0,0 +1,52 @@ +#!/usr/bin/perl +# removes the configuration of a node so that the next time you reboot +# a node it forces it to go through the discovery process. +# usage: rmnodecfg +# this does not remove it completely from xCAT. You may want to do this +# command before running noderm to completely purge the system of the node +use strict; +use Socket; + +my $blades = shift; +if(! $blades) { + print "Please specify a noderange of blades to remove\n"; + exit; +} + +foreach my $blade (`/opt/xcat/bin/nodels $blades`){ + chomp($blade); + my $hex = ip2hex($blade); + my $cmd = "nodech $blade chain.currstate= chain.currchain= chain.chain="; + $cmd = "chtab -d node=$blade chain"; + print "$cmd\n"; + `$cmd`; + $cmd = "chtab -d node=$blade mac"; + print "$cmd\n"; + `$cmd`; + $cmd = "makedhcp -d $blade"; + print "$cmd\n"; + `$cmd`; + $cmd = "rm /tftpboot/pxelinux.cfg/$blade"; + print "$cmd\n"; + `$cmd`; + if($hex){ + $cmd = "rm /tftpboot/pxelinux.cfg/$hex"; + print "$cmd\n"; + `$cmd`; + } +} + +sub ip2hex { + my $node = shift; + my $ip = ''; + my @quad; + my $hex = ''; + my $packed_ip = gethostbyname($node); + if(defined $packed_ip){ + $ip = inet_ntoa($packed_ip); + @quad = split('\.', $ip); + $hex = sprintf("%02X%02X%02X%02X", @quad); + } + return $hex; +} +