2010-01-19 05:49:22 +00:00
|
|
|
#!/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 <noderange>
|
|
|
|
# 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
|
2010-02-24 09:25:29 +00:00
|
|
|
BEGIN
|
|
|
|
{
|
|
|
|
$::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat';
|
|
|
|
}
|
|
|
|
|
|
|
|
use lib "$::XCATROOT/lib/perl";
|
2010-01-19 05:49:22 +00:00
|
|
|
use strict;
|
|
|
|
use Socket;
|
|
|
|
|
2013-03-13 23:01:17 +00:00
|
|
|
use Getopt::Long;
|
|
|
|
|
|
|
|
my $help;
|
|
|
|
GetOptions('h|help' => \$help);
|
|
|
|
if ($help) {
|
|
|
|
print <<'EOS';
|
|
|
|
Usage: rmnodecfg [-h|--help] <noderange>
|
|
|
|
|
|
|
|
Removes the configuration of a node so that the next time you reboot
|
|
|
|
it, it forces it to go through the discovery process.
|
|
|
|
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
|
2013-03-14 14:18:54 +00:00
|
|
|
|
|
|
|
Author: Vallard Benincosa
|
2013-03-13 23:01:17 +00:00
|
|
|
EOS
|
|
|
|
exit 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
require xCAT::Utils;
|
|
|
|
require xCAT::TableUtils;
|
|
|
|
|
2010-01-19 05:49:22 +00:00
|
|
|
my $blades = shift;
|
|
|
|
if(! $blades) {
|
|
|
|
print "Please specify a noderange of blades to remove\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
2012-08-22 07:36:09 +00:00
|
|
|
my $tftpdir = xCAT::TableUtils->getTftpDir();
|
2010-02-24 09:25:29 +00:00
|
|
|
|
2010-01-19 05:49:22 +00:00
|
|
|
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`;
|
2010-02-24 09:25:29 +00:00
|
|
|
$cmd = "rm $tftpdir/pxelinux.cfg/$blade";
|
2010-01-19 05:49:22 +00:00
|
|
|
print "$cmd\n";
|
|
|
|
`$cmd`;
|
|
|
|
if($hex){
|
2010-02-24 09:25:29 +00:00
|
|
|
$cmd = "rm $tftpdir/pxelinux.cfg/$hex";
|
2010-01-19 05:49:22 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|