| 1 |
.. _cluset-tool: |
| 2 |
|
| 3 |
cluset |
| 4 |
------ |
| 5 |
|
| 6 |
.. highlight:: console |
| 7 |
|
| 8 |
.. note:: The **cluset** command is introduced in ClusterShell version 1.7.3 as |
| 9 |
an alternative to the :ref:`nodeset-tool` command to avoid conflicts |
| 10 |
with the **nodeset** command from xCAT. Users are encouraged to |
| 11 |
transition to using **cluset** for their range/node/group set |
| 12 |
management tasks. |
| 13 |
|
| 14 |
The *cluset* command enables easy manipulation of node and range sets, as |
| 15 |
well as node groups, at the command line level. As it is user-friendly and |
| 16 |
efficient, the *cluset* command can quickly improve traditional cluster |
| 17 |
shell scripts. It is also full-featured as it provides most of the |
| 18 |
:class:`.NodeSet` and :class:`.RangeSet` class methods (see also |
| 19 |
:ref:`class-NodeSet`, and :ref:`class-RangeSet`). |
| 20 |
|
| 21 |
Most of the examples in this section are using simple indexed node sets, |
| 22 |
however, *cluset* supports multidimensional node sets, like |
| 23 |
``dc[1-2]n[1-99]``, introduced in version 1.7 (see :ref:`class-RangeSetND` |
| 24 |
for more info). |
| 25 |
|
| 26 |
This section will guide you through the basics and also more advanced features |
| 27 |
of *cluset*. |
| 28 |
|
| 29 |
.. _cluset-commands: |
| 30 |
|
| 31 |
Usage basics |
| 32 |
^^^^^^^^^^^^ |
| 33 |
|
| 34 |
One exclusive command must be specified to *cluset*, for example:: |
| 35 |
|
| 36 |
$ cluset --expand node[13-15,17-19] |
| 37 |
node13 node14 node15 node17 node18 node19 |
| 38 |
|
| 39 |
$ cluset --count node[13-15,17-19] |
| 40 |
6 |
| 41 |
|
| 42 |
$ cluset --fold node1-ipmi node2-ipmi node3-ipmi |
| 43 |
node[1-3]-ipmi |
| 44 |
|
| 45 |
|
| 46 |
.. _cluset-stdin: |
| 47 |
|
| 48 |
Commands with inputs |
| 49 |
"""""""""""""""""""" |
| 50 |
|
| 51 |
Some *cluset* commands require input (e.g. node names, node sets or node |
| 52 |
groups), and some only give output. The following table shows commands that |
| 53 |
require some input: |
| 54 |
|
| 55 |
+-------------------+--------------------------------------------------------+ |
| 56 |
| Command | Description | |
| 57 |
+===================+========================================================+ |
| 58 |
| ``-c``, | Count and display the total number of nodes in node | |
| 59 |
| ``--count`` | sets or/and node groups. | |
| 60 |
+-------------------+--------------------------------------------------------+ |
| 61 |
| ``-e``, | Expand node sets or/and node groups as unitary node | |
| 62 |
| ``--expand`` | names separated by current separator string (see | |
| 63 |
| | ``--separator`` option described in | |
| 64 |
| | :ref:`cluset-commands-formatting`). | |
| 65 |
+-------------------+--------------------------------------------------------+ |
| 66 |
| ``-f``, | Fold (compact) node sets or/and node groups into one | |
| 67 |
| ``--fold`` | set of nodes (by previously resolving any groups). The | |
| 68 |
| | resulting node set is guaranteed to be free from node | |
| 69 |
| | groups (see ``--regroup`` below if you want to resolve | |
| 70 |
| | node groups in result). Please note that folding may | |
| 71 |
| | be time consuming for multidimensional node sets. | |
| 72 |
+-------------------+--------------------------------------------------------+ |
| 73 |
| ``-r``, | Fold (compact) node sets or/and node groups into one | |
| 74 |
| ``--regroup`` | set of nodes using node groups whenever possible (by | |
| 75 |
| | previously resolving any groups). | |
| 76 |
| | See :ref:`cluset-groups`. | |
| 77 |
+-------------------+--------------------------------------------------------+ |
| 78 |
|
| 79 |
|
| 80 |
There are three ways to give some input to the *cluset* command: |
| 81 |
|
| 82 |
* from command line arguments, |
| 83 |
* from standard input (enabled when no arguments are found on command line), |
| 84 |
* from both command line and standard input, by using the dash special |
| 85 |
argument ``-`` meaning you need to use stdin instead. |
| 86 |
|
| 87 |
The following example illustrates the three ways to feed *cluset*:: |
| 88 |
|
| 89 |
$ cluset -f node1 node6 node7 |
| 90 |
node[1,6-7] |
| 91 |
|
| 92 |
$ echo node1 node6 node7 | cluset -f |
| 93 |
node[1,6-7] |
| 94 |
|
| 95 |
$ echo node1 node6 node7 | cluset -f node0 - |
| 96 |
node[0-1,6-7] |
| 97 |
|
| 98 |
|
| 99 |
Furthermore, *cluset*'s standard input reader is able to process multiple |
| 100 |
lines and multiple node sets or groups per line. The following example shows a |
| 101 |
simple use case:: |
| 102 |
|
| 103 |
$ mount -t nfs | cut -d':' -f1 |
| 104 |
nfsserv1 |
| 105 |
nfsserv2 |
| 106 |
nfsserv3 |
| 107 |
|
| 108 |
$ mount -t nfs | cut -d':' -f1 | cluset -f |
| 109 |
nfsserv[1-3] |
| 110 |
|
| 111 |
|
| 112 |
Other usage examples of *cluset* below show how it can be useful to provide |
| 113 |
node sets from standard input (*sinfo* is a Slurm [#]_ command to view nodes |
| 114 |
and partitions information and *sacct* is a command to display Slurm |
| 115 |
accounting data):: |
| 116 |
|
| 117 |
$ sinfo -p cuda -o '%N' -h |
| 118 |
node[156-159] |
| 119 |
|
| 120 |
$ sinfo -p cuda -o '%N' -h | cluset -e |
| 121 |
node156 node157 node158 node159 |
| 122 |
|
| 123 |
$ for node in $(sinfo -p cuda -o '%N' -h | cluset -e); do |
| 124 |
sacct -a -N $node > /tmp/cudajobs.$node; |
| 125 |
done |
| 126 |
|
| 127 |
Previous rules also apply when working with node groups, for example when |
| 128 |
using ``cluset -r`` reading from standard input (and a matching group is |
| 129 |
found):: |
| 130 |
|
| 131 |
$ cluset -f @gpu |
| 132 |
node[156-159] |
| 133 |
|
| 134 |
$ sinfo -p cuda -o '%N' -h | cluset -r |
| 135 |
@gpu |
| 136 |
|
| 137 |
Most commands described in this section produce output results that may be |
| 138 |
formatted using ``--output-format`` and ``--separator`` which are described in |
| 139 |
:ref:`cluset-commands-formatting`. |
| 140 |
|
| 141 |
Commands with no input |
| 142 |
"""""""""""""""""""""" |
| 143 |
|
| 144 |
The following table shows all other commands that are supported by |
| 145 |
*cluset*. These commands don't support any input (like node sets), but can |
| 146 |
still recognize options as specified below. |
| 147 |
|
| 148 |
+--------------------+-----------------------------------------------------+ |
| 149 |
| Command w/o input | Description | |
| 150 |
+====================+=====================================================+ |
| 151 |
| ``-l``, ``--list`` | List node groups from selected *group source* as | |
| 152 |
| | specified with ``-s`` or ``--groupsource``. If | |
| 153 |
| | not specified, node groups from the default *group | |
| 154 |
| | source* are listed (see :ref:`groups configuration | |
| 155 |
| | <groups-config>` for default *group source* | |
| 156 |
| | configuration). | |
| 157 |
+--------------------+-----------------------------------------------------+ |
| 158 |
| ``--list-sources`` | List all configured *group sources*, one per line, | |
| 159 |
| | as configured in *groups.conf* (see | |
| 160 |
| | :ref:`groups configuration <groups-config>`). | |
| 161 |
| | The default *group source* is appended with | |
| 162 |
| | `` (default)``, unless the ``-q``, ``--quiet`` | |
| 163 |
| | option is specified. This command is mainly here to | |
| 164 |
| | avoid reading any configuration files, or to check | |
| 165 |
| | if all work fine when configuring *group sources*. | |
| 166 |
| | Also available as ``--groupsources``. | |
| 167 |
+--------------------+-----------------------------------------------------+ |
| 168 |
|
| 169 |
.. _cluset-commands-formatting: |
| 170 |
|
| 171 |
Output result formatting |
| 172 |
"""""""""""""""""""""""" |
| 173 |
|
| 174 |
When using the expand command (``-e, --expand``), a separator string is used |
| 175 |
when displaying results. The option ``-S``, ``--separator`` allows you to |
| 176 |
modify it. The specified string is interpreted, so that you can use special |
| 177 |
characters as separator, like ``\n`` or ``\t``. The default separator is the |
| 178 |
space character *" "*. This is an example showing such separator string |
| 179 |
change:: |
| 180 |
|
| 181 |
$ cluset -e --separator='\n' node[0-3] |
| 182 |
node0 |
| 183 |
node1 |
| 184 |
node2 |
| 185 |
node3 |
| 186 |
|
| 187 |
The ``-O, --output-format`` option can be used to format output results of |
| 188 |
most *cluset* commands. The string passed to this option is used as a base |
| 189 |
format pattern applied to each node or each result (depending on the command |
| 190 |
and other options requested). The default format string is *"%s"*. Formatting |
| 191 |
is performed using the Python builtin string formatting operator, so you must |
| 192 |
use one format operator of the right type (*%s* is guaranteed to work in all |
| 193 |
cases). Here is an output formatting example when using the expand command:: |
| 194 |
|
| 195 |
$ cluset --output-format='%s-ipmi' -e node[1-2]x[1-2] |
| 196 |
node1x1-ipmi node1x2-ipmi node2x1-ipmi node2x2-ipmi |
| 197 |
|
| 198 |
Output formatting and separator combined can be useful when using the expand |
| 199 |
command, as shown here:: |
| 200 |
|
| 201 |
$ cluset -O '%s-ipmi' -S '\n' -e node[1-2]x[1-2] |
| 202 |
node1x1-ipmi |
| 203 |
node1x2-ipmi |
| 204 |
node2x1-ipmi |
| 205 |
node2x2-ipmi |
| 206 |
|
| 207 |
When using the output formatting option along with the folding command, the |
| 208 |
format is applied to each node but the result is still folded:: |
| 209 |
|
| 210 |
$ cluset -O '%s-ipmi' -f mgmt1 mgmt2 login[1-4] |
| 211 |
login[1-4]-ipmi,mgmt[1-2]-ipmi |
| 212 |
|
| 213 |
|
| 214 |
.. _cluset-stepping: |
| 215 |
|
| 216 |
Stepping and auto-stepping |
| 217 |
^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 218 |
|
| 219 |
The *cluset* command, as does the *clush* command, is able to recognize by |
| 220 |
default a factorized notation for range sets of the form *a-b/c*, indicating a |
| 221 |
list of integers starting from *a*, less than or equal to *b* with the |
| 222 |
increment (step) *c*. |
| 223 |
|
| 224 |
For example, the *0-6/2* format indicates a range of 0-6 stepped by 2; that |
| 225 |
is 0,2,4,6:: |
| 226 |
|
| 227 |
$ cluset -e node[0-6/2] |
| 228 |
node0 node2 node4 node6 |
| 229 |
|
| 230 |
However, by default, *cluset* never uses this stepping notation in output |
| 231 |
results, as other cluster tools seldom if ever support this feature. Thus, to |
| 232 |
enable such factorized output in *cluset*, you must specify |
| 233 |
``--autostep=AUTOSTEP`` to set an auto step threshold number when folding |
| 234 |
nodesets (i.e. when using ``-f`` or ``-r``). This threshold number |
| 235 |
(AUTOSTEP) is the minimum occurrence of equally-spaced integers needed to |
| 236 |
enable auto-stepping. |
| 237 |
|
| 238 |
For example:: |
| 239 |
|
| 240 |
$ cluset -f --autostep=3 node1 node3 node5 |
| 241 |
node[1-5/2] |
| 242 |
|
| 243 |
$ cluset -f --autostep=4 node1 node3 node5 |
| 244 |
node[1,3,5] |
| 245 |
|
| 246 |
It is important to note that resulting node sets with enabled auto-stepping |
| 247 |
never create overlapping ranges, for example:: |
| 248 |
|
| 249 |
$ cluset -f --autostep=3 node1 node5 node9 node13 |
| 250 |
node[1-13/4] |
| 251 |
|
| 252 |
$ cluset -f --autostep=3 node1 node5 node7 node9 node13 |
| 253 |
node[1,5-9/2,13] |
| 254 |
|
| 255 |
However, any ranges given as input may still overlap (in this case, *cluset* |
| 256 |
will automatically spread them out so that they do not overlap), for example:: |
| 257 |
|
| 258 |
$ cluset -f --autostep=3 node[1-13/4,7] |
| 259 |
node[1,5-9/2,13] |
| 260 |
|
| 261 |
|
| 262 |
A minimum node count threshold **percentage** before autostep is enabled may |
| 263 |
also be specified as autostep value (or ``auto`` which is currently 100%). In |
| 264 |
the two following examples, only the first 4 of the 7 indexes may be |
| 265 |
represented using the step syntax (57% of them):: |
| 266 |
|
| 267 |
$ cluset -f --autostep=50% node[1,3,5,7,34,39,99] |
| 268 |
node[1-7/2,34,39,99] |
| 269 |
|
| 270 |
$ cluset -f --autostep=90% node[1,3,5,7,34,39,99] |
| 271 |
node[1,3,5,7,34,39,99] |
| 272 |
|
| 273 |
|
| 274 |
.. _cluset-zeropadding: |
| 275 |
|
| 276 |
Zero-padding |
| 277 |
^^^^^^^^^^^^ |
| 278 |
|
| 279 |
Sometimes, cluster node names are padded with zeros (e.g. *node007*). With |
| 280 |
*cluset*, when leading zeros are used, resulting host names or node sets |
| 281 |
are automatically padded with zeros as well. For example:: |
| 282 |
|
| 283 |
$ cluset -e node[08-11] |
| 284 |
node08 node09 node10 node11 |
| 285 |
|
| 286 |
$ cluset -f node001 node002 node003 node005 |
| 287 |
node[001-003,005] |
| 288 |
|
| 289 |
Zero-padding and stepping (as seen in :ref:`cluset-stepping`) together are |
| 290 |
also supported, for example:: |
| 291 |
|
| 292 |
$ cluset -e node[000-012/4] |
| 293 |
node000 node004 node008 node012 |
| 294 |
|
| 295 |
Since v1.9, mixed length padding is allowed, for example:: |
| 296 |
|
| 297 |
$ cluset -f node2 node01 node001 |
| 298 |
node[2,01,001] |
| 299 |
|
| 300 |
When mixed length zero-padding is encountered, indexes with smaller padding |
| 301 |
length are returned first, as you can see in the example above (``2`` comes |
| 302 |
before ``01``). |
| 303 |
|
| 304 |
Since v1.9, when using node sets with multiple dimensions, each dimension (or |
| 305 |
axis) may also use mixed length zero-padding:: |
| 306 |
|
| 307 |
$ cluset -f foo1bar1 foo1bar00 foo1bar01 foo004bar1 foo004bar00 foo004bar01 |
| 308 |
foo[1,004]bar[1,00-01] |
| 309 |
|
| 310 |
|
| 311 |
Leading and trailing digits |
| 312 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 313 |
|
| 314 |
Version 1.7 introduces improved support for bracket leading and trailing |
| 315 |
digits. Those digits are automatically included within the range set, |
| 316 |
allowing all node set operations to be fully supported. |
| 317 |
|
| 318 |
Examples with bracket leading digits:: |
| 319 |
|
| 320 |
$ cluset -f node-00[00-99] |
| 321 |
node-[0000-0099] |
| 322 |
|
| 323 |
$ cluset -f node-01[01,09,42] |
| 324 |
node-[0101,0109,0142] |
| 325 |
|
| 326 |
Examples with bracket trailing digits:: |
| 327 |
|
| 328 |
$ cluset -f node-[1-2]0-[0-2]5 |
| 329 |
node-[10,20]-[05,15,25] |
| 330 |
|
| 331 |
Examples with both bracket leading and trailing digits:: |
| 332 |
|
| 333 |
$ cluset -f node-00[1-6]0 |
| 334 |
node-[0010,0020,0030,0040,0050,0060] |
| 335 |
|
| 336 |
$ cluset --autostep=auto -f node-00[1-6]0 |
| 337 |
node-[0010-0060/10] |
| 338 |
|
| 339 |
Example with leading digit and mixed length zero padding (supported since |
| 340 |
v1.9):: |
| 341 |
|
| 342 |
$ cluset -f node1[00-02,000-032/8] |
| 343 |
node[100-102,1000,1008,1016,1024,1032] |
| 344 |
|
| 345 |
Using this syntax can be error-prone especially if used with node sets |
| 346 |
without 0-padding or with the */step* syntax and also requires additional |
| 347 |
processing by the parser. In general, we recommend writing the whole rangeset |
| 348 |
inside the brackets. |
| 349 |
|
| 350 |
.. warning:: Using the step syntax (seen above) within a bracket-delimited |
| 351 |
range set is not compatible with **trailing** digits. For instance, this is |
| 352 |
**not** supported: ``node-00[1-6/2]0`` |
| 353 |
|
| 354 |
.. _cluset-arithmetic: |
| 355 |
|
| 356 |
Arithmetic operations |
| 357 |
^^^^^^^^^^^^^^^^^^^^^ |
| 358 |
|
| 359 |
As a preamble to this section, keep in mind that all operations can be |
| 360 |
repeated/mixed within the same *cluset* command line, they will be |
| 361 |
processed from left to right. |
| 362 |
|
| 363 |
Union operation |
| 364 |
""""""""""""""" |
| 365 |
|
| 366 |
Union is the easiest arithmetic operation supported by *cluset*: there is |
| 367 |
no special command line option for that, just provide several node sets and |
| 368 |
the union operation will be computed, for example:: |
| 369 |
|
| 370 |
$ cluset -f node[1-3] node[4-7] |
| 371 |
node[1-7] |
| 372 |
|
| 373 |
$ cluset -f node[1-3] node[2-7] node[5-8] |
| 374 |
node[1-8] |
| 375 |
|
| 376 |
Other operations |
| 377 |
"""""""""""""""" |
| 378 |
|
| 379 |
As an extension to the above, other arithmetic operations are available by |
| 380 |
using the following command-line options (*working set* is the node set |
| 381 |
currently processed on the command line -- always from left to right): |
| 382 |
|
| 383 |
+--------------------------------------------+---------------------------------+ |
| 384 |
| *cluset* command option | Operation | |
| 385 |
+============================================+=================================+ |
| 386 |
| ``-x NODESET``, ``--exclude=NODESET`` | compute a new set with elements | |
| 387 |
| | in *working set* but not in | |
| 388 |
| | ``NODESET`` | |
| 389 |
+--------------------------------------------+---------------------------------+ |
| 390 |
| ``-i NODESET``, ``--intersection=NODESET`` | compute a new set with elements | |
| 391 |
| | common to *working set* and | |
| 392 |
| | ``NODESET`` | |
| 393 |
+--------------------------------------------+---------------------------------+ |
| 394 |
| ``-X NODESET``, ``--xor=NODESET`` | compute a new set with elements | |
| 395 |
| | that are in exactly one of the | |
| 396 |
| | *working set* and ``NODESET`` | |
| 397 |
+--------------------------------------------+---------------------------------+ |
| 398 |
|
| 399 |
|
| 400 |
If rangeset mode (``-R``) is turned on, all arithmetic operations are |
| 401 |
supported by replacing ``NODESET`` by any ``RANGESET``. See |
| 402 |
:ref:`cluset-rangeset` for more info about *cluset*'s rangeset mode. |
| 403 |
|
| 404 |
|
| 405 |
Arithmetic operations usage examples:: |
| 406 |
|
| 407 |
$ cluset -f node[1-9] -x node6 |
| 408 |
node[1-5,7-9] |
| 409 |
|
| 410 |
$ cluset -f node[1-9] -i node[6-11] |
| 411 |
node[6-9] |
| 412 |
|
| 413 |
$ cluset -f node[1-9] -X node[6-11] |
| 414 |
node[1-5,10-11] |
| 415 |
|
| 416 |
$ cluset -f node[1-9] -x node6 -i node[6-12] |
| 417 |
node[7-9] |
| 418 |
|
| 419 |
.. _cluset-extended-patterns: |
| 420 |
|
| 421 |
*Extended patterns* support |
| 422 |
""""""""""""""""""""""""""" |
| 423 |
|
| 424 |
*cluset* does also support arithmetic operations through its "extended |
| 425 |
patterns" (inherited from :class:`.NodeSet` extended pattern feature, see |
| 426 |
:ref:`class-NodeSet-extended-patterns`), here is an example of use:: |
| 427 |
|
| 428 |
$ cluset -f node[1-4],node[5-9] |
| 429 |
node[1-9] |
| 430 |
|
| 431 |
$ cluset -f node[1-9]\!node6 |
| 432 |
node[1-5,7-9] |
| 433 |
|
| 434 |
$ cluset -f node[1-9]\&node[6-12] |
| 435 |
node[6-9] |
| 436 |
|
| 437 |
$ cluset -f node[1-9]^node[6-11] |
| 438 |
node[1-5,10-11] |
| 439 |
|
| 440 |
.. _cluset-special: |
| 441 |
|
| 442 |
Special operations |
| 443 |
^^^^^^^^^^^^^^^^^^ |
| 444 |
|
| 445 |
A few special operations are currently available: node set slicing, splitting |
| 446 |
on a predefined node count, splitting non-contiguous subsets, choosing fold |
| 447 |
axis (for multidimensional node sets) and picking N nodes randomly. They are |
| 448 |
all explained below. |
| 449 |
|
| 450 |
.. _cluset-slice: |
| 451 |
|
| 452 |
Slicing |
| 453 |
""""""" |
| 454 |
|
| 455 |
Slicing is a way to select elements from a node set by their index (or from a |
| 456 |
range set when using ``-R`` toggle option, see :ref:`cluset-rangeset`). In |
| 457 |
this case actually, and because *cluset*'s underlying :class:`.NodeSet` class |
| 458 |
sorts elements as observed after folding (for example), the word *set* may |
| 459 |
sound like a stretch of language (a *set* isn't usually sorted). Indeed, |
| 460 |
:class:`.NodeSet` further guarantees that its iterator will traverse the set |
| 461 |
in order, so we should see it as an *ordered set*. The following simple example |
| 462 |
illustrates this sorting behavior:: |
| 463 |
|
| 464 |
$ cluset -f b2 b1 b0 b c a0 a |
| 465 |
a,a0,b,b[0-2],c |
| 466 |
|
| 467 |
Slicing is performed through the following command-line option: |
| 468 |
|
| 469 |
+---------------------------------------+-----------------------------------+ |
| 470 |
| *cluset* command option | Operation | |
| 471 |
+=======================================+===================================+ |
| 472 |
| ``-I RANGESET``, ``--slice=RANGESET`` | *slicing*: get sliced off result, | |
| 473 |
| | selecting elements from provided | |
| 474 |
| | rangeset's indexes | |
| 475 |
+---------------------------------------+-----------------------------------+ |
| 476 |
|
| 477 |
Some slicing examples are shown below:: |
| 478 |
|
| 479 |
$ cluset -f -I 0 node[4-8] |
| 480 |
node4 |
| 481 |
|
| 482 |
$ cluset -f --slice=0 bnode[0-9] anode[0-9] |
| 483 |
anode0 |
| 484 |
|
| 485 |
$ cluset -f --slice=1,4,7,9,15 bnode[0-9] anode[0-9] |
| 486 |
anode[1,4,7,9],bnode5 |
| 487 |
|
| 488 |
$ cluset -f --slice=0-18/2 bnode[0-9] anode[0-9] |
| 489 |
anode[0,2,4,6,8],bnode[0,2,4,6,8] |
| 490 |
|
| 491 |
|
| 492 |
.. _cluset-splitting-n: |
| 493 |
|
| 494 |
Splitting into *n* subsets |
| 495 |
"""""""""""""""""""""""""" |
| 496 |
|
| 497 |
Splitting a node set into several parts is often useful to get separate groups |
| 498 |
of nodes, for instance when you want to check MPI comm between nodes, etc. |
| 499 |
Based on :meth:`.NodeSet.split` method, the *cluset* command provides the |
| 500 |
following additional command-line option (since v1.4): |
| 501 |
|
| 502 |
+--------------------------+--------------------------------------------+ |
| 503 |
| *cluset* command option | Operation | |
| 504 |
+==========================+============================================+ |
| 505 |
| ``--split=MAXSPLIT`` | *splitting*: split result into a number of | |
| 506 |
| | subsets | |
| 507 |
+--------------------------+--------------------------------------------+ |
| 508 |
|
| 509 |
``MAXSPLIT`` is an integer specifying the number of separate groups of nodes |
| 510 |
to compute. Input's node set is divided into smaller groups, whenever possible |
| 511 |
with the same size (only the last ones may be smaller due to rounding). |
| 512 |
Obviously, if ``MAXSPLIT`` is higher than or equal to the number N of elements |
| 513 |
in the set, then the set is split to N single sets. |
| 514 |
|
| 515 |
Some node set splitting examples:: |
| 516 |
|
| 517 |
$ cluset -f --split=4 node[0-7] |
| 518 |
node[0-1] |
| 519 |
node[2-3] |
| 520 |
node[4-5] |
| 521 |
node[6-7] |
| 522 |
|
| 523 |
$ cluset -f --split=4 node[0-6] |
| 524 |
node[0-1] |
| 525 |
node[2-3] |
| 526 |
node[4-5] |
| 527 |
node6 |
| 528 |
|
| 529 |
$ cluset -f --split=10000 node[0-4] |
| 530 |
node0 |
| 531 |
node1 |
| 532 |
node2 |
| 533 |
node3 |
| 534 |
node4 |
| 535 |
|
| 536 |
$ cluset -f --autostep=3 --split=2 node[0-38/2] |
| 537 |
node[0-18/2] |
| 538 |
node[20-38/2] |
| 539 |
|
| 540 |
|
| 541 |
.. _cluset-splitting-contiguous: |
| 542 |
|
| 543 |
Splitting off non-contiguous subsets |
| 544 |
"""""""""""""""""""""""""""""""""""" |
| 545 |
|
| 546 |
It can be useful to split a node set into several contiguous subsets (with |
| 547 |
same pattern name and contiguous range indexes, e.g. *node[1-100]* or |
| 548 |
*dc[1-4]node[1-100]*). The ``--contiguous`` option allows you to do that. It |
| 549 |
is based on :meth:`.NodeSet.contiguous` method, and should be specified with |
| 550 |
standard commands (fold, expand, count, regroup). The following example shows |
| 551 |
how to split off non-contiguous subsets of a specified node set, and to |
| 552 |
display each resulting contiguous node set in a folded manner to separated |
| 553 |
lines:: |
| 554 |
|
| 555 |
$ cluset -f --contiguous node[1-100,200-300,500] |
| 556 |
node[1-100] |
| 557 |
node[200-300] |
| 558 |
node500 |
| 559 |
|
| 560 |
|
| 561 |
Similarly, the following example shows how to display each resulting |
| 562 |
contiguous node set in an expanded manner to separate lines:: |
| 563 |
|
| 564 |
$ cluset -e --contiguous node[1-9,11-19] |
| 565 |
node1 node2 node3 node4 node5 node6 node7 node8 node9 |
| 566 |
node11 node12 node13 node14 node15 node16 node17 node18 node19 |
| 567 |
|
| 568 |
|
| 569 |
Choosing fold axis (nD) |
| 570 |
""""""""""""""""""""""" |
| 571 |
|
| 572 |
The default folding behavior for multidimensional node sets is to fold along |
| 573 |
all *nD* axes. However, other cluster tools barely support nD nodeset syntax, |
| 574 |
so it may be useful to fold along one axis (or a few axes) only. The ``--axis`` |
| 575 |
option allows you to specify indexes of dimensions to fold. Using this |
| 576 |
option, rangesets of unspecified axes won't be folded. Please note |
| 577 |
however that the obtained result may be suboptimal, this is because |
| 578 |
:class:`.NodeSet` algorithms are optimized for folding along all axes. |
| 579 |
``--axis`` value is a set of integers from 1 to n representing selected nD |
| 580 |
axes, in the form of a number or a rangeset. A common case is to restrict |
| 581 |
folding on a single axis, like in the following simple examples:: |
| 582 |
|
| 583 |
$ cluset --axis=1 -f node1-ib0 node2-ib0 node1-ib1 node2-ib1 |
| 584 |
node[1-2]-ib0,node[1-2]-ib1 |
| 585 |
|
| 586 |
$ cluset --axis=2 -f node1-ib0 node2-ib0 node1-ib1 node2-ib1 |
| 587 |
node1-ib[0-1],node2-ib[0-1] |
| 588 |
|
| 589 |
Because a single nodeset may have several different dimensions, axis indices |
| 590 |
are silently truncated to fall in the allowed range. Negative indices are |
| 591 |
useful to fold along the last axis whatever number of dimensions used:: |
| 592 |
|
| 593 |
$ cluset --axis=-1 -f comp-[1-2]-[1-36],login-[1-2] |
| 594 |
comp-1-[1-36],comp-2-[1-36],login-[1-2] |
| 595 |
|
| 596 |
See also the :ref:`defaults-config-slurm` of Library Defaults for changing it |
| 597 |
permanently. |
| 598 |
|
| 599 |
.. _cluset-pick: |
| 600 |
|
| 601 |
Picking N node(s) at random |
| 602 |
""""""""""""""""""""""""""" |
| 603 |
|
| 604 |
Use ``--pick`` with a maximum number of nodes you wish to pick randomly from |
| 605 |
the resulting node set (or from the resulting range set with ``-R``):: |
| 606 |
|
| 607 |
$ cluset --pick=1 -f node11 node12 node13 |
| 608 |
node12 |
| 609 |
$ cluset --pick=2 -f node11 node12 node13 |
| 610 |
node[11,13] |
| 611 |
|
| 612 |
|
| 613 |
.. _cluset-index: |
| 614 |
|
| 615 |
Finding the index of a node |
| 616 |
""""""""""""""""""""""""""" |
| 617 |
|
| 618 |
The ``--index`` command is the reverse of :ref:`slicing <cluset-slice>`: |
| 619 |
instead of selecting a node by its position, it outputs the zero-based index |
| 620 |
of a node within the resulting (ordered) node set. It is the command-line |
| 621 |
equivalent of the :meth:`.NodeSet.index` method:: |
| 622 |
|
| 623 |
$ cluset --index node5 node[0-9] |
| 624 |
5 |
| 625 |
|
| 626 |
If the node is not part of the set, an error is printed and a non-zero exit |
| 627 |
status is returned, so ``--index`` can also be used to test set membership:: |
| 628 |
|
| 629 |
$ cluset --index node42 node[0-9] |
| 630 |
ERROR: 'node42' is not in nodeset |
| 631 |
|
| 632 |
It also works in range set mode with ``-R``:: |
| 633 |
|
| 634 |
$ cluset -R --index 18 1,5,18-31 |
| 635 |
2 |
| 636 |
|
| 637 |
The position follows the same ordering as ``-e/--expand``. Two aspects of that |
| 638 |
ordering are worth knowing, as both can be surprising. First, when a node set |
| 639 |
spans several distinct patterns (different name templates), the patterns are |
| 640 |
sorted alphabetically by name, not by the order they were written or by the |
| 641 |
numbers they contain:: |
| 642 |
|
| 643 |
$ cluset -e node[1-4],bmc[10-20] |
| 644 |
bmc10 bmc11 bmc12 bmc13 bmc14 bmc15 bmc16 bmc17 bmc18 bmc19 bmc20 node1 node2 node3 node4 |
| 645 |
$ cluset --index bmc10 node[1-4],bmc[10-20] |
| 646 |
0 |
| 647 |
$ cluset --index node1 node[1-4],bmc[10-20] |
| 648 |
11 |
| 649 |
|
| 650 |
Second, for multidimensional node sets, the set is traversed as a Cartesian |
| 651 |
product in which the last dimension varies fastest:: |
| 652 |
|
| 653 |
$ cluset -e rack[1-2]node[1-3] |
| 654 |
rack1node1 rack1node2 rack1node3 rack2node1 rack2node2 rack2node3 |
| 655 |
$ cluset --index rack2node1 rack[1-2]node[1-3] |
| 656 |
3 |
| 657 |
|
| 658 |
For a one-dimensional node set (for example ``node[01-04]``) the index is just |
| 659 |
the node's ascending numeric position. A multidimensional node set has no |
| 660 |
single obvious order, so ClusterShell flattens it using its own convention, |
| 661 |
which is not guaranteed across versions; do not rely on a given index over |
| 662 |
time. Within a version it is always deterministic and depends only on the |
| 663 |
set's contents. |
| 664 |
|
| 665 |
.. note:: |
| 666 |
|
| 667 |
``--index`` reflects ClusterShell's own ordering, so for a multidimensional |
| 668 |
node list it is not guaranteed to match the node rank a resource manager |
| 669 |
assigns (such as Slurm's ``$SLURM_NODEID``); use the value the resource |
| 670 |
manager provides instead. |
| 671 |
|
| 672 |
|
| 673 |
.. _cluset-groups: |
| 674 |
|
| 675 |
Node groups |
| 676 |
^^^^^^^^^^^ |
| 677 |
|
| 678 |
This section tackles the node groups feature available more particularly |
| 679 |
through the *cluset* command-line tool. The ClusterShell library defines a |
| 680 |
node groups syntax and allows you to bind these group sources to your |
| 681 |
applications (cf. :ref:`node groups configuration <groups-config>`). Having |
| 682 |
those group sources, group provisioning is easily done through user-defined |
| 683 |
external shell commands. Thus, node groups might be very dynamic and their |
| 684 |
nodes might change very often. However, for performance reasons, external call |
| 685 |
results are still cached in memory to avoid duplicate external calls during |
| 686 |
*cluset* execution. For example, a group source can be bound to a resource |
| 687 |
manager or a custom cluster database. |
| 688 |
|
| 689 |
For further details about using node groups in Python, please see |
| 690 |
:ref:`class-NodeSet-groups`. For advanced usage, you should also be able to |
| 691 |
define your own group source directly in Python (cf. |
| 692 |
:ref:`class-NodeSet-groups-override`). |
| 693 |
|
| 694 |
.. _cluset-groupsexpr: |
| 695 |
|
| 696 |
Node group expression rules |
| 697 |
""""""""""""""""""""""""""" |
| 698 |
|
| 699 |
The general node group expression is ``@source:groupname``. For example, |
| 700 |
``@slurm:bigmem`` represents the group *bigmem* of the group source *slurm*. |
| 701 |
Moreover, a shortened expression is available when using the default group |
| 702 |
source (defined by configuration); for instance ``@compute`` represents the |
| 703 |
*compute* group of the default group source. |
| 704 |
|
| 705 |
Valid group source names and group names can contain alphanumeric characters, |
| 706 |
hyphens and underscores (no space allowed). Indeed, same rules apply to node |
| 707 |
names. |
| 708 |
|
| 709 |
Listing group sources |
| 710 |
""""""""""""""""""""" |
| 711 |
|
| 712 |
As already mentioned, the following *cluset* command is available to list |
| 713 |
configured group sources and also display the default group source (unless |
| 714 |
``-q`` is provided). The ``--list-sources`` and ``--groupsources`` options |
| 715 |
are equivalent:: |
| 716 |
|
| 717 |
$ cluset --list-sources |
| 718 |
local (default) |
| 719 |
genders |
| 720 |
slurm |
| 721 |
|
| 722 |
Listing group names |
| 723 |
""""""""""""""""""" |
| 724 |
|
| 725 |
It is always possible to list the groups from a group source if the source is |
| 726 |
:ref:`file-based <group-file-based>`. |
| 727 |
If the source is an :ref:`external group source <group-external-sources>`, the |
| 728 |
**list** upcall must be configured (see also: |
| 729 |
:ref:`node groups configuration <groups-config>`). |
| 730 |
|
| 731 |
To list available groups *from the default source*, use the following command:: |
| 732 |
|
| 733 |
$ cluset -l |
| 734 |
@mgnt |
| 735 |
@mds |
| 736 |
@oss |
| 737 |
@login |
| 738 |
@compute |
| 739 |
|
| 740 |
To list groups *from a specific group source*, use *-l* in conjunction |
| 741 |
with *-s* (or *--groupsource*):: |
| 742 |
|
| 743 |
$ cluset -l -s slurm |
| 744 |
@slurm:parallel |
| 745 |
@slurm:cuda |
| 746 |
|
| 747 |
Or, to list groups *from all available group sources*, use *-L* (or |
| 748 |
*--list-all*):: |
| 749 |
|
| 750 |
$ cluset -L |
| 751 |
@mgnt |
| 752 |
@mds |
| 753 |
@oss |
| 754 |
@login |
| 755 |
@compute |
| 756 |
@slurm:parallel |
| 757 |
@slurm:cuda |
| 758 |
|
| 759 |
You can also use ``cluset -ll`` or ``cluset -LL`` to see each group's |
| 760 |
associated node sets. |
| 761 |
|
| 762 |
.. _cluset-rawgroupnames: |
| 763 |
|
| 764 |
Listing group names in expressions |
| 765 |
"""""""""""""""""""""""""""""""""" |
| 766 |
|
| 767 |
ClusterShell 1.9 introduces a new operator **@@** optionally followed by a |
| 768 |
source name (e.g. **@@source**) to access the list of *raw group names* of |
| 769 |
the source (without the **@** prefix). If no source is specified (as in *just* |
| 770 |
**@@**), the default group source is used (see :ref:`groups_config_conf`). |
| 771 |
The **@@** operator may be used in any node set expression to manipulate group |
| 772 |
names as a node set. |
| 773 |
|
| 774 |
Example with the default group source:: |
| 775 |
|
| 776 |
$ cluset -l |
| 777 |
@mgnt |
| 778 |
@mds |
| 779 |
@oss |
| 780 |
@login |
| 781 |
@compute |
| 782 |
|
| 783 |
$ cluset -e @@ |
| 784 |
compute login mds mgnt oss |
| 785 |
|
| 786 |
Example with a group source "rack" that defines group names from rack |
| 787 |
locations in a data center:: |
| 788 |
|
| 789 |
$ cluset -l -s rack |
| 790 |
@rack:J1 |
| 791 |
@rack:J2 |
| 792 |
@rack:J3 |
| 793 |
|
| 794 |
$ cluset -f @@rack |
| 795 |
J[1-3] |
| 796 |
|
| 797 |
A set of valid, indexed group sources is also accepted by the **@@** operator |
| 798 |
(e.g. **@@dc[1-3]**). |
| 799 |
|
| 800 |
|
| 801 |
.. warning:: An error is generated when using **@@** in an expression if the |
| 802 |
source is not valid (e.g. invalid name, not configured or upcalls |
| 803 |
not currently working). |
| 804 |
|
| 805 |
|
| 806 |
Using node groups in basic commands |
| 807 |
""""""""""""""""""""""""""""""""""" |
| 808 |
|
| 809 |
The use of node groups with the *cluset* command is very straightforward. |
| 810 |
Indeed, any group name, prefixed by **@** as mentioned above, can be used in |
| 811 |
lieu of a node name, where it will be substituted for all nodes in that group. |
| 812 |
|
| 813 |
A first, simple example is a group expansion (using default source) with |
| 814 |
*cluset*:: |
| 815 |
|
| 816 |
$ cluset -e @oss |
| 817 |
node40 node41 node42 node43 node44 node45 |
| 818 |
|
| 819 |
The *cluset* count command works as expected:: |
| 820 |
|
| 821 |
$ cluset -c @oss |
| 822 |
6 |
| 823 |
|
| 824 |
Also *cluset* folding command can always resolve node groups:: |
| 825 |
|
| 826 |
$ cluset -f @oss |
| 827 |
node[40-45] |
| 828 |
|
| 829 |
There are usually two ways to use a specific group source (need to be properly |
| 830 |
configured):: |
| 831 |
|
| 832 |
$ cluset -f @slurm:parallel |
| 833 |
node[50-81] |
| 834 |
|
| 835 |
$ cluset -f -s slurm @parallel |
| 836 |
node[50-81] |
| 837 |
|
| 838 |
.. _cluset-group-finding: |
| 839 |
|
| 840 |
Finding node groups |
| 841 |
""""""""""""""""""" |
| 842 |
|
| 843 |
As an extension to the **list** command, you can search node groups that a |
| 844 |
specified node set belongs to with ``cluset -l[ll]`` as follows:: |
| 845 |
|
| 846 |
$ cluset -l node40 |
| 847 |
@all |
| 848 |
@oss |
| 849 |
|
| 850 |
$ cluset -ll node40 |
| 851 |
@all node[1-159] |
| 852 |
@oss node[40-45] |
| 853 |
|
| 854 |
This feature is implemented with the help of the :meth:`.NodeSet.groups` |
| 855 |
method (see :ref:`class-NodeSet-groups-finding` for further details). |
| 856 |
|
| 857 |
.. _cluset-regroup: |
| 858 |
|
| 859 |
Resolving node groups |
| 860 |
""""""""""""""""""""" |
| 861 |
|
| 862 |
If needed group configuration conditions are met (cf. :ref:`node groups |
| 863 |
configuration <groups-config>`), you can try group lookups thanks to the ``-r, |
| 864 |
--regroup`` command. This feature is implemented with the help of the |
| 865 |
:meth:`.NodeSet.regroup()` method (see :ref:`class-NodeSet-regroup` for |
| 866 |
further details). Only exact matching groups are returned (all containing |
| 867 |
nodes needed), for example:: |
| 868 |
|
| 869 |
$ cluset -r node[40-45] |
| 870 |
@oss |
| 871 |
|
| 872 |
$ cluset -r node[0,40-45] |
| 873 |
@mgnt,@oss |
| 874 |
|
| 875 |
|
| 876 |
When resolving node groups, *cluset* always returns the largest groups |
| 877 |
first, instead of several smaller matching groups, for instance:: |
| 878 |
|
| 879 |
$ cluset -ll |
| 880 |
@login node[50-51] |
| 881 |
@compute node[52-81] |
| 882 |
@intel node[50-81] |
| 883 |
|
| 884 |
$ cluset -r node[50-81] |
| 885 |
@intel |
| 886 |
|
| 887 |
If no matching group is found, ``cluset -r`` still returns folded result (as |
| 888 |
does ``-f``):: |
| 889 |
|
| 890 |
$ cluset -r node40 node42 |
| 891 |
node[40,42] |
| 892 |
|
| 893 |
Indexed node groups |
| 894 |
""""""""""""""""""" |
| 895 |
|
| 896 |
Node groups are themselves some kind of group sets and can be indexable. To |
| 897 |
use this feature, node groups external shell commands need to return indexed |
| 898 |
group names (automatically handled by the library as needed). For example, |
| 899 |
take a look at these indexed node groups:: |
| 900 |
|
| 901 |
$ cluset -l |
| 902 |
@io1 |
| 903 |
@io2 |
| 904 |
@io3 |
| 905 |
|
| 906 |
$ cluset -f @io[1-3] |
| 907 |
node[40-45] |
| 908 |
|
| 909 |
|
| 910 |
Arithmetic operations on node groups |
| 911 |
"""""""""""""""""""""""""""""""""""" |
| 912 |
|
| 913 |
Arithmetic and special operations (as explained for node sets in |
| 914 |
:ref:`cluset-arithmetic` and :ref:`cluset-special`) are also supported with |
| 915 |
node groups. |
| 916 |
Any group name can be used in lieu of a node set, where it will be substituted |
| 917 |
for all nodes in that group before processing requested operations. Some |
| 918 |
typical examples are:: |
| 919 |
|
| 920 |
$ cluset -f @lustre -x @mds |
| 921 |
node[40-45] |
| 922 |
|
| 923 |
$ cluset -r @lustre -x @mds |
| 924 |
@oss |
| 925 |
|
| 926 |
$ cluset -r -a -x @lustre |
| 927 |
@compute,@login,@mgnt |
| 928 |
|
| 929 |
More advanced examples, with the use of node group sets, follow:: |
| 930 |
|
| 931 |
$ cluset -r @io[1-3] -x @io2 |
| 932 |
@io[1,3] |
| 933 |
|
| 934 |
$ cluset -f -I0 @io[1-3] |
| 935 |
node40 |
| 936 |
|
| 937 |
$ cluset -f --split=3 @oss |
| 938 |
node[40-41] |
| 939 |
node[42-43] |
| 940 |
node[44-45] |
| 941 |
|
| 942 |
$ cluset -r --split=3 @oss |
| 943 |
@io1 |
| 944 |
@io2 |
| 945 |
@io3 |
| 946 |
|
| 947 |
|
| 948 |
*Extended patterns* support with node groups |
| 949 |
"""""""""""""""""""""""""""""""""""""""""""" |
| 950 |
|
| 951 |
Even for node groups, the *cluset* command supports arithmetic operations |
| 952 |
through its *extended pattern* feature (see |
| 953 |
:ref:`class-NodeSet-extended-patterns`). |
| 954 |
A first example illustrates node groups intersection, that can be used in |
| 955 |
practice to get nodes available from two dynamic group sources at a given |
| 956 |
time:: |
| 957 |
|
| 958 |
$ cluset -f @db:prod\&@compute |
| 959 |
|
| 960 |
The following hypothetical example computes a folded node set containing nodes |
| 961 |
found in node group ``@gpu`` and ``@slurm:bigmem``, but not in both, minus |
| 962 |
the nodes found in odd ``@chassis`` groups from 1 to 9 (computed from left to |
| 963 |
right):: |
| 964 |
|
| 965 |
$ cluset -f @gpu^@slurm:bigmem\!@chassis[1-9/2] |
| 966 |
|
| 967 |
Also, version 1.7 introduces a notation extension ``@*`` (or ``@SOURCE:*``) |
| 968 |
that has been added to quickly represent *all nodes* (please refer to |
| 969 |
:ref:`clush-all-nodes` for more details). |
| 970 |
|
| 971 |
|
| 972 |
.. _cluset-all-nodes: |
| 973 |
|
| 974 |
Selecting all nodes |
| 975 |
""""""""""""""""""" |
| 976 |
|
| 977 |
The option ``-a`` (without argument) can be used to select **all** nodes from |
| 978 |
a group source (see :ref:`node groups configuration <groups-config>` for more |
| 979 |
details on special **all** external shell command upcall). Example of use for |
| 980 |
the default group source:: |
| 981 |
|
| 982 |
$ cluset -a -f |
| 983 |
example[4-6,32-159] |
| 984 |
|
| 985 |
Use ``-s/--groupsource`` to select another group source. |
| 986 |
|
| 987 |
If not properly configured, the ``-a`` option may lead to runtime errors |
| 988 |
like:: |
| 989 |
|
| 990 |
$ cluset -s mybrokensource -a -f |
| 991 |
cluset: External error: Not enough working methods (all or map + list) |
| 992 |
to get all nodes |
| 993 |
|
| 994 |
A similar option is available with :ref:`clush-tool`, see |
| 995 |
:ref:`selecting all nodes with clush <clush-all-nodes>`. |
| 996 |
|
| 997 |
.. _node-wildcards: |
| 998 |
|
| 999 |
Node wildcards |
| 1000 |
"""""""""""""" |
| 1001 |
|
| 1002 |
ClusterShell 1.8 introduces node wildcards: ``*`` means match zero or more |
| 1003 |
characters of any type; ``?`` means match exactly one character of any type. |
| 1004 |
|
| 1005 |
Any wildcard mask found is matched against **all** nodes from the group source |
| 1006 |
(see :ref:`cluset-all-nodes`). |
| 1007 |
|
| 1008 |
This can be especially useful for server farms, or when cluster node names |
| 1009 |
differ. Say that your :ref:`group configuration <groups-config>` is set to |
| 1010 |
return the following "all nodes":: |
| 1011 |
|
| 1012 |
$ cluset -f -a |
| 1013 |
bckserv[1-2],dbserv[1-4],wwwserv[1-9] |
| 1014 |
|
| 1015 |
Then, you can use wildcards to select particular nodes, as shown below:: |
| 1016 |
|
| 1017 |
$ cluset -f 'www*' |
| 1018 |
wwwserv[1-9] |
| 1019 |
|
| 1020 |
$ cluset -f 'www*[1-4]' |
| 1021 |
wwwserv[1-4] |
| 1022 |
|
| 1023 |
$ cluset -f '*serv1' |
| 1024 |
bckserv1,dbserv1,wwwserv1 |
| 1025 |
|
| 1026 |
Wildcard masks are resolved prior to |
| 1027 |
:ref:`extended patterns <cluset-extended-patterns>`, but each mask is |
| 1028 |
evaluated as a whole node set operand. In the example below, we select |
| 1029 |
all nodes matching ``*serv*`` before removing all nodes matching ``www*``:: |
| 1030 |
|
| 1031 |
$ cluset -f '*serv*!www*' |
| 1032 |
bckserv[1-2],dbserv[1-4] |
| 1033 |
|
| 1034 |
.. _cluset-rangeset: |
| 1035 |
|
| 1036 |
Range sets |
| 1037 |
^^^^^^^^^^ |
| 1038 |
|
| 1039 |
Working with range sets |
| 1040 |
""""""""""""""""""""""" |
| 1041 |
|
| 1042 |
By default, the *cluset* command works with node or group sets and its |
| 1043 |
functionality matches most :class:`.NodeSet` class methods. Similarly, *cluset* |
| 1044 |
will match :class:`.RangeSet` methods when you make use of the ``-R`` option |
| 1045 |
switch. In that case, all operations are restricted to numerical ranges. For |
| 1046 |
example, to expand the range "``1-10``", you should use:: |
| 1047 |
|
| 1048 |
$ cluset -e -R 1-10 |
| 1049 |
1 2 3 4 5 6 7 8 9 10 |
| 1050 |
|
| 1051 |
Almost all commands and operations available for node sets are also available |
| 1052 |
with range sets. The only restrictions are commands and operations related to |
| 1053 |
node groups. For instance, the following command options are **not** available |
| 1054 |
with ``cluset -R``: |
| 1055 |
|
| 1056 |
* ``-r, --regroup`` as this feature is obviously related to node groups, |
| 1057 |
* ``-a / --all`` as the **all** external call is also related to node groups. |
| 1058 |
|
| 1059 |
|
| 1060 |
Using range sets instead of node sets doesn't change the general command |
| 1061 |
usage, like the need of one command option presence (cf. :ref:`cluset-commands`), |
| 1062 |
or the way to give some input (cf. :ref:`cluset-stdin`), for example:: |
| 1063 |
|
| 1064 |
$ echo 3 2 36 0 4 1 37 | cluset -fR |
| 1065 |
0-4,36-37 |
| 1066 |
|
| 1067 |
$ echo 0-8/4 | cluset -eR -S'\n' |
| 1068 |
0 |
| 1069 |
4 |
| 1070 |
8 |
| 1071 |
|
| 1072 |
Stepping and auto-stepping are supported (cf. :ref:`cluset-stepping`) and |
| 1073 |
also zero-padding (cf. :ref:`cluset-zeropadding`), which are both |
| 1074 |
:class:`.RangeSet` class features anyway. |
| 1075 |
|
| 1076 |
The following examples illustrate these last points:: |
| 1077 |
|
| 1078 |
$ cluset -fR 03 05 01 07 11 09 |
| 1079 |
01,03,05,07,09,11 |
| 1080 |
|
| 1081 |
$ cluset -fR --autostep=3 03 05 01 07 11 09 |
| 1082 |
01-11/2 |
| 1083 |
|
| 1084 |
Arithmetic and special operations |
| 1085 |
""""""""""""""""""""""""""""""""" |
| 1086 |
|
| 1087 |
All arithmetic operations, as seen for node sets (cf. |
| 1088 |
:ref:`cluset-arithmetic`), are available for range sets, for example:: |
| 1089 |
|
| 1090 |
$ cluset -fR 1-14 -x 10-20 |
| 1091 |
1-9 |
| 1092 |
|
| 1093 |
$ cluset -fR 1-14 -i 10-20 |
| 1094 |
10-14 |
| 1095 |
|
| 1096 |
$ cluset -fR 1-14 -X 10-20 |
| 1097 |
1-9,15-20 |
| 1098 |
|
| 1099 |
For now, there is no *extended patterns* syntax for range sets as for node |
| 1100 |
sets (cf. :ref:`cluset-extended-patterns`). However, as the union operator |
| 1101 |
``,`` is available natively by design, such expressions are still allowed:: |
| 1102 |
|
| 1103 |
$ cluset -fR 4-10,1-2 |
| 1104 |
1-2,4-10 |
| 1105 |
|
| 1106 |
|
| 1107 |
Besides arithmetic operations, special operations may be very convenient for |
| 1108 |
range sets also (cf. :ref:`cluset-special`). |
| 1109 |
Below is an example with ``-I / --slice`` (cf. :ref:`cluset-slice`):: |
| 1110 |
|
| 1111 |
$ cluset -fR -I 0 100-131 |
| 1112 |
100 |
| 1113 |
|
| 1114 |
$ cluset -fR -I 0-15 100-131 |
| 1115 |
100-115 |
| 1116 |
|
| 1117 |
There is another special operation example with ``--split`` (cf. |
| 1118 |
:ref:`cluset-splitting-n`):: |
| 1119 |
|
| 1120 |
$ cluset -fR --split=2 100-131 |
| 1121 |
100-115 |
| 1122 |
116-131 |
| 1123 |
|
| 1124 |
Finally, an example of the special operation ``--contiguous`` (cf. |
| 1125 |
:ref:`cluset-splitting-contiguous`):: |
| 1126 |
|
| 1127 |
$ cluset -f -R --contiguous 1-9,11,13-19 |
| 1128 |
1-9 |
| 1129 |
11 |
| 1130 |
13-19 |
| 1131 |
|
| 1132 |
*rangeset* alias |
| 1133 |
"""""""""""""""" |
| 1134 |
|
| 1135 |
When using *cluset* with range sets intensively (e.g. for scripting), it may |
| 1136 |
be convenient to create a local command alias, as shown in the following |
| 1137 |
example (Bourne shell), making it sort of a super `seq(1)`_ command:: |
| 1138 |
|
| 1139 |
$ alias rangeset='cluset -R' |
| 1140 |
$ rangeset -e 0-8/2 |
| 1141 |
0 2 4 6 8 |
| 1142 |
|
| 1143 |
|
| 1144 |
.. [#] Slurm is an open-source resource manager (https://slurm.schedmd.com/overview.html) |
| 1145 |
|
| 1146 |
.. _seq(1): http://linux.die.net/man/1/seq |
| 1147 |
|