fix for bug 3568424
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13842 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -12537,7 +12537,6 @@ sub rmdsklsnode | ||||
|  | ||||
|     foreach my $node (@nodelist) | ||||
|     { | ||||
|  | ||||
|         my $nodename; | ||||
|         my $name; | ||||
|         ($name = $node) =~ s/\..*$//;    # always use short hostname | ||||
| @@ -12562,136 +12561,149 @@ sub rmdsklsnode | ||||
| 			next; | ||||
|         } | ||||
|  | ||||
|         # see if the node is running | ||||
| # ndebug | ||||
|  | ||||
| 		my $badmstate; | ||||
|         my $badnodestat; | ||||
| 		# see if the node is running | ||||
| 		# check BOTH Mstate and nodestat | ||||
| 		my $nimMstate; | ||||
| 		my $runstatus; | ||||
|  | ||||
| 		# check NIM Mstate for node | ||||
| 		my $mstate = xCAT::InstUtils->get_nim_attr_val($nodename, "Mstate", $callback, $Sname, $subreq); | ||||
|         if ($mstate && (!($mstate =~ /currently running/)) ) { | ||||
| 			$badmstate++; | ||||
| 		if ($mstate && ($mstate =~ /currently running/) ) { | ||||
| 			# NIM thinks the node is running | ||||
| 			$nimMstate++; | ||||
| 		} | ||||
|  | ||||
|         # check xCAT nodelist.status for the node | ||||
|         if ($nlhash && $nlhash->{$name}->[0]->{'status'} ne 'booted') | ||||
| 		{ | ||||
| 			$badnodestat++; | ||||
| 		# check xCAT nodelist.status for the node | ||||
| 		if ($nlhash && ($nlhash->{$name}->[0]->{'status'} eq 'booted') || ($nlhash->{$name}->[0]->{'status'} eq 'alive') ) { | ||||
| 			$runstatus++; | ||||
| 		} | ||||
|  | ||||
| 		if (!$badmstate && !$badnodestat)  | ||||
|         { | ||||
| 		#  do we think the node is running? | ||||
| 		my $noderunning = 0; | ||||
|  | ||||
| 		  # if REMDEF then skip the node shut down | ||||
| 		  if (!$::REMDEF) | ||||
| 		  { | ||||
|             if ($::FORCE) | ||||
|             { | ||||
|                 if ($::VERBOSE) | ||||
|                 { | ||||
|                     my $rsp; | ||||
|                     push @{$rsp->{data}}, "Shutting down node \'$name\'"; | ||||
|                     xCAT::MsgUtils->message("I", $rsp, $callback); | ||||
|                 } | ||||
| 		# ???  one or the other or both? | ||||
| 		if ($nimMstate || $runstatus) { | ||||
|     		$noderunning++; | ||||
| 		} | ||||
|  | ||||
|                 # shut down the node | ||||
|                 my $scmd = "shutdown -F &"; | ||||
|                 my $output; | ||||
|                 $output = | ||||
|                   xCAT::InstUtils->xcmd($callback, $subreq, "xdsh", $name, $scmd, 0); | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 # don't remove the def | ||||
|                 my $rsp; | ||||
|                 push @{$rsp->{data}}, | ||||
|                   "The node \'$name\' is currently running. Use the -f flag to force the removal of the NIM client definition."; | ||||
|                 xCAT::MsgUtils->message("E", $rsp, $callback); | ||||
|                 $error++; | ||||
|                 push(@nodesfailed, $nodename); | ||||
|                 next; | ||||
|             } | ||||
| 		  } # end - if not REMDEF | ||||
|         } | ||||
| 		# if node is running then try to shut it down or give error | ||||
| 		if ( $noderunning ) { | ||||
| 			# REMDEF means just remove the client def  | ||||
| 			#	- don't try to shut down | ||||
|           	if (!$::REMDEF) | ||||
|           	{ | ||||
|             	if ($::FORCE) | ||||
|             	{ | ||||
|                 	if ($::VERBOSE) | ||||
|                 	{ | ||||
|                     	my $rsp; | ||||
|                     	push @{$rsp->{data}}, "Shutting down node \'$name\'"; | ||||
|                     	xCAT::MsgUtils->message("I", $rsp, $callback); | ||||
| 					} | ||||
|  | ||||
|         if ($::VERBOSE) | ||||
|         { | ||||
|             my $rsp; | ||||
|             push @{$rsp->{data}}, "Resetting NIM client \'$nodename\'"; | ||||
|             xCAT::MsgUtils->message("I", $rsp, $callback); | ||||
|         } | ||||
|                 	# shut down the node | ||||
|                 	my $scmd = "shutdown -F &"; | ||||
|                 	my $output; | ||||
|                 	$output = | ||||
|                   		xCAT::InstUtils->xcmd($callback, $subreq, "xdsh", $name, $scmd, 0); | ||||
| 					# assume the node is down now | ||||
| 					$noderunning = 0; | ||||
|             	} | ||||
|             	else | ||||
|             	{ | ||||
|                 	# don't remove the def | ||||
|                 	my $rsp; | ||||
|                 	push @{$rsp->{data}}, | ||||
|                   		"The node \'$name\' is currently running. Use the -f flag to force the removal of the NIM client definition."; | ||||
|                 	xCAT::MsgUtils->message("E", $rsp, $callback); | ||||
|                 	$error++; | ||||
|                 	push(@nodesfailed, $nodename); | ||||
|                 	next; | ||||
|             	} | ||||
| 		  	} # end - if not REMDEF | ||||
|         } # end of if running shut down | ||||
|  | ||||
|         # nim -Fo reset c75m5ihp05_53Lcosi | ||||
|         my $cmd = "nim -Fo reset -a force=yes $nodename  >/dev/null 2>&1"; | ||||
|         my $output; | ||||
| 		# if not running or REMDEF then do the remove of the client def | ||||
| 		if (!$noderunning || $::REMDEF) { | ||||
|         	if ($::VERBOSE) | ||||
|         	{ | ||||
|             	my $rsp; | ||||
|             	push @{$rsp->{data}}, "Resetting NIM client node \'$nodename\'"; | ||||
|             	xCAT::MsgUtils->message("I", $rsp, $callback); | ||||
|         	} | ||||
|  | ||||
|         $output = xCAT::Utils->runcmd("$cmd", -1); | ||||
|         if ($::RUNCMD_RC != 0) | ||||
|         { | ||||
|             my $rsp; | ||||
|             if ($::VERBOSE) | ||||
|             { | ||||
|                 push @{$rsp->{data}}, | ||||
|                   "Could not reset the NIM client machine definition for \'$nodename\'.\n"; | ||||
|                 push @{$rsp->{data}}, "$output"; | ||||
|             } | ||||
|             xCAT::MsgUtils->message("E", $rsp, $callback); | ||||
|             $error++; | ||||
|             push(@nodesfailed, $nodename); | ||||
|             next; | ||||
|         } | ||||
|         	# nim -Fo reset c75m5ihp05_53Lcosi | ||||
|         	my $cmd = "nim -Fo reset $nodename  >/dev/null 2>&1"; | ||||
|         	my $output; | ||||
|  | ||||
|         if ($::VERBOSE) | ||||
|         { | ||||
|             my $rsp; | ||||
|             push @{$rsp->{data}}, | ||||
|               "Deallocating resources for NIM client \'$nodename\'"; | ||||
|             xCAT::MsgUtils->message("I", $rsp, $callback); | ||||
|         } | ||||
|         	$output = xCAT::Utils->runcmd("$cmd", -1); | ||||
|         	if ($::RUNCMD_RC != 0) | ||||
|         	{ | ||||
|             	my $rsp; | ||||
|             	if ($::VERBOSE) | ||||
|             	{ | ||||
|                 	push @{$rsp->{data}}, | ||||
|                   		"Could not reset the NIM machine definition for \'$nodename\'.\n"; | ||||
|                 	push @{$rsp->{data}}, "$output"; | ||||
|             	} | ||||
|             	xCAT::MsgUtils->message("E", $rsp, $callback); | ||||
|             	$error++; | ||||
|             	push(@nodesfailed, $nodename); | ||||
|             	next; | ||||
|         	} | ||||
|  | ||||
|         $cmd = "nim -Fo deallocate -a subclass=all $nodename  >/dev/null 2>&1"; | ||||
|         $output = xCAT::Utils->runcmd("$cmd", -1); | ||||
|         if ($::RUNCMD_RC != 0) | ||||
|         { | ||||
|             my $rsp; | ||||
|             if ($::VERBOSE) | ||||
|             { | ||||
|                 push @{$rsp->{data}}, | ||||
|                   "Could not deallocate resources for the NIM client machine definition \'$nodename\'.\n"; | ||||
|                 push @{$rsp->{data}}, "$output"; | ||||
|             } | ||||
|             xCAT::MsgUtils->message("E", $rsp, $callback); | ||||
|             $error++; | ||||
|             push(@nodesfailed, $nodename); | ||||
|             next; | ||||
|         } | ||||
|         	if ($::VERBOSE) | ||||
|         	{ | ||||
|             	my $rsp; | ||||
|             	push @{$rsp->{data}}, | ||||
|               		"Deallocating resources for NIM node \'$nodename\'"; | ||||
|             	xCAT::MsgUtils->message("I", $rsp, $callback); | ||||
|         	} | ||||
|  | ||||
|         if ($::VERBOSE) | ||||
|         { | ||||
|             my $rsp; | ||||
|             push @{$rsp->{data}}, | ||||
|               "Removing the NIM definition for NIM client \'$nodename\'"; | ||||
|             xCAT::MsgUtils->message("I", $rsp, $callback); | ||||
|         } | ||||
|         	$cmd = "nim -Fo deallocate -a subclass=all $nodename  >/dev/null 2>&1"; | ||||
|         	$output = xCAT::Utils->runcmd("$cmd", -1); | ||||
|         	if ($::RUNCMD_RC != 0) | ||||
|         	{ | ||||
|             	my $rsp; | ||||
|             	if ($::VERBOSE) | ||||
|             	{ | ||||
|                 	push @{$rsp->{data}}, | ||||
|                   		"Could not deallocate resources for the NIM machine definition \'$nodename\'.\n"; | ||||
|                 	push @{$rsp->{data}}, "$output"; | ||||
|             	} | ||||
|             	xCAT::MsgUtils->message("E", $rsp, $callback); | ||||
|             	$error++; | ||||
|             	push(@nodesfailed, $nodename); | ||||
|             	next; | ||||
|         	} | ||||
|  | ||||
|         $cmd = "nim -Fo remove $nodename  >/dev/null 2>&1"; | ||||
|         $output = xCAT::Utils->runcmd("$cmd", -1); | ||||
|         if ($::RUNCMD_RC != 0) | ||||
|         { | ||||
|             my $rsp; | ||||
|             if ($::VERBOSE) | ||||
|             { | ||||
|                 push @{$rsp->{data}}, | ||||
|                   "Could not remove the NIM client machine definition \'$nodename\'.\n"; | ||||
|                 push @{$rsp->{data}}, "$output"; | ||||
|             } | ||||
|             xCAT::MsgUtils->message("E", $rsp, $callback); | ||||
|             $error++; | ||||
|             push(@nodesfailed, $nodename); | ||||
|             next; | ||||
|         } | ||||
|         	if ($::VERBOSE) | ||||
|         	{ | ||||
|             	my $rsp; | ||||
|             	push @{$rsp->{data}}, | ||||
|               		"Removing the NIM definition for NIM node \'$nodename\'"; | ||||
|             	xCAT::MsgUtils->message("I", $rsp, $callback); | ||||
|         	} | ||||
|  | ||||
|         	$cmd = "nim -Fo remove $nodename  >/dev/null 2>&1"; | ||||
|         	$output = xCAT::Utils->runcmd("$cmd", -1); | ||||
|         	if ($::RUNCMD_RC != 0) | ||||
|         	{ | ||||
|             	my $rsp; | ||||
|             	if ($::VERBOSE) | ||||
|             	{ | ||||
|                 	push @{$rsp->{data}}, | ||||
|                   		"Could not remove the NIM machine definition \'$nodename\'.\n"; | ||||
|                 	push @{$rsp->{data}}, "$output"; | ||||
|             	} | ||||
|             	xCAT::MsgUtils->message("E", $rsp, $callback); | ||||
|             	$error++; | ||||
|             	push(@nodesfailed, $nodename); | ||||
|             	next; | ||||
|         	} | ||||
| 		} | ||||
|     }    # end - for each node | ||||
|  | ||||
| 	#   restore tftpboot and bootptab files | ||||
|   | ||||
		Reference in New Issue
	
	Block a user