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

Module NodeSet

source code

Cluster node set module.

A module to deal efficiently with 1D rangesets and nodesets (pdsh-like). Instances of RangeSet and NodeSet both provide similar operations than the builtin set() type and Set object. 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]")
>>> # Print nodeset as a pdsh-like pattern
... print nodeset
cluster[1,6-30,32]
>>> # Iterate over node names in nodeset
... for node in nodeset:
...     print node
[...]
Classes [hide private]
  RangeSetException
Base RangeSet exception class.
  RangeSetParseError
Raised when RangeSet parsing cannot be done properly.
  RangeSetPaddingError
Raised when a fatal padding incoherency occurs
  NodeSetException
Base NodeSet exception class.
  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.
  RangeSet
Advanced range sets.
  NodeSetBase
Base class for NodeSet.
  NodeGroupBase
  ParsingEngine
Class that is able to transform a source into a NodeSetBase.
  NodeSet
Iterable class of nodes with node ranges support.
Functions [hide private]
 
expand(pat)
Commodity function that expands a pdsh-like 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)
Commodity function that retrieves the list of groups for a specified group namespace (or use default namespace).
source code
 
_test() source code
Variables [hide private]
  DEF_GROUPS_CONFIG = '/etc/clustershell/groups.conf'
  DEF_STD_GROUP_RESOLVER = NodeUtils.GroupResolverConfig(DEF_GRO...
  STD_GROUP_RESOLVER = NodeUtils.GroupResolverConfig(DEF_GROUPS_...
  NOGROUP_RESOLVER = -1
  __package__ = 'ClusterShell'
Variables Details [hide private]

DEF_STD_GROUP_RESOLVER

Value:
NodeUtils.GroupResolverConfig(DEF_GROUPS_CONFIG)

STD_GROUP_RESOLVER

Value:
NodeUtils.GroupResolverConfig(DEF_GROUPS_CONFIG)