support for changing clustershell config directory via environment variable by chassing · Pull Request #191 · clustershell/clustershell · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/ClusterShell/CLI/Config.py
20 changes: 11 additions & 9 deletions lib/ClusterShell/NodeSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@

import re
import sys
import os

import ClusterShell.NodeUtils as NodeUtils
from ClusterShell.RangeSet import RangeSet, RangeSetParseError


# Define default GroupResolver object used by NodeSet
DEF_GROUPS_CONFIG = "/etc/clustershell/groups.conf"
CLUSTERSHELL_CONFIG_DIR = os.environ.get("CLUSTERSHELL_CONFIG", "/etc/clustershell/")
DEF_GROUPS_CONFIG = os.path.join(CLUSTERSHELL_CONFIG_DIR, "groups.conf")
DEF_RESOLVER_STD_GROUP = NodeUtils.GroupResolverConfig(DEF_GROUPS_CONFIG)
# Standard group resolver
RESOLVER_STD_GROUP = DEF_RESOLVER_STD_GROUP
Expand Down Expand Up @@ -499,7 +501,7 @@ def intersection_update(self, other):
# intersect two nodes with no rangeset
tmp_ns._add(pat, None)

# Substitute
# Substitute
self._patterns = tmp_ns._patterns

def __iand__(self, other):
Expand Down Expand Up @@ -580,7 +582,7 @@ def symmetric_difference(self, other):
"""
s.symmetric_difference(t) returns the symmetric difference of
two nodesets as a new NodeSet.

(ie. all nodes that are in exactly one of the nodesets.)
"""
self_copy = self.copy()
Expand Down Expand Up @@ -687,7 +689,7 @@ def parse(self, nsobj, autostep):
raise NodeSetParseError(nsobj, str(exc))

raise TypeError("Unsupported NodeSet input %s" % type(nsobj))

def parse_string(self, nsstr, autostep):
"""
Parse provided string and return a NodeSetBase object.
Expand All @@ -711,18 +713,18 @@ def parse_string(self, nsstr, autostep):
getattr(nodeset, opc)(NodeSetBase(pat, rangeset, False))

return nodeset

def parse_string_single(self, nsstr, autostep):
"""Parse provided string and return a NodeSetBase object."""
pat, rangeset = self._scan_string_single(nsstr, autostep)
return NodeSetBase(pat, rangeset, False)

def parse_group(self, group, namespace=None, autostep=None):
"""Parse provided single group name (without @ prefix)."""
assert self.group_resolver is not None
nodestr = self.group_resolver.group_nodes(group, namespace)
return self.parse(",".join(nodestr), autostep)

def parse_group_string(self, nodegroup):
"""Parse provided group string and return a string."""
assert nodegroup[0] == '@'
Expand Down Expand Up @@ -786,7 +788,7 @@ def _scan_string_single(self, nsstr, autostep):
else:
# undefined pad means no node index
return pfx, None

def _scan_string(self, nsstr, autostep):
"""Parsing engine's string scanner method (iterator)."""
pat = nsstr.strip()
Expand Down Expand Up @@ -846,7 +848,7 @@ def _scan_string(self, nsstr, autostep):
pat = None # break next time
else:
node, pat = pat.split(self.OP_CODES[next_op_code], 1)

newpat, rset = self._scan_string_single(node, autostep)
yield op_code, newpat, rset

Expand Down
57 changes: 31 additions & 26 deletions lib/ClusterShell/Task.py