-
Notifications
You must be signed in to change notification settings - Fork 86
NodeGroups
Node Groups documentation has been moved to Read the Docs.
By default, the NodeSet class of ClusterShell is able to interpret node groups syntax and is bound to a new NodeUtils.GroupResolverConfig
object in order to make external groups resolution. For instance, any scripts using the NodeSet class now support node groups automatically (assuming groups.conf
is well configured on the node). For example, resolving node groups is as simple as:
>>> from ClusterShell.NodeSet import NodeSet
>>> print NodeSet("@oss")
node[4-9]
In order to find node groups a specified node set belongs to, you can use the NodeSet.groups()
method. This method is used by the nodeset -l <nodeset>
command. It returns a Python dictionary where keys are groups found and values, provided for convenience, are tuples of the form (group_nodeset, contained_nodeset)
. For example:
>>> for group, (group_nodes, contained_nodes) in NodeSet("@oss").groups().iteritems():
... print group, group_nodes, contained_nodes
@all example[4-6,32-159] example[4-5]
@oss example[4-5] example[4-5]
To try performing reverse resolutions (ie. nodes to node groups), a new method has been added to the NodeSet class: NodeSet.regroup()
. Use this method to perform this operation, with optional group source as method parameter. For example:
>>> NodeSet("node[4-9]").regroup()
'@oss'
The NodeUtils module is a ClusterShell helper module that provides supplementary services to manage nodes in a cluster. It is primarily designed to enhance the NodeSet module providing some binding support to external node groups sources in separate namespaces.
Two base classes are defined in this module:
class GroupSource(object):
"""
GroupSource class managing external calls for nodegroup support.
""""
and
class GroupResolver(object):
"""
Base class GroupResolver that aims to provide node/group resolution
from multiple GroupSource's.
""""
The default NodeSet's GroupResolver
is also defined, named GroupResolverConfig
. A GroupResolverConfig
object is instantiated by NodeSet with /etc/clustershell/groups.conf
as configuration file parameter.