diff options
| author | Loic Guegan <loic.guegan@mailbox.org> | 2023-10-27 14:18:57 +0200 |
|---|---|---|
| committer | Loic Guegan <loic.guegan@mailbox.org> | 2023-10-27 14:18:57 +0200 |
| commit | 28c1833601f433d5b5dee840192a7bb4c3d36f4d (patch) | |
| tree | 19e50a9d5638bde16c7243e295157268043999a1 /clusterman | |
| parent | eb41b0b49a4d698bb264e5f7e280d8349eba2344 (diff) | |
Minor changes
Diffstat (limited to 'clusterman')
| -rw-r--r-- | clusterman/__main__.py | 6 | ||||
| -rw-r--r-- | clusterman/commands/node.py | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/clusterman/__main__.py b/clusterman/__main__.py index d22786b..be2ea22 100644 --- a/clusterman/__main__.py +++ b/clusterman/__main__.py @@ -20,6 +20,7 @@ def main(): node_cmd_list.add_argument("-g", "--group" ,help="Group to list") # Exec node_cmd_list=node_subparsers.add_parser("exec") + node_cmd_list.add_argument("-g", "--group" ,help="Group to run the command on") node_cmd_list.add_argument("cmd",help="Command to run",nargs=argparse.REMAINDER) ##### Frontend commands ##### @@ -58,7 +59,10 @@ def main(): else: node.ls() elif args.command == "exec": - node.exec(args.cmd) + if args.group: + node.exec(args.cmd,args.group) + else: + node.exec(args.cmd) else: target_node.print_help(sys.stderr) sys.exit(1) diff --git a/clusterman/commands/node.py b/clusterman/commands/node.py index 6a32fb1..59fbdc5 100644 --- a/clusterman/commands/node.py +++ b/clusterman/commands/node.py @@ -83,10 +83,11 @@ def check(timeout): else: print("Error: Some of your nodes are not reachable") -def exec(command): +def exec(command, group=None): user="root" if len(CONF["ssh"]["user"]) <= 0 else CONF["ssh"]["user"] key_path=CONF["ssh"]["key_path"] - for ip in get_node_list(): + nodes=get_node_list() if group is None else get_node_in_group(group) + for ip in nodes: print("----- Node {} -----".format(ip)) if len(key_path)>0: output=subprocess.check_output(["ssh","-o", "StrictHostKeyChecking=no", "-i", CONF["ssh"]["key_path"],"{}@{}".format(user,ip), " ".join(command)]) |
