From 973d71517b2a8309e24867ba5488474c9ebed697 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Tue, 7 Mar 2017 11:47:59 -0500 Subject: [PATCH 1/2] Make running nodeset offline optional for rmdef --- .../admin-guides/references/man1/rmdef.1.rst | 16 +++--- xCAT-client/pods/man1/rmdef.1.pod | 14 ++--- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 55 +++++++++++++------ 3 files changed, 54 insertions(+), 31 deletions(-) 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; From 87d870f1bcbfc68f89112372792fe408b8145a3a Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Fri, 10 Mar 2017 14:03:39 -0500 Subject: [PATCH 2/2] Update man page based on comments --- .../admin-guides/references/man1/rmdef.1.rst | 71 +++++++++++-------- xCAT-client/pods/man1/rmdef.1.pod | 12 +++- 2 files changed, 53 insertions(+), 30 deletions(-) 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 f520916bc..06e4c474d 100644 --- a/docs/source/guides/admin-guides/references/man1/rmdef.1.rst +++ b/docs/source/guides/admin-guides/references/man1/rmdef.1.rst @@ -41,49 +41,62 @@ 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 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. + Clear the whole xCAT database. A backup of the xCAT definitions should be saved before using this option as the xCAT daemons will no longer work once cleared. - - -\ **-f|-**\ **-force**\ + To restore: - Use this with the \ **-**\ **-all**\ option as an extra indicator that ALL definitions are to be removed. - - -\ **-h|-**\ **-help**\ + 1. \ **export XCATBYPASS=1**\ and run the \ **restorexCATdb**\ command. + + or + - Display a usage message. - - -\ *noderange*\ + 2. Run \ **xcatconfig -d**\ which initializes the database the same as when xCAT was installed. - A set of comma delimited node names and/or group names. See the "noderange" man page for details on supported formats. - - -\ **-o**\ \ *object-names*\ - A set of comma delimited object names. + \ **-f|-**\ **-force**\ + + Use this with the \ **-**\ **-all**\ option as an extra indicator that ALL definitions are to be removed. + - - -\ **-t**\ \ *object-types*\ - A set of comma delimited object types. + \ **-h|-**\ **-help**\ + + Display a usage message. + - - -\ **-C|-**\ **-cleanup**\ - Perform additional cleanup by running \ **nodeset offline**\ on the objects specified in the \ *noderange*\ . + \ *noderange*\ + + A set of comma delimited node names and/or group names. See the "noderange" man page for details on supported formats. + - - -\ **-V|-**\ **-verbose**\ - Verbose mode. + \ **-o**\ \ *object-names*\ + + A set of comma delimited object names. + + + + \ **-t**\ \ *object-types*\ + + A set of comma delimited object types. + + + + \ **-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 be44ccc73..0c3e8d58a 100644 --- a/xCAT-client/pods/man1/rmdef.1.pod +++ b/xCAT-client/pods/man1/rmdef.1.pod @@ -22,7 +22,17 @@ 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 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. +Clear the whole xCAT database. A backup of the xCAT definitions should be saved before using this option as the xCAT daemons will no longer work once cleared. + +To restore: + +=over 5 + +=item 1. B and run the B command. + +or + +=item 2. Run B which initializes the database the same as when xCAT was installed. =item B<-f|--force>