diff options
Diffstat (limited to 'clusterman/commands/node.py')
| -rw-r--r-- | clusterman/commands/node.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/clusterman/commands/node.py b/clusterman/commands/node.py index a04b1a7..e949887 100644 --- a/clusterman/commands/node.py +++ b/clusterman/commands/node.py @@ -1,8 +1,8 @@ -import os, json, time +import os, json, time, re, sys from clusterman.config import CONF -def ls(): +def ls(group=None): nodes_path=CONF.NODE_FILE nodes=None if os.path.exists(nodes_path): @@ -11,8 +11,21 @@ def ls(): else: print("Please perform a scan before") exit(0) + # Setup group pattern + pattern=None + if group is not None: + if group in CONF["cluster"]["groups"]: + pattern = re.compile(CONF["cluster"]["groups"][group]) + else: + print("Group {} not found".format(group)) + sys.exit(1) + # Print nodes for node in nodes: - print(node) + if pattern is not None: + if pattern.match(node): + print(node) + else: + print(node) def scan(timeout): from_split=[int(n) for n in CONF["cluster"]["ip4_from"].split(".")] |
