From b28bedc524b1a0f90a1b760ac29fb2d49d7970b3 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 24 Jun 2013 19:19:46 +0200 Subject: fix symlink --- retiolum/bin/nodes-to-json | 37 +++++++++++++++++++++++++++++++++++++ retiolum/bin/nodes-to-json.py | 37 ------------------------------------- retiolum/bin/tinc2json | 1 + retiolum/bin/tinc_stats2json | 1 - 4 files changed, 38 insertions(+), 38 deletions(-) create mode 100644 retiolum/bin/nodes-to-json delete mode 100644 retiolum/bin/nodes-to-json.py create mode 120000 retiolum/bin/tinc2json delete mode 120000 retiolum/bin/tinc_stats2json (limited to 'retiolum/bin') diff --git a/retiolum/bin/nodes-to-json b/retiolum/bin/nodes-to-json new file mode 100644 index 00000000..ca9d3c8c --- /dev/null +++ b/retiolum/bin/nodes-to-json @@ -0,0 +1,37 @@ +#!/usr/bin/python + +def parse_hosts_path(path="/etc/tinc/retiolum/hosts"): + import os + import re + + needle_addr = re.compile("Subnet\s*=\s*(.*)/[0-9]+") + needle_port = re.compile("Port\s*=\s*(.*)") + for f in os.listdir(path): + with open(path+"/"+f) as of: + addrs = [] + port = "655" + + for line in of.readlines(): + + addr_found = needle_addr.match(line) + if addr_found: + addrs.append(addr_found.group(1)) + + port_found = needle_port.match(line) + if port_found: + port = port_found.group(1) + + if addrs : yield (f ,[(addr ,int(port)) for addr in addrs]) + + + +if __name__ == "__main__": + """ + usage + """ + import json + import sys + db={} + for host,addrs in parse_hosts_path(sys.argv[1] if len(sys.argv) > 2 else "/etc/tinc/retiolum/hosts"): + db[host] = addrs + print(json.dumps(db)) diff --git a/retiolum/bin/nodes-to-json.py b/retiolum/bin/nodes-to-json.py deleted file mode 100644 index ca9d3c8c..00000000 --- a/retiolum/bin/nodes-to-json.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python - -def parse_hosts_path(path="/etc/tinc/retiolum/hosts"): - import os - import re - - needle_addr = re.compile("Subnet\s*=\s*(.*)/[0-9]+") - needle_port = re.compile("Port\s*=\s*(.*)") - for f in os.listdir(path): - with open(path+"/"+f) as of: - addrs = [] - port = "655" - - for line in of.readlines(): - - addr_found = needle_addr.match(line) - if addr_found: - addrs.append(addr_found.group(1)) - - port_found = needle_port.match(line) - if port_found: - port = port_found.group(1) - - if addrs : yield (f ,[(addr ,int(port)) for addr in addrs]) - - - -if __name__ == "__main__": - """ - usage - """ - import json - import sys - db={} - for host,addrs in parse_hosts_path(sys.argv[1] if len(sys.argv) > 2 else "/etc/tinc/retiolum/hosts"): - db[host] = addrs - print(json.dumps(db)) diff --git a/retiolum/bin/tinc2json b/retiolum/bin/tinc2json new file mode 120000 index 00000000..31bd0775 --- /dev/null +++ b/retiolum/bin/tinc2json @@ -0,0 +1 @@ +../scripts/adv_graphgen/tinc_stats/Log2JSON.py \ No newline at end of file diff --git a/retiolum/bin/tinc_stats2json b/retiolum/bin/tinc_stats2json deleted file mode 120000 index 413b778c..00000000 --- a/retiolum/bin/tinc_stats2json +++ /dev/null @@ -1 +0,0 @@ -../scripts/adv_graphgen/tinc_stats2json \ No newline at end of file -- cgit v1.2.3