From 4703244376e4954fcaa4bee4afcd473240abb970 Mon Sep 17 00:00:00 2001 From: Mark Gurevich Date: Thu, 21 Nov 2019 10:50:36 -0500 Subject: [PATCH] Remove /install/autoinst config files as part of nodepurge --- .../admin-guides/references/man1/nodepurge.1.rst | 16 +++++----------- xCAT-client/pods/man1/nodepurge.1.pod | 16 +++++----------- xCAT-server/lib/xcat/plugins/profilednodes.pm | 16 +++++++++++++++- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/docs/source/guides/admin-guides/references/man1/nodepurge.1.rst b/docs/source/guides/admin-guides/references/man1/nodepurge.1.rst index 847eb6c7b..a8d256927 100644 --- a/docs/source/guides/admin-guides/references/man1/nodepurge.1.rst +++ b/docs/source/guides/admin-guides/references/man1/nodepurge.1.rst @@ -31,7 +31,7 @@ DESCRIPTION The \ **nodepurge**\ automatically removes all nodes from the database and any related configurations used by the node. -After the nodes are removed, the configuration files related to these nodes are automatically updated, including the following files: /etc/hosts, DNS, DHCP. Any kits that are used by the nodes are triggered to automatically update kit configuration and services. +After the nodes are removed, the configuration files related to these nodes are automatically updated, including the following files: \ */etc/hosts*\ , DNS, DHCP. Any kits that are used by the nodes are triggered to automatically update kit configuration and services. Any related configuration files from \ */install/autoinst*\ are also removed. ******* @@ -39,17 +39,11 @@ OPTIONS ******* -\ **-h|-**\ **-help**\ +\ **-h|-**\ **-help**\ Display usage message. -Display usage message. +\ **-v|-**\ **-version**\ Command Version -\ **-v|-**\ **-version**\ - -Command Version - -\ *noderange*\ - -The nodes to be removed. +\ *noderange*\ The nodes to be removed. ************ @@ -67,7 +61,7 @@ EXAMPLES ******** -To remove nodes compute-000 and compute-001, use the following command: +To remove nodes compute-000 and compute-001: .. code-block:: perl diff --git a/xCAT-client/pods/man1/nodepurge.1.pod b/xCAT-client/pods/man1/nodepurge.1.pod index 714f164f2..c71ceb2c4 100644 --- a/xCAT-client/pods/man1/nodepurge.1.pod +++ b/xCAT-client/pods/man1/nodepurge.1.pod @@ -12,21 +12,15 @@ B I The B automatically removes all nodes from the database and any related configurations used by the node. -After the nodes are removed, the configuration files related to these nodes are automatically updated, including the following files: /etc/hosts, DNS, DHCP. Any kits that are used by the nodes are triggered to automatically update kit configuration and services. +After the nodes are removed, the configuration files related to these nodes are automatically updated, including the following files: I, DNS, DHCP. Any kits that are used by the nodes are triggered to automatically update kit configuration and services. Any related configuration files from I are also removed. =head1 OPTIONS -B<-h|--help> +B<-h|--help> Display usage message. -Display usage message. +B<-v|--version> Command Version -B<-v|--version> - -Command Version - -I - -The nodes to be removed. +I The nodes to be removed. =head1 RETURN VALUE @@ -36,7 +30,7 @@ The nodes to be removed. =head1 EXAMPLES -To remove nodes compute-000 and compute-001, use the following command: +To remove nodes compute-000 and compute-001: nodepurge compute-000,compute-001 diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index b3708cf9f..38c49c51d 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -687,7 +687,7 @@ sub nodepurge { Usage: \tnodepurge \tnodepurge [-h|--help] -\tnodepurge {-v|--version}"; +\tnodepurge [-v|--version]"; my $ret = validate_args($helpmsg); if (!$ret) { @@ -735,6 +735,20 @@ Usage: $warnstr .= "Details: $retstrref->[1]"; } } + # For each node in the noderange remove its configureation files in $config_dir, if file exists + setrsp_progress("Removing configuration files..."); + my $config_dir = "/install/autoinst/"; + foreach my $one_node (@$nodes) { + if ( -e "$config_dir/$one_node") { + unlink "$config_dir/$one_node"; + } + if ( -e "$config_dir/$one_node.post") { + unlink "$config_dir/$one_node.post"; + } + if ( -e "$config_dir/$one_node.pre") { + unlink "$config_dir/$one_node.pre"; + } + } setrsp_progress("Removed all nodes."); setrsp_success($nodes, $warnstr); }