Minor changes

This commit is contained in:
Loïc Guégan 2023-10-26 15:49:19 +02:00
parent 068fba0484
commit abd29e2cdf
3 changed files with 17 additions and 6 deletions

View file

@ -1,6 +1,6 @@
import argparse,sys
from clusterman.config import *
from clusterman.commands import node
from clusterman.commands import node, plugins
def main():
parser = argparse.ArgumentParser()
@ -21,6 +21,10 @@ def main():
##### Frontend commands #####
target_frontend = subparsers.add_parser("frontend")
##### Plugins commands #####
target_plugins = subparsers.add_parser("plugins")
target_plugins.add_argument("name", help="Plugin's name")
target_plugins.add_argument("parameters", help="Plugin's parameters",nargs=argparse.REMAINDER)
# Check if command specified:
if len(sys.argv)==1:
@ -45,11 +49,11 @@ def main():
node.ls()
else:
target_node.print_help(sys.stderr)
sys.exit(1)
if args.target == "frontend":
sys.exit(1)
elif args.target == "frontend":
print("Do frontend related stuff")
elif args.target == "plugins":
plugins.execute(args.name,args.parameters)

View file

@ -0,0 +1,7 @@
import os
from clusterman.config import CONF
def execute(name,args):
executable=CONF["plugins"][name]
os.system(executable+" "+" ".join(args))

View file

@ -13,7 +13,7 @@ class Config:
"ip4_to": "10.128.0.140",
"ip4_ignore": ["10.0.0.5", "10.0.0.1"],
},
"plugins": [],
"plugins": { "ls": "ls -al" },
"timeout": 0.5
}