Expand description
Hostlist expression support for pdsh-style range expansion
This module provides parsing and expansion of hostlist expressions, allowing compact specification of multiple hosts using range notation.
§Syntax
The hostlist expression syntax supports:
- Simple range:
node[1-5]->node1, node2, node3, node4, node5 - Zero-padded range:
node[01-05]->node01, node02, node03, node04, node05 - Comma-separated values:
node[1,3,5]->node1, node3, node5 - Mixed ranges and values:
node[1-3,7,9-10]-> 7 hosts - Multiple ranges (cartesian product):
rack[1-2]-node[1-3]-> 6 hosts - Domain suffix:
web[1-3].example.com-> 3 hosts - File input:
^/path/to/file-> read hosts from file
§Examples
use bssh::hostlist::expand_hostlist;
// Simple range expansion
let hosts = expand_hostlist("node[1-3]").unwrap();
assert_eq!(hosts, vec!["node1", "node2", "node3"]);
// Zero-padded expansion
let hosts = expand_hostlist("server[01-03]").unwrap();
assert_eq!(hosts, vec!["server01", "server02", "server03"]);
// Multiple ranges (cartesian product)
let hosts = expand_hostlist("rack[1-2]-node[1-2]").unwrap();
assert_eq!(hosts, vec!["rack1-node1", "rack1-node2", "rack2-node1", "rack2-node2"]);Re-exports§
pub use expander::expand_host_spec;pub use expander::expand_host_specs;pub use expander::expand_hostlist;
Modules§
- expander
- Hostlist expansion implementation
Structs§
- Host
Pattern - Represents a complete host pattern
Enums§
- Hostlist
Error - Errors that can occur during hostlist parsing and expansion
Functions§
- expand_
hostlist_ patterns - Expand a comma-separated list of host patterns
- is_
hostlist_ expression - Check if a pattern is a hostlist expression (contains numeric range brackets)
- looks_
like_ hostlist_ range - Check if bracket content looks like a hostlist numeric range
- parse_
host_ pattern - Parse a host pattern string into a HostPattern structure
- parse_
hostfile - Parse hosts from a file (one per line)