ClusterShell

1.9.3 · active · verified Thu Apr 16

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

from ClusterShell.NodeSet import NodeSet

# Create a NodeSet from a string representation
nodes = NodeSet("node[0-3],host[10-12]")
print(f"Original NodeSet: {nodes}")

# Add individual nodes or other NodeSets
nodes.add("server05")
print(f"After adding server05: {nodes}")

# Remove nodes
nodes.remove("node1")
print(f"After removing node1: {nodes}")

# Check for membership
print(f"Is node2 in the set? {'node2' in nodes}")

# Iterate over nodes
print("Nodes in the set:")
for node in nodes:
    print(f"- {node}")

view raw JSON →