mirror of
https://gitlab.com/manzerbredes/clusterman.git
synced 2025-04-09 22:56:59 +00:00
Minor changes
This commit is contained in:
parent
b87f4be0bd
commit
9a3523d659
3 changed files with 26 additions and 5 deletions
clusterman
|
@ -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)
|
||||
|
|
|
@ -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(".")]
|
||||
|
|
|
@ -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":[
|
||||
|
|
Loading…
Add table
Reference in a new issue