From f9e79c6d8e7484e00e493d1b3436d5c6bc05be3e Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Tue, 8 Nov 2016 11:38:17 +0100 Subject: Move templating URLs around Fixes #143 Fixes #141 --- extras/misc/varnish.vcl | 4 ++-- templating/templates/switch.txt | 19 ------------------- templating/templates/switches.txt | 7 ------- templating/templating.py | 2 +- web/templates/switch.txt | 19 +++++++++++++++++++ web/templates/switches.txt | 7 +++++++ 6 files changed, 29 insertions(+), 29 deletions(-) delete mode 100644 templating/templates/switch.txt delete mode 100644 templating/templates/switches.txt create mode 100644 web/templates/switch.txt create mode 100644 web/templates/switches.txt diff --git a/extras/misc/varnish.vcl b/extras/misc/varnish.vcl index c9e23c5..02562ec 100644 --- a/extras/misc/varnish.vcl +++ b/extras/misc/varnish.vcl @@ -40,8 +40,8 @@ sub vcl_recv { if (req.url ~ "/render") { set req.backend_hint = graphite; } - if (req.url ~ "/templating") { - set req.url = regsub(req.url, "/templating", ""); + if (req.url ~ "/api/templates") { + set req.url = regsub(req.url, "/api/templates", ""); set req.backend_hint = templating; } diff --git a/templating/templates/switch.txt b/templating/templates/switch.txt deleted file mode 100644 index 0fd9754..0000000 --- a/templating/templates/switch.txt +++ /dev/null @@ -1,19 +0,0 @@ -{# - This can be used through GET /templating/switch.txt?switch=e41-2 - - It is provided as a simple demo of how to combine "GET parameters" with - templating. - - #} -{% set sw = options["switch"] %} -{% set s = objects["public/switches"].switches[sw] %} -{% if s %} -{% set mg = objects["read/switches-management"].switches[sw] %} - -Switch {{ sw }} has management ip {{ mg.mgmt_v4_addr }} - -It is assoicated with distro {{ s.distro_name }} -{% else %} -Switch not found -{% endif %} - diff --git a/templating/templates/switches.txt b/templating/templates/switches.txt deleted file mode 100644 index 0cc203b..0000000 --- a/templating/templates/switches.txt +++ /dev/null @@ -1,7 +0,0 @@ -{% for switch in objects["public/switches"].switches %} - {% set mg = objects["read/switches-management"].switches[switch] %} - {% set s = objects["public/switches"].switches[switch] %} - {% if mg.subnet4 -%} - {{ switch }} {{mg.subnet4 }} {{ mg.subnet6 }} {{ mg.mgmt_v4_addr }} {{ mg.mgmt_v6_addr }} {{ mg.traffic_vlan }} {{ s.distro_name }} - {% endif %} -{% endfor %} diff --git a/templating/templating.py b/templating/templating.py index 57d81b1..7b91806 100755 --- a/templating/templating.py +++ b/templating/templating.py @@ -17,7 +17,7 @@ def updateData(): for a in endpoints: objects[a] = getEndpoint(a) -env = Environment(loader=FileSystemLoader(['templates/','/opt/gondul/templating/templates']),lstrip_blocks=True, trim_blocks=True) +env = Environment(loader=FileSystemLoader(['templates/','/opt/gondul/web/templates']),lstrip_blocks=True, trim_blocks=True) import http.server class MyHandler(http.server.BaseHTTPRequestHandler): diff --git a/web/templates/switch.txt b/web/templates/switch.txt new file mode 100644 index 0000000..0fd9754 --- /dev/null +++ b/web/templates/switch.txt @@ -0,0 +1,19 @@ +{# + This can be used through GET /templating/switch.txt?switch=e41-2 + + It is provided as a simple demo of how to combine "GET parameters" with + templating. + + #} +{% set sw = options["switch"] %} +{% set s = objects["public/switches"].switches[sw] %} +{% if s %} +{% set mg = objects["read/switches-management"].switches[sw] %} + +Switch {{ sw }} has management ip {{ mg.mgmt_v4_addr }} + +It is assoicated with distro {{ s.distro_name }} +{% else %} +Switch not found +{% endif %} + diff --git a/web/templates/switches.txt b/web/templates/switches.txt new file mode 100644 index 0000000..0cc203b --- /dev/null +++ b/web/templates/switches.txt @@ -0,0 +1,7 @@ +{% for switch in objects["public/switches"].switches %} + {% set mg = objects["read/switches-management"].switches[switch] %} + {% set s = objects["public/switches"].switches[switch] %} + {% if mg.subnet4 -%} + {{ switch }} {{mg.subnet4 }} {{ mg.subnet6 }} {{ mg.mgmt_v4_addr }} {{ mg.mgmt_v6_addr }} {{ mg.traffic_vlan }} {{ s.distro_name }} + {% endif %} +{% endfor %} -- cgit v1.2.3