diff --git a/docs/source/guides/admin-guides/references/man1/rmdef.1.rst b/docs/source/guides/admin-guides/references/man1/rmdef.1.rst index 4b1d4cb5a..f520916bc 100644 --- a/docs/source/guides/admin-guides/references/man1/rmdef.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rmdef.1.rst @@ -22,7 +22,7 @@ SYNOPSIS \ **rmdef**\ [\ **-h | -**\ **-help**\ ] [\ **-t**\ \ *object-types*\ ] \ **rmdef**\ [\ **-V | -**\ **-verbose**\ ] [\ **-a | -**\ **-all**\ ] [\ **-t**\ \ *object-types*\ ] [\ **-o**\ \ *object-names*\ ] -[\ **-f | -**\ **-force**\ ] [\ *noderange*\ ] +[\ **-f | -**\ **-force**\ ] [\ **-C | -**\ **-cleanup**\ ] [\ *noderange*\ ] *********** @@ -41,17 +41,13 @@ OPTIONS \ **-a|-**\ **-all**\ - Clear the whole xCAT database. A backup of the xCAT definitions should be saved before using this option. Once all the data is removed the xCAT daemon will no longer work. Most xCAT commands will fail. - In order to use xCAT commands again, you have two options. You can restore your database from your backup by switching to bypass mode, and running the restorexCATdb command. - You switch to bypass mode by setting the XCATBYPASS environmant variable. (ex. "export XCATBYPASS=yes") - A second option is to run xcatconfig -d. This will restore the initial setup of the database as when xCAT was initially installed. - You can then restart xcatd and run xCAT commands. + Clear the whole xCAT database. A backup of the xCAT definitions should be saved before using this option. Once all the data is removed the xCAT daemon will no longer work. Most xCAT commands will fail. In order to use xCAT commands again, you have two options. You can restore your database from your backup by switching to bypass mode, and running the \ **restorexCATdb**\ command. You can switch to bypass mode by setting the XCATBYPASS environmant variable. (ex. "export XCATBYPASS=yes") A second option is to run \ **xcatconfig -d**\ . This will restore the initial setup of the database as when xCAT was initially installed. You can then restart xcatd and run xCAT commands. \ **-f|-**\ **-force**\ - Use this with the all option as an extra indicator that ALL definitions are to be removed. + Use this with the \ **-**\ **-all**\ option as an extra indicator that ALL definitions are to be removed. @@ -79,6 +75,12 @@ OPTIONS +\ **-C|-**\ **-cleanup**\ + + Perform additional cleanup by running \ **nodeset offline**\ on the objects specified in the \ *noderange*\ . + + + \ **-V|-**\ **-verbose**\ Verbose mode. diff --git a/xCAT-client/pods/man1/rmdef.1.pod b/xCAT-client/pods/man1/rmdef.1.pod index e226fe80c..be44ccc73 100644 --- a/xCAT-client/pods/man1/rmdef.1.pod +++ b/xCAT-client/pods/man1/rmdef.1.pod @@ -8,7 +8,7 @@ B - Use this command to remove xCAT data object definitions. B [B<-h>|B<--help>] [B<-t> I] B [B<-V>|B<--verbose>] [B<-a>|B<--all>] [B<-t> I] [B<-o> I] -[B<-f>|B<--force>] [I] +[B<-f>|B<--force>] [B<-C>|B<--cleanup>] [I] =head1 DESCRIPTION @@ -22,15 +22,11 @@ This command is used to remove xCAT object definitions that are stored in the xC =item B<-a|--all> -Clear the whole xCAT database. A backup of the xCAT definitions should be saved before using this option. Once all the data is removed the xCAT daemon will no longer work. Most xCAT commands will fail. -In order to use xCAT commands again, you have two options. You can restore your database from your backup by switching to bypass mode, and running the restorexCATdb command. -You switch to bypass mode by setting the XCATBYPASS environmant variable. (ex. "export XCATBYPASS=yes") -A second option is to run xcatconfig -d. This will restore the initial setup of the database as when xCAT was initially installed. -You can then restart xcatd and run xCAT commands. +Clear the whole xCAT database. A backup of the xCAT definitions should be saved before using this option. Once all the data is removed the xCAT daemon will no longer work. Most xCAT commands will fail. In order to use xCAT commands again, you have two options. You can restore your database from your backup by switching to bypass mode, and running the B command. You can switch to bypass mode by setting the XCATBYPASS environmant variable. (ex. "export XCATBYPASS=yes") A second option is to run B. This will restore the initial setup of the database as when xCAT was initially installed. You can then restart xcatd and run xCAT commands. =item B<-f|--force> -Use this with the all option as an extra indicator that ALL definitions are to be removed. +Use this with the B<--all> option as an extra indicator that ALL definitions are to be removed. =item B<-h|--help> @@ -48,6 +44,10 @@ A set of comma delimited object names. A set of comma delimited object types. +=item B<-C|--cleanup> + +Perform additional cleanup by running B on the objects specified in the I. + =item B<-V|--verbose> Verbose mode. diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index d91d51c3e..f263fdfe4 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -468,6 +468,7 @@ sub processArgs undef $::opt_nics; undef $::opt_setattr; undef $::opt_template; + undef $::opt_cleanup; # parse the options - include any option from all 4 cmds Getopt::Long::Configure("no_pass_through"); @@ -497,6 +498,7 @@ sub processArgs 'nics' => \$::opt_nics, 'u' => \$::opt_setattr, 'template:s' => \$::opt_template, + 'C|cleanup' => \$::opt_cleanup, ) ) { @@ -513,6 +515,13 @@ sub processArgs return 2; } + if (defined($::opt_cleanup) && ($::command ne "rmdef")) { + my $rsp; + $rsp->{data}->[0] = "Option \'-C\' can not be used with $::command."; + xCAT::MsgUtils->message("E", $rsp, $::callback); + return 2; + } + if (defined($::opt_setattr)) { if (!$::opt_t && !$::filedata) { $::opt_t = 'osimage'; @@ -4015,6 +4024,9 @@ sub defrm # process the command line my $rc = &processArgs; + # Issue info message if more than cleanup_msg_trigger nodes are being removed with --cleanup option + my $cleanup_msg_trigger = 100; + if ($rc != 0) { @@ -4258,24 +4270,33 @@ sub defrm } } - # Call nodeset offline on each node to cleanup its boot configuration files from /tftpboot directory - if ($doreq) { - # Go through each object and make sure it is a node type - my @allnodes; - foreach my $single_object (keys %objhash) { - if ($objhash{$single_object} eq "node") { - # build a list of nodes to offline - push @allnodes, $single_object; + if ($::opt_cleanup) { + # Call nodeset offline on each node to cleanup its boot configuration files from /tftpboot directory + if ($doreq) { + # Go through each object and make sure it is a node type + my @allnodes; + foreach my $single_object (keys %objhash) { + if ($objhash{$single_object} eq "node") { + # build a list of nodes to offline + push @allnodes, $single_object; + } } + # If cleaning up (issuing nodeset offline) for more than cleanup_msg_trigger node, + # issue info message + if (@allnodes > $cleanup_msg_trigger) { + my $rsp; + $rsp->{data}->[0] = "Performing configuration cleanup. This might take a some time."; + xCAT::MsgUtils->message("I", $rsp, $::callback); + } + # Run nodeset offline and capture output. + # But the output can be ignored since we do not want to prevent user from doing rmdef if + # nodeset returns some error. + my @output = xCAT::Utils->runxcmd({ + command => ['nodeset'], + node => [@allnodes], + arg => ['offline'], + }, $doreq, 0 ,1); } - # Run nodeset offline and capture output. - # But the output can be ignored since we do not want to prevent user from doing rmdef if - # nodeset returns some error. - my @output = xCAT::Utils->runxcmd({ - command => ['nodeset'], - node => [@allnodes], - arg => ['offline'], - }, $doreq, 0 ,1); } # remove the objects @@ -4488,7 +4509,7 @@ sub defrm_usage $rsp->{data}->[0] = "\nUsage: rmdef - Remove xCAT data object definitions.\n"; $rsp->{data}->[1] = " rmdef [-h | --help ] [-t object-types]\n"; $rsp->{data}->[2] = " rmdef [-V | --verbose] [-t object-types] [-a | --all] [-f | --force]"; - $rsp->{data}->[3] = " [-o object-names] [-w attr=val,[attr=val...] [noderange]\n"; + $rsp->{data}->[3] = " [-o object-names] [-C | --cleanup] [noderange]\n"; $rsp->{data}->[4] = "\nThe following data object types are supported by xCAT.\n"; my $n = 5;