From 4a0972703cdba7c71be76e42973c11405d51cee3 Mon Sep 17 00:00:00 2001 From: Ivan Pepelnjak Date: Sun, 9 Jul 2023 09:33:06 +0200 Subject: [PATCH] Addressing reports in HTML format --- docs/outputs/report.md | 4 ++- netsim/reports/addressing-link.html.j2 | 24 ++++++++++++++++++ netsim/reports/addressing-node.html.j2 | 31 +++++++++++++++++++++++ netsim/reports/addressing.html.j2 | 34 +++----------------------- netsim/reports/page.html.j2 | 7 +++++- 5 files changed, 68 insertions(+), 32 deletions(-) create mode 100644 netsim/reports/addressing-link.html.j2 create mode 100644 netsim/reports/addressing-node.html.j2 diff --git a/docs/outputs/report.md b/docs/outputs/report.md index 65720293e..780394e2e 100644 --- a/docs/outputs/report.md +++ b/docs/outputs/report.md @@ -9,7 +9,9 @@ The *report* output module tries to use the **defaults.outputs.report.*rname*** _netlab_ ships with the following built-in reports: * **addressing** -- Node/interface addressing report in text format -* **addressing.html** -- Node/interface addressing report in HTML format +* **addressing.html** -- Node/interface and link/interface addressing report in HTML format +* **addressing.node.html** -- Node/interface addressing report in HTML format +* **addressing.link.html** -- Link/interface addressing report in HTML format ## Generating HTML reports diff --git a/netsim/reports/addressing-link.html.j2 b/netsim/reports/addressing-link.html.j2 new file mode 100644 index 000000000..ee0e59a05 --- /dev/null +++ b/netsim/reports/addressing-link.html.j2 @@ -0,0 +1,24 @@ + + + + + + +{% for l in links %} + + + +{% set pfx = l.prefix|default({ 'ipv4':'' }) %} + + + +{% for intf in l.interfaces|default([]) %} + + + + + + +{% endfor %} +{% endfor %} +
Link/NodeIPv4 prefixIPv6 prefix

# {{ l.linkindex }}

{{ l.name|default('') }}

{{ pfx.ipv4|default('') }}{{ pfx.ipv6|default('') }}
{{ intf.node }} ({{ intf.ifname }}){{ intf.ipv4|default('') }}{{ intf.ipv6|default('') }}
diff --git a/netsim/reports/addressing-node.html.j2 b/netsim/reports/addressing-node.html.j2 new file mode 100644 index 000000000..fa928a823 --- /dev/null +++ b/netsim/reports/addressing-node.html.j2 @@ -0,0 +1,31 @@ + + + + + + + +{% for n,d in nodes.items() %} + +{% if 'loopback' in d %} + + + +{% set lb = d.loopback|default({ 'ipv4':'' }) %} + +{% else %} + +{% endif %} + +{% for intf in d.interfaces %} + + + + + + +{% endfor %} +{% endfor %} +
Node/InterfaceIPv4 addressIPv6 addressDescription/Router ID

{{ n }}

{% if 'ipv4' in d.loopback %}{{ d.loopback.ipv4 }}{% endif %}{% if 'ipv6' in d.loopback %}{{ d.loopback.ipv6 }}{% endif %}{{ d.router_id|default(lb.ipv4) }}

{{ n }}

{{ intf.ifname }}{{ intf.ipv4|default('') }}{{ intf.ipv6|default('') }} + {{ intf.name }}{% if 'vrf' in intf %} (VRF: {{ intf.vrf }}){% endif +%} +
diff --git a/netsim/reports/addressing.html.j2 b/netsim/reports/addressing.html.j2 index 39979aba0..5160d16ba 100644 --- a/netsim/reports/addressing.html.j2 +++ b/netsim/reports/addressing.html.j2 @@ -1,30 +1,4 @@ - - - - - - -{% for n,d in nodes.items() %} - - - -{% for intf in d.interfaces %} - - - - - -{% endfor %} -{% endfor %} +

Node/Interface Addressing

+{% include 'addressing-node.html.j2' %} +

Link/Interface Addressing

+{% include 'addressing-link.html.j2' %} diff --git a/netsim/reports/page.html.j2 b/netsim/reports/page.html.j2 index 2aaee3039..c44076c03 100644 --- a/netsim/reports/page.html.j2 +++ b/netsim/reports/page.html.j2 @@ -9,7 +9,12 @@ body { font-style: normal; } h1, h2, h3 { - color: #9b652f } + color: #d26400; + font-weight: 500; } + +h1 { font-size: 200% } +h2 { font-size: 140% } +h3 { font-size: 120%; } a { color: #d26400;
Node/InterfaceIPv4/IPv6 addressDescription
-

- {{ n }} - {% for af in ['ipv4','ipv6'] if 'loopback' in d and af in d.loopback -%} - {%- if loop.first %}({% endif %}{{ d.loopback[af] }}{% if loop.last %}){% endif -%} - {% endfor -%} -

{{ intf.ifname }} - {% for af in ['ipv4','ipv6'] if af in intf %} - {% if not loop.first %}
{% endif %}{{ intf[af] }} - {% endfor %} -
- {{ intf.name }}{% if 'vrf' in intf %} (VRF: {{ intf.vrf }}){% endif +%} -