Skip to content

Commit 5fa13e3

Browse files
committed
CLI: add options to specify alternate config files (#336)
Added the following command line options: --conf to specify alternative clush.conf (clush only) --groupsconf to specify alternative groups.conf (all CLIs) For example, this can be useful to programmatically create/update clustershell config files with an alternate group source setup. Closes #336 Change-Id: I3aff60057274198b700b44b4d5bbdc916a5b5d0b
1 parent 61c8af3 commit 5fa13e3

File tree

18 files changed

+234
-34
lines changed

18 files changed

+234
-34
lines changed

doc/man/man1/clubak.1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Man page generated from reStructuredText.
22
.
3-
.TH CLUBAK 1 "2017-10-23" "1.8" "ClusterShell User Manual"
3+
.TH CLUBAK 1 "2018-04-16" "1.8" "ClusterShell User Manual"
44
.SH NAME
55
clubak \- format output from clush/pdsh-like output and more
66
.
@@ -71,6 +71,9 @@ fold nodeset using node groups
7171
.BI \-s \ GROUPSOURCE\fP,\fB \ \-\-groupsource\fB= GROUPSOURCE
7272
optional \fBgroups.conf\fP(5) group source to use
7373
.TP
74+
.BI \-\-groupsconf\fB= FILE
75+
use alternate config file for groups.conf(5)
76+
.TP
7477
.B \-G\fP,\fB \-\-groupbase
7578
do not display group source prefix (always \fI@groupname\fP)
7679
.TP

doc/man/man1/cluset.1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Man page generated from reStructuredText.
22
.
3-
.TH CLUSET 1 "2017-10-23" "1.8" "ClusterShell User Manual"
3+
.TH CLUSET 1 "2018-04-16" "1.8" "ClusterShell User Manual"
44
.SH NAME
55
cluset \- compute advanced cluster node set operations
66
.
@@ -61,6 +61,9 @@ show this help message and exit
6161
.TP
6262
.BI \-s \ GROUPSOURCE\fP,\fB \ \-\-groupsource\fB= GROUPSOURCE
6363
optional \fBgroups.conf\fP(5) group source to use
64+
.TP
65+
.BI \-\-groupsconf\fB= FILE
66+
use alternate config file for groups.conf(5)
6467
.UNINDENT
6568
.INDENT 0.0
6669
.TP

doc/man/man1/clush.1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Man page generated from reStructuredText.
22
.
3-
.TH CLUSH 1 "2017-10-23" "1.8" "ClusterShell User Manual"
3+
.TH CLUSH 1 "2018-04-16" "1.8" "ClusterShell User Manual"
44
.SH NAME
55
clush \- execute shell commands on a cluster
66
.
@@ -162,6 +162,12 @@ optional \fBgroups.conf\fP(5) group source to use
162162
.B \-n\fP,\fB \-\-nostdin
163163
do not watch for possible input from stdin; this should be used when \fBclush\fP is run in the background (or in scripts).
164164
.TP
165+
.BI \-\-groupsconf\fB= FILE
166+
use alternate config file for groups.conf(5)
167+
.TP
168+
.BI \-\-conf\fB= FILE
169+
use alternate config file for clush.conf(5)
170+
.TP
165171
.BI \-O \ <KEY=VALUE>\fP,\fB \ \-\-option\fB= <KEY=VALUE>
166172
override any key=value \fBclush.conf\fP(5) options (repeat as needed)
167173
.UNINDENT

doc/man/man1/nodeset.1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Man page generated from reStructuredText.
22
.
3-
.TH NODESET 1 "2017-10-23" "1.8" "ClusterShell User Manual"
3+
.TH NODESET 1 "2018-04-16" "1.8" "ClusterShell User Manual"
44
.SH NAME
55
nodeset \- compute advanced nodeset operations
66
.
@@ -61,6 +61,9 @@ show this help message and exit
6161
.TP
6262
.BI \-s \ GROUPSOURCE\fP,\fB \ \-\-groupsource\fB= GROUPSOURCE
6363
optional \fBgroups.conf\fP(5) group source to use
64+
.TP
65+
.BI \-\-groupsconf\fB= FILE
66+
use alternate config file for groups.conf(5)
6467
.UNINDENT
6568
.INDENT 0.0
6669
.TP

doc/txt/clubak.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ format output from clush/pdsh-like output and more
77
--------------------------------------------------
88

99
:Author: Stephane Thiell <[email protected]>
10-
:Date: 2017-10-23
10+
:Date: 2018-04-16
1111
:Copyright: GNU Lesser General Public License version 2.1 or later (LGPLv2.1+)
1212
:Version: 1.8
1313
:Manual section: 1
@@ -49,6 +49,8 @@ OPTIONS
4949
-r, --regroup fold nodeset using node groups
5050
-s GROUPSOURCE, --groupsource=GROUPSOURCE
5151
optional ``groups.conf``\(5) group source to use
52+
--groupsconf=FILE
53+
use alternate config file for groups.conf(5)
5254
-G, --groupbase
5355
do not display group source prefix (always `@groupname`)
5456
-S SEPARATOR, --separator=SEPARATOR

doc/txt/cluset.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ compute advanced cluster node set operations
77
--------------------------------------------
88

99
:Author: Stephane Thiell <[email protected]>
10-
:Date: 2017-10-23
10+
:Date: 2018-04-16
1111
:Copyright: GNU Lesser General Public License version 2.1 or later (LGPLv2.1+)
1212
:Version: 1.8
1313
:Manual section: 1
@@ -41,6 +41,7 @@ OPTIONS
4141
-h, --help show this help message and exit
4242
-s GROUPSOURCE, --groupsource=GROUPSOURCE
4343
optional ``groups.conf``\(5) group source to use
44+
--groupsconf=FILE use alternate config file for groups.conf(5)
4445

4546
Commands:
4647
-c, --count show number of nodes in nodeset(s)

doc/txt/clush.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ execute shell commands on a cluster
77
-----------------------------------
88

99
:Author: Stephane Thiell <[email protected]>
10-
:Date: 2017-10-23
10+
:Date: 2018-04-16
1111
:Copyright: GNU Lesser General Public License version 2.1 or later (LGPLv2.1+)
1212
:Version: 1.8
1313
:Manual section: 1
@@ -131,6 +131,8 @@ OPTIONS
131131
-s GROUPSOURCE, --groupsource=GROUPSOURCE
132132
optional ``groups.conf``\(5) group source to use
133133
-n, --nostdin do not watch for possible input from stdin; this should be used when ``clush`` is run in the background (or in scripts).
134+
--groupsconf=FILE use alternate config file for groups.conf(5)
135+
--conf=FILE use alternate config file for clush.conf(5)
134136
-O <KEY=VALUE>, --option=<KEY=VALUE>
135137
override any key=value ``clush.conf``\(5) options (repeat as needed)
136138

doc/txt/nodeset.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ compute advanced nodeset operations
77
-----------------------------------
88

99
:Author: Stephane Thiell <[email protected]>
10-
:Date: 2017-10-23
10+
:Date: 2018-04-16
1111
:Copyright: GNU Lesser General Public License version 2.1 or later (LGPLv2.1+)
1212
:Version: 1.8
1313
:Manual section: 1
@@ -41,6 +41,7 @@ OPTIONS
4141
-h, --help show this help message and exit
4242
-s GROUPSOURCE, --groupsource=GROUPSOURCE
4343
optional ``groups.conf``\(5) group source to use
44+
--groupsconf=FILE use alternate config file for groups.conf(5)
4445

4546
Commands:
4647
-c, --count show number of nodes in nodeset(s)

lib/ClusterShell/CLI/Clubak.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22
# Copyright (C) 2010-2012 CEA/DAM
3-
# Copyright (C) 2017 Stephane Thiell <[email protected]>
3+
# Copyright (C) 2017-2018 Stephane Thiell <[email protected]>
44
#
55
# This file is part of ClusterShell.
66
#
@@ -31,9 +31,10 @@
3131

3232
from ClusterShell.MsgTree import MsgTree, MODE_DEFER, MODE_TRACE
3333
from ClusterShell.NodeSet import NodeSet, NodeSetParseError, std_group_resolver
34+
from ClusterShell.NodeSet import set_std_group_resolver_config
3435

3536
from ClusterShell.CLI.Display import Display, THREE_CHOICES
36-
from ClusterShell.CLI.Display import sys_stdin, sys_stdout, sys_stderr
37+
from ClusterShell.CLI.Display import sys_stdin, sys_stdout
3738
from ClusterShell.CLI.Error import GENERIC_ERRORS, handle_generic_error
3839
from ClusterShell.CLI.OptionParser import OptionParser
3940
from ClusterShell.CLI.Utils import nodeset_cmpkey
@@ -94,12 +95,15 @@ def clubak():
9495

9596
# Argument management
9697
parser = OptionParser("%prog [options]")
98+
parser.install_groupsconf_option()
9799
parser.install_display_options(verbose_options=True,
98100
separator_option=True,
99101
dshbak_compat=True,
100102
msgtree_mode=True)
101103
options = parser.parse_args()[0]
102104

105+
set_std_group_resolver_config(options.groupsconf)
106+
103107
if options.interpret_keys == THREE_CHOICES[-1]: # auto?
104108
enable_nodeset_key = None # AUTO
105109
else:

lib/ClusterShell/CLI/Clush.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#
22
# Copyright (C) 2007-2016 CEA/DAM
3-
# Copyright (C) 2015-2017 Stephane Thiell <[email protected]>
3+
# Copyright (C) 2015-2018 Stephane Thiell <[email protected]>
44
#
55
# This file is part of ClusterShell.
66
#
@@ -59,8 +59,8 @@
5959

6060
from ClusterShell.Event import EventHandler
6161
from ClusterShell.MsgTree import MsgTree
62-
from ClusterShell.NodeSet import RESOLVER_NOGROUP, std_group_resolver
63-
from ClusterShell.NodeSet import NodeSet, NodeSetParseError
62+
from ClusterShell.NodeSet import RESOLVER_NOGROUP, set_std_group_resolver_config
63+
from ClusterShell.NodeSet import NodeSet, NodeSetParseError, std_group_resolver
6464
from ClusterShell.Task import Task, task_self
6565

6666

@@ -793,18 +793,21 @@ def main():
793793
parser.add_option("-n", "--nostdin", action="store_true", dest="nostdin",
794794
help="don't watch for possible input from stdin")
795795

796-
parser.install_config_options('clush.conf(5)')
796+
parser.install_groupsconf_option()
797+
parser.install_clush_config_options()
797798
parser.install_nodes_options()
798799
parser.install_display_options(verbose_options=True)
799800
parser.install_filecopy_options()
800801
parser.install_connector_options()
801802

802803
(options, args) = parser.parse_args()
803804

805+
set_std_group_resolver_config(options.groupsconf)
806+
804807
#
805808
# Load config file and apply overrides
806809
#
807-
config = ClushConfig(options)
810+
config = ClushConfig(options, options.conf)
808811

809812
# Initialize logging
810813
if config.verbosity >= VERB_DEBUG:

0 commit comments

Comments
 (0)