diff options
author | makefu <github@syntax-fehler.de> | 2015-09-16 08:30:04 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2015-09-16 08:30:04 +0200 |
commit | 147044be891c92b3c0c1bcc3a4e53e2d0eef9963 (patch) | |
tree | 13ed3ac36d514347f503043b454dddaee51b03ac /retiolum/scripts/adv_graphgen/tinc_graphs/Services.py | |
parent | 9bf9f8d045801b17956d12f599bb166e608ed6dd (diff) | |
parent | 219fab970c7fe455d3dd9bc48e909d96a234046b (diff) |
Merge branch 'master' of github.com:krebscode/painload
Diffstat (limited to 'retiolum/scripts/adv_graphgen/tinc_graphs/Services.py')
-rw-r--r-- | retiolum/scripts/adv_graphgen/tinc_graphs/Services.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/retiolum/scripts/adv_graphgen/tinc_graphs/Services.py b/retiolum/scripts/adv_graphgen/tinc_graphs/Services.py new file mode 100644 index 00000000..9581e21e --- /dev/null +++ b/retiolum/scripts/adv_graphgen/tinc_graphs/Services.py @@ -0,0 +1,25 @@ +import os,sys +services_dir=os.environ.get("SERIVCES_DIR","/home/reaktor/nag.services") +def add_services(nodes): + for k,v in nodes.items(): + n = nodes[k] + try: + with open("{0}/{1}".format(services_dir,k)) as f: + n["services"] = [] + for line in f.readlines(): + n["services"].append(line.strip()) + except Exception as e: + n["services"] = ["Error: No Service File!"] + return nodes +def main(): + import json,sys + try: + nodes = add_services(json.load(sys.stdin)) + print (json.dumps(nodes,indent=4)) + except: + print("unable to parse json data from stdin") + sys.exit(1) + +if __name__ == "__main__": + main() +# vim: set expandtab:ts=4:sw=4 |