ClusterShell is a Python library and set of tools designed for efficient command execution on Linux clusters. It provides robust NodeSet manipulation, parallel command execution, and a powerful CLI for High-Performance Computing (HPC) environments. The current version is 1.9.3, with releases typically occurring a few times a year, indicating active maintenance and development.
pip install clustershellVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates the core NodeSet functionality of ClusterShell, allowing you to parse, manipulate, and query groups of node names efficiently. This is a foundational step before performing distributed tasks.
Upgrade your environment to Python 3.6 or newer. Previous ClusterShell versions (1.7.x and below) are required for Python 2 compatibility.
Ensure you assign the result of these methods back to a variable, e.g., `nodes = nodes.intersection(other_nodes)`. Code expecting in-place modification will behave unexpectedly.
To empty a NodeSet, re-initialize it: `nodes = NodeSet()`.
Before using `Task.run()`, ensure you can manually SSH to your target nodes. For debugging, use `task.set_info("ssh_options", "-vvv")` to see detailed SSH output. For isolated testing, consider using `localhost` or mock objects.Change your import statements to use 'ClusterShell', e.g., `from ClusterShell.NodeSet import NodeSet`.
Convert the NodeSet to a list first if you need indexed access: `node_list = list(nodes)`, then `node_list[0]`.
Verify SSH connectivity manually (e.g., `ssh user@node01 hostname`). Check SSH agent forwarding and host key configuration. For deeper diagnostics, enable verbose SSH output within ClusterShell: `task.set_info("ssh_options", "-vvv")`.