summaryrefslogtreecommitdiff
path: root/clusterman
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-10-26 20:08:13 +0200
committerLoic Guegan <manzerbredes@mailbox.org>2023-10-26 20:08:13 +0200
commit9a3523d659eb8c51204e3084336e1b884d181274 (patch)
tree3b753237340d842747572e8227c1454e92929cfb /clusterman
parentb87f4be0bd0c3d715d042d8fba654f5ec0314833 (diff)
Minor changes
Diffstat (limited to 'clusterman')
-rw-r--r--clusterman/__main__.py6
-rw-r--r--clusterman/commands/node.py19
-rw-r--r--clusterman/config.py6
3 files changed, 26 insertions, 5 deletions
diff --git a/clusterman/__main__.py b/clusterman/__main__.py
index 5496ba5..598ea7a 100644
--- a/clusterman/__main__.py
+++ b/clusterman/__main__.py
@@ -17,6 +17,7 @@ def main():
node_cmd_scan.add_argument("-t", "--timeout" ,help="Timeout", type=float)
# List
node_cmd_list=node_subparsers.add_parser("list")
+ node_cmd_list.add_argument("-g", "--group" ,help="Group to list")
##### Frontend commands #####
target_frontend = subparsers.add_parser("frontend")
@@ -49,7 +50,10 @@ def main():
else:
node.check(CONF["timeout"])
elif args.command == "list":
- node.ls()
+ if args.group:
+ node.ls(args.group)
+ else:
+ node.ls()
else:
target_node.print_help(sys.stderr)
sys.exit(1)
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(".")]
diff --git a/clusterman/config.py b/clusterman/config.py
index 58dbdbc..c39c8c2 100644
--- a/clusterman/config.py
+++ b/clusterman/config.py
@@ -13,6 +13,9 @@ class Config:
"ip4_from": "10.128.0.133",
"ip4_to": "10.128.0.140",
"ip4_ignore": ["10.0.0.5", "10.0.0.1"],
+ "groups": {
+ "all": "*"
+ }
},
"plugins": { "ls": "ls -al" },
"timeout": 0.5,
@@ -27,7 +30,8 @@ class Config:
"cluster": {"type": "object", "properties":{
"ip4_from": {"type": "string"},
"ip4_to": {"type": "string"},
- "ip4_ignore": {"type": "array", "items":{"type": "string"}}
+ "ip4_ignore": {"type": "array", "items":{"type": "string"}},
+ "groups": {"type": "object"}
}}
},
"required":[