Fix for the problem that -f does not work for the existing diskful CN.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8589 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
sjing 2011-01-10 09:52:02 +00:00
parent 8ab1e35be0
commit 80f82a6a5d

View File

@ -7861,6 +7861,7 @@ sub mkdsklsnode
my $todef = 0;
my $toinit = 0;
my $toremove = 0;
# see if it's already defined first
if (grep(/^$nim_name$/, @machines))
@ -7868,6 +7869,23 @@ sub mkdsklsnode
# Already defined
if ($::FORCE)
{
# To determine if the defined node is standalone
my $tstring;
$cmd =
qq~/usr/sbin/lsnim -l $nim_name | grep "type " 2>/dev/null~;
$tstring = xCAT::Utils->runcmd("$cmd", -1);
my ($junk, $mtype) = split(/=/, $tstring);
chomp $mtype;
if ($mtype =~ /standalone/)
{
# Need to remove the machine and define it as diskless
$toremove = 1;
$todef = 1;
}
# Reinitialize
# Deallocate the nim resources for the existing machine, but not remove machine definition
@ -7886,7 +7904,7 @@ sub mkdsklsnode
{
my $rsp;
push @{$rsp->{data}},
"$Sname: Could not remove the existing NIM object named \'$nim_name\'.\n";
"$Sname: Could not deallocate the existing NIM object named \'$nim_name\'.\n";
if ($::VERBOSE)
{
push @{$rsp->{data}}, "$output";
@ -7897,6 +7915,27 @@ sub mkdsklsnode
next;
}
if ($toremove == 1)
{
$cmd =
"/usr/sbin/nim -Fo remove $nim_name";
$output = xCAT::Utils->runcmd("$cmd", -1);
if ($::RUNCMD_RC != 0)
{
my $rsp;
push @{$rsp->{data}},
"$Sname: Could not remove the existing NIM object named \'$nim_name\'.\n";
if ($::VERBOSE)
{
push @{$rsp->{data}}, "$output";
}
xCAT::MsgUtils->message("E", $rsp, $callback);
$error++;
push(@nodesfailed, $node);
next;
}
}
# To be reinitialized
$toinit = 1;