summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2021-04-13 10:25:47 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2021-04-13 10:25:47 (GMT)
commitf12fa88f0456380c051aa17249529ec83287f985 (patch)
tree2fa0ca5d7f6994e9dac346f245e108fe47e9a9ab
parent1ddfe568f9b3ecc0cc8ed24fcf96bda5dc5528a6 (diff)
downloadeoptasks-f12fa88f0456380c051aa17249529ec83287f985.zip
eoptasks-f12fa88f0456380c051aa17249529ec83287f985.tar.gz
eoptasks-f12fa88f0456380c051aa17249529ec83287f985.tar.bz2
add support for defining custom keywords mappings in configuration file
This can be used for shortcuts or alternative names, ex: [keywords] monitoring = munin,scrutiny,prometheus or to prevent common errors or misconceptions: [keywords] saas/test = saas/test,-hds,-re,-docbow
-rw-r--r--README12
-rwxr-xr-xeoptasks.py7
2 files changed, 17 insertions, 2 deletions
diff --git a/README b/README
index e792b54..f848622 100644
--- a/README
+++ b/README
@@ -38,6 +38,18 @@ It is also possible to declare additional servers, in a [servers] section, ex::
host.domain = keyword1, keyword2
+And custom keywords mapping can be defined, for shortcuts or alternative names,
+ex::
+
+ [keywords]
+ monitoring = munin,scrutiny,prometheus
+
+or to prevent common errors or misconceptions::
+
+ [keywords]
+ saas/test = saas/test,-hds,-re,-docbow
+
+
Examples
--------
diff --git a/eoptasks.py b/eoptasks.py
index ee4562c..c2d4607 100755
--- a/eoptasks.py
+++ b/eoptasks.py
@@ -124,12 +124,15 @@ def parse_args():
def filter_servers(servers, args):
selected_servers = []
if args.keywords:
- for keyword in args.keywords.split(','):
+ config = get_config()
+ cmd_keywords = config['keywords'].get(args.keywords, args.keywords)
+
+ for keyword in cmd_keywords.split(','):
keywords = set(keyword.split('/'))
selected_servers.extend(
[x for x in servers if keywords.issubset(x.keywords) and not x in selected_servers]
)
- for keyword in args.keywords.split(','):
+ for keyword in cmd_keywords.split(','):
if keyword.startswith('!') or keyword.startswith('-'):
selected_servers = [x for x in selected_servers if keyword[1:] not in x.keywords]
else: