@@ -107,6 +107,8 @@ Performance Computing) or with large server farms. This section explains how
107107to configure node group **sources **. Please see also :ref: `nodeset node groups
108108<nodeset-groups>` for specific usage examples.
109109
110+ .. _groups_config_conf :
111+
110112groups.conf
111113^^^^^^^^^^^
112114
@@ -132,7 +134,7 @@ other node set operations will still work.
132134
133135*groups.conf * defines configuration sub-directories, but may also define
134136source definitions by itself. These **sources ** provide external calls that
135- are detailed in :ref: `group-sources-upcalls `.
137+ are detailed in :ref: `group-external-sources `.
136138
137139The following example shows the content of a *groups.conf * file where node
138140groups are bound to the source named *genders * by default::
@@ -186,51 +188,94 @@ The *groups.conf* files are parsed with Python's `ConfigParser`_:
186188 map, all, list and reverse upcalls are explained below in
187189 :ref: `group-sources-upcalls `.
188190
189- .. _group-multi-sources :
191+ .. _group-file-based :
190192
191- Multiple sources section
193+ File-based group sources
192194^^^^^^^^^^^^^^^^^^^^^^^^
193195
194- Use a comma-separated list of source names in the section header if you want
195- to define multiple group sources with similar upcall commands. The special
196- variable ` $SOURCE ` is always replaced by the source name before command
197- execution (here ` cluster `, ` racks ` and ` cpu `), for example::
196+ Version 1.7 introduces support for native handling of flat files with
197+ different group sources to avoid the use of external upcalls for such static
198+ configuration. This can be achieved through the * autodir * feature and YAML
199+ files described below.
198200
199- [cluster,racks,cpu]
200- map: get_nodes_from_source.sh $SOURCE $GROUP
201- all: get_all_nodes_from_source.sh $SOURCE
202- list: list_nodes_from_source.sh $SOURCE
201+ YAML group files
202+ """"""""""""""""
203203
204- is equivalent to::
204+ Cluster node groups can be defined in straightforward YAML files. In such a
205+ file, each YAML dictionary defines group to nodes mapping. **Different
206+ dictionaries ** are handled as **different group sources **.
205207
206- [cluster]
207- map: get_nodes_from_source.sh cluster $GROUP
208- all: get_all_nodes_from_source.sh cluster
209- list: list_nodes_from_source.sh cluster
208+ For compatibility reasons with previous versions of ClusterShell, this is not
209+ the default way to define node groups yet. So here are the steps needed to try
210+ this out:
210211
211- [racks]
212- map: get_nodes_from_source.sh racks $GROUP
213- all: get_all_nodes_from_source.sh racks
214- list: list_nodes_from_source.sh racks
212+ Rename the following file::
215213
216- [cpu]
217- map: get_nodes_from_source.sh cpu $GROUP
218- all: get_all_nodes_from_source.sh cpu
219- list: list_nodes_from_source.sh cpu
214+ /etc/clustershell/groups.d/cluster.yaml.example
220215
221- Please note that single flat files with several sections acting as different
222- group sources are supported through the *autodir * feature based on YAML files.
223- An example of such configuration is available at::
216+ to a file having the **.yaml ** extension, for example::
224217
225- /etc/clustershell/groups.d/cluster.yaml.example
218+ /etc/clustershell/groups.d/cluster.yaml
219+
220+
221+ Ensure that *autodir * is set in :ref: `groups_config_conf `::
222+
223+ autodir: /etc/clustershell/groups.d $CFGDIR/groups.d
224+
225+ In the following example, we also changed the default group source
226+ to **roles ** in :ref: `groups_config_conf ` (the first dictionary defined in
227+ the example), so that *@roles:groupname * can just be shorted *@groupname *.
228+
229+ .. highlight :: yaml
230+
231+ Here is an example of **/etc/clustershell/groups.d/cluster.yaml **::
232+
233+ roles:
234+ adm: 'mgmt[1-2]' # define groups @roles:adm and @adm
235+ login: 'login[1-2]'
236+ compute: 'node[0001-0288]'
237+ gpu: 'node[0001-0008]'
238+
239+ cpu_only: '@compute!@gpu' # example of inline set operation
240+ # define group @cpu_only with node[0009-0288]
241+
242+ storage: '@lustre:mds,@lustre:oss' # example of external source reference
243+
244+ all: '@login,@compute,@storage' # special group used for clush/nodeset -a
245+ # only needed if not including all groups
226246
227- Just rename it to ``cluster.yaml `` and be sure that *autodir * is set to enable
228- it. Feel free to edit this file to fit your needs.
247+ lustre:
248+ mds: 'mds[1-4]'
249+ oss: 'oss[0-15]'
250+ rbh: 'rbh[1-2]'
251+
252+ .. highlight :: console
253+
254+ Testing the syntax of your group file can be quickly performed through the
255+ ``-L `` or ``--list-all `` command of :ref: `nodeset-tool `::
256+
257+ $ nodeset -LL
258+ @adm mgmt[1-2]
259+ @all login[1-2],mds[1-4],node[0001-0288],oss[0-15],rbh[1-2]
260+ @compute node[0001-0288]
261+ @cpu_only node[0009-0288]
262+ @gpu node[0001-0008]
263+ @login login[1-2]
264+ @storage mds[1-4],oss[0-15],rbh[1-2]
265+ @sysgrp sysgrp[1-4]
266+ @lustre:mds mds[1-4]
267+ @lustre:oss oss[0-15]
268+ @lustre:rbh rbh[1-2]
269+
270+ .. _group-external-sources :
271+
272+ External group sources
273+ ^^^^^^^^^^^^^^^^^^^^^^
229274
230275.. _group-sources-upcalls :
231276
232277Group source upcalls
233- ^^^^^^^^^^^^^^^^^^^^
278+ """"""""""""""""""""
234279
235280Each node group source is defined by a section name (*source * name) and up to
236281four upcalls:
@@ -241,7 +286,9 @@ four upcalls:
241286* **all **: Optional external shell command that should return a node set, list
242287 of nodes or list of node sets of all nodes for this group source. If not
243288 specified, the library will try to resolve all nodes by using the **list **
244- external command in the same group source followed by **map ** for each available group.
289+ external command in the same group source followed by **map ** for each
290+ available group. The notion of *all nodes * is used by ``clush -a `` and also
291+ by the special group name ``@* `` (or ``@source:* ``).
245292* **list **: Optional external shell command that should return the list of all
246293 groups for this group source (separated by space characters or by carriage
247294 returns). If this upcall is not specified, ClusterShell won't be able to
@@ -260,12 +307,43 @@ above, the two following variables are always available and also replaced
260307before executing shell commands:
261308
262309* *$CFGDIR * is replaced by *groups.conf * base directory path
263- * *$SOURCE * is replaced by current source name
310+ * *$SOURCE * is replaced by current source name (see an usage example just
311+ below)
312+
313+ Multiple sources section
314+ """"""""""""""""""""""""
315+
316+ .. highlight :: ini
264317
265- Please see :ref: `group-multi-sources ` for a particular use of *$SOURCE *.
318+ Use a comma-separated list of source names in the section header if you want
319+ to define multiple group sources with similar upcall commands. The special
320+ variable `$SOURCE ` is always replaced by the source name before command
321+ execution (here `cluster `, `racks ` and `cpu `), for example::
322+
323+ [cluster,racks,cpu]
324+ map: get_nodes_from_source.sh $SOURCE $GROUP
325+ all: get_all_nodes_from_source.sh $SOURCE
326+ list: list_nodes_from_source.sh $SOURCE
327+
328+ is equivalent to::
329+
330+ [cluster]
331+ map: get_nodes_from_source.sh cluster $GROUP
332+ all: get_all_nodes_from_source.sh cluster
333+ list: list_nodes_from_source.sh cluster
334+
335+ [racks]
336+ map: get_nodes_from_source.sh racks $GROUP
337+ all: get_all_nodes_from_source.sh racks
338+ list: list_nodes_from_source.sh racks
339+
340+ [cpu]
341+ map: get_nodes_from_source.sh cpu $GROUP
342+ all: get_all_nodes_from_source.sh cpu
343+ list: list_nodes_from_source.sh cpu
266344
267345Return code of external calls
268- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
346+ """""""""""""""""""""""""""""
269347
270348Each external command might return a non-zero return code when the operation
271349is not doable. But if the call return zero, for instance, for a non-existing
0 commit comments