mirror of
https://gitlab.com/manzerbredes/clusterman.git
synced 2025-04-18 03:42:07 +00:00
Minor changes
This commit is contained in:
parent
b87f4be0bd
commit
9a3523d659
3 changed files with 26 additions and 5 deletions
|
@ -17,6 +17,7 @@ def main():
|
||||||
node_cmd_scan.add_argument("-t", "--timeout" ,help="Timeout", type=float)
|
node_cmd_scan.add_argument("-t", "--timeout" ,help="Timeout", type=float)
|
||||||
# List
|
# List
|
||||||
node_cmd_list=node_subparsers.add_parser("list")
|
node_cmd_list=node_subparsers.add_parser("list")
|
||||||
|
node_cmd_list.add_argument("-g", "--group" ,help="Group to list")
|
||||||
|
|
||||||
##### Frontend commands #####
|
##### Frontend commands #####
|
||||||
target_frontend = subparsers.add_parser("frontend")
|
target_frontend = subparsers.add_parser("frontend")
|
||||||
|
@ -49,7 +50,10 @@ def main():
|
||||||
else:
|
else:
|
||||||
node.check(CONF["timeout"])
|
node.check(CONF["timeout"])
|
||||||
elif args.command == "list":
|
elif args.command == "list":
|
||||||
node.ls()
|
if args.group:
|
||||||
|
node.ls(args.group)
|
||||||
|
else:
|
||||||
|
node.ls()
|
||||||
else:
|
else:
|
||||||
target_node.print_help(sys.stderr)
|
target_node.print_help(sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import os, json, time
|
import os, json, time, re, sys
|
||||||
from clusterman.config import CONF
|
from clusterman.config import CONF
|
||||||
|
|
||||||
|
|
||||||
def ls():
|
def ls(group=None):
|
||||||
nodes_path=CONF.NODE_FILE
|
nodes_path=CONF.NODE_FILE
|
||||||
nodes=None
|
nodes=None
|
||||||
if os.path.exists(nodes_path):
|
if os.path.exists(nodes_path):
|
||||||
|
@ -11,8 +11,21 @@ def ls():
|
||||||
else:
|
else:
|
||||||
print("Please perform a scan before")
|
print("Please perform a scan before")
|
||||||
exit(0)
|
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:
|
for node in nodes:
|
||||||
print(node)
|
if pattern is not None:
|
||||||
|
if pattern.match(node):
|
||||||
|
print(node)
|
||||||
|
else:
|
||||||
|
print(node)
|
||||||
|
|
||||||
def scan(timeout):
|
def scan(timeout):
|
||||||
from_split=[int(n) for n in CONF["cluster"]["ip4_from"].split(".")]
|
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_from": "10.128.0.133",
|
||||||
"ip4_to": "10.128.0.140",
|
"ip4_to": "10.128.0.140",
|
||||||
"ip4_ignore": ["10.0.0.5", "10.0.0.1"],
|
"ip4_ignore": ["10.0.0.5", "10.0.0.1"],
|
||||||
|
"groups": {
|
||||||
|
"all": "*"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"plugins": { "ls": "ls -al" },
|
"plugins": { "ls": "ls -al" },
|
||||||
"timeout": 0.5,
|
"timeout": 0.5,
|
||||||
|
@ -27,7 +30,8 @@ class Config:
|
||||||
"cluster": {"type": "object", "properties":{
|
"cluster": {"type": "object", "properties":{
|
||||||
"ip4_from": {"type": "string"},
|
"ip4_from": {"type": "string"},
|
||||||
"ip4_to": {"type": "string"},
|
"ip4_to": {"type": "string"},
|
||||||
"ip4_ignore": {"type": "array", "items":{"type": "string"}}
|
"ip4_ignore": {"type": "array", "items":{"type": "string"}},
|
||||||
|
"groups": {"type": "object"}
|
||||||
}}
|
}}
|
||||||
},
|
},
|
||||||
"required":[
|
"required":[
|
||||||
|
|
Loading…
Add table
Reference in a new issue