diff options
author | root <root@colazero.tele.tg18.gathering.org> | 2018-03-31 22:28:26 +0200 |
---|---|---|
committer | root <root@colazero.tele.tg18.gathering.org> | 2018-03-31 22:28:26 +0200 |
commit | 38b48dd77b57b116f633b1cf5d68cc70a44b1ea8 (patch) | |
tree | 52b6b4a1af7c4aff3321f4ce60e88d4a483ba315 /templating/templating.py | |
parent | be54730288b9925003e88788e65f11199cc8292b (diff) |
Throw TG18-stuff over the wall
Diffstat (limited to 'templating/templating.py')
-rwxr-xr-x | templating/templating.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/templating/templating.py b/templating/templating.py index 32abb0c..28a6370 100755 --- a/templating/templating.py +++ b/templating/templating.py @@ -11,7 +11,7 @@ endpoints = "read/networks read/oplog read/snmp read/switches-management public/ objects = dict() def getEndpoint(endpoint): - r = requests.get("http://localhost:8080/api/%s" % endpoint) + r = requests.get("http://localhost:80/api/%s" % endpoint) if (r.status_code != 200): raise Exception("Bad status code for endpoint %s: %s" % (endpoint, r.status_code)) return r.json() @@ -34,6 +34,8 @@ def getDistro(src): return src.split(":")[0] def getPort(src): return src.split(":")[1] +def getFirstFapIp(ip): + return netaddr.IPNetwork(ip)[netaddr.IPNetwork(ip).size/2] env = Environment(loader=FileSystemLoader(['templates/','/opt/gondul/data/templates', '/opt/gondul/web/templates']), trim_blocks=True) @@ -44,6 +46,7 @@ env.filters["getFirstDhcpIp"] = getFirstDhcpIp env.filters["getLastDhcpIp"] = getLastDhcpIp env.filters["agentDistro"] = getDistro env.filters["agentPort"] = getPort +env.filters["getFirstFapIP"] = getFirstFapIp class Mode(Enum): Get = 1 @@ -105,7 +108,7 @@ class MyHandler(http.server.BaseHTTPRequestHandler): self.generic(Mode.Post) def run(server_class=http.server.HTTPServer, handler_class=http.server.BaseHTTPRequestHandler): - server_address = ('localhost', 8081) + server_address = ('localhost', 8084) httpd = server_class(server_address, handler_class) httpd.serve_forever() |