From 9a3523d659eb8c51204e3084336e1b884d181274 Mon Sep 17 00:00:00 2001 From: Loic Guegan Date: Thu, 26 Oct 2023 20:08:13 +0200 Subject: Minor changes --- clusterman/commands/node.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'clusterman/commands/node.py') 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(".")] -- cgit v1.2.3