Package ClusterShell :: Module NodeSet
[hide private]
[frames] | no frames]

Module NodeSet

source code

Cluster node set module.

A module to efficiently deal with node sets and node groups. Instances of NodeSet provide similar operations than the builtin set() type, see http://www.python.org/doc/lib/set-objects.html

Usage example

>>> # Import NodeSet class
... from ClusterShell.NodeSet import NodeSet
>>>
>>> # Create a new nodeset from string
... nodeset = NodeSet("cluster[1-30]")
>>> # Add cluster32 to nodeset
... nodeset.update("cluster32")
>>> # Remove from nodeset
... nodeset.difference_update("cluster[2-5,8-31]")
>>> # Print nodeset as a pdsh-like pattern
... print nodeset
cluster[1,6-7,32]
>>> # Iterate over node names in nodeset
... for node in nodeset:
...     print node
cluster1
cluster6
cluster7
cluster32
Classes [hide private]
  NodeSetException
Base NodeSet exception class.
  NodeSetError
Raised when an error is encountered.
  NodeSetParseError
Raised when NodeSet parsing cannot be done properly.
  NodeSetParseRangeError
Raised when bad range is encountered during NodeSet parsing.
  NodeSetExternalError
Raised when an external error is encountered.
  NodeSetBase
Base class for NodeSet.
  ParsingEngine
Class that is able to transform a source into a NodeSetBase.
  NodeSet
Iterable class of nodes with node ranges support.
Functions [hide private]
 
_strip_escape(nsstr)
Helper to prepare a nodeset string for parsing: trim boundary whitespaces and escape special characters.
source code
 
expand(pat)
Commodity function that expands a nodeset pattern into a list of nodes.
source code
 
fold(pat)
Commodity function that clean dups and fold provided pattern with ranges and "/step" support.
source code
 
grouplist(namespace=None, resolver=None)
Commodity function that retrieves the list of raw groups for a specified group namespace (or use default namespace).
source code
 
std_group_resolver()
Get the current resolver used for standard "@" group resolution.
source code
 
set_std_group_resolver(new_resolver)
Override the resolver used for standard "@" group resolution.
source code
Variables [hide private]
  DEF_GROUPS_CONFIGS = ['/etc/clustershell/groups.conf', '/home/...
  ILLEGAL_GROUP_CHARS = set(['!', '&', '*', ',', '@', '^'])
  _DEF_RESOLVER_STD_GROUP = NodeUtils.GroupResolverConfig(DEF_GR...
  RESOLVER_STD_GROUP = NodeUtils.GroupResolverConfig(DEF_GROUPS_...
  RESOLVER_NOGROUP = -1
  RESOLVER_NOINIT = -2
  STD_GROUP_RESOLVER = NodeUtils.GroupResolverConfig(DEF_GROUPS_...
  NOGROUP_RESOLVER = -1
  __package__ = 'ClusterShell'
Function Details [hide private]

grouplist(namespace=None, resolver=None)

source code 

Commodity function that retrieves the list of raw groups for a specified group namespace (or use default namespace). Group names are not prefixed with "@".

set_std_group_resolver(new_resolver)

source code 

Override the resolver used for standard "@" group resolution. The new resolver should be either an instance of NodeUtils.GroupResolver or None. In the latter case, the group resolver is restored to the default one.


Variables Details [hide private]

DEF_GROUPS_CONFIGS

Value:
['/etc/clustershell/groups.conf',
 '/home/sthiell/.local/etc/clustershell/groups.conf',
 '/home/sthiell/.config/clustershell/groups.conf']

_DEF_RESOLVER_STD_GROUP

Value:
NodeUtils.GroupResolverConfig(DEF_GROUPS_CONFIGS, ILLEGAL_GROUP_CHARS)

RESOLVER_STD_GROUP

Value:
NodeUtils.GroupResolverConfig(DEF_GROUPS_CONFIGS, ILLEGAL_GROUP_CHARS)

STD_GROUP_RESOLVER

Value:
NodeUtils.GroupResolverConfig(DEF_GROUPS_CONFIGS, ILLEGAL_GROUP_CHARS)