Skip to content

Commit

Permalink
Addressing reports in HTML format
Browse files Browse the repository at this point in the history
  • Loading branch information
ipspace committed Jul 9, 2023
1 parent 4c559cf commit 4a09727
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 32 deletions.
4 changes: 3 additions & 1 deletion docs/outputs/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 24 additions & 0 deletions netsim/reports/addressing-link.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<table>
<tr>
<th colspan='2'>Link/Node</th>
<th class='right'>IPv4 prefix</th>
<th class='right'>IPv6 prefix</th>
</tr>
{% for l in links %}
<tr>
<td class='header'><h3># {{ l.linkindex }}</h3></td>
<td class='header'><h3>{{ l.name|default('') }}</h3></td>
{% set pfx = l.prefix|default({ 'ipv4':'' }) %}
<td class='right header'>{{ pfx.ipv4|default('') }}</td>
<td class='right header'>{{ pfx.ipv6|default('') }}</td>
</tr>
{% for intf in l.interfaces|default([]) %}
<tr>
<td></td>
<td>{{ intf.node }} ({{ intf.ifname }})</td>
<td class='right'>{{ intf.ipv4|default('') }}</td>
<td class='right'>{{ intf.ipv6|default('') }}</td>
</tr>
{% endfor %}
{% endfor %}
</table>
31 changes: 31 additions & 0 deletions netsim/reports/addressing-node.html.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<table>
<tr>
<th>Node/Interface</th>
<th class='right'>IPv4 address</th>
<th class='right'>IPv6 address</th>
<th>Description/Router ID</th>
</tr>
{% for n,d in nodes.items() %}
<tr>
{% if 'loopback' in d %}
<td class='header'><h3>{{ n }}</h3></td>
<td class='header right'>{% if 'ipv4' in d.loopback %}{{ d.loopback.ipv4 }}{% endif %}</td>
<td class='header right'>{% if 'ipv6' in d.loopback %}{{ d.loopback.ipv6 }}{% endif %}</td>
{% set lb = d.loopback|default({ 'ipv4':'' }) %}
<td class='header right'>{{ d.router_id|default(lb.ipv4) }}</td>
{% else %}
<td class='header' colspan='4'><h3>{{ n }}</h3></td>
{% endif %}
</tr>
{% for intf in d.interfaces %}
<tr>
<td style='padding-left: 2em;'>{{ intf.ifname }}</td>
<td class='right'>{{ intf.ipv4|default('') }}</td>
<td class='right'>{{ intf.ipv6|default('') }}</td>
<td>
{{ intf.name }}{% if 'vrf' in intf %} (VRF: {{ intf.vrf }}){% endif +%}
</td>
</tr>
{% endfor %}
{% endfor %}
</table>
34 changes: 4 additions & 30 deletions netsim/reports/addressing.html.j2
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
<table>
<tr>
<th>Node/Interface</th>
<th class='right'>IPv4/IPv6 address</th>
<th>Description</th>
</tr>
{% for n,d in nodes.items() %}
<tr>
<td colspan="3" class='header'>
<h3>
{{ 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 -%}
</td>
</tr>
{% for intf in d.interfaces %}
<tr>
<td style='padding-left: 2em;'>{{ intf.ifname }}</td>
<td class='right'>
{% for af in ['ipv4','ipv6'] if af in intf %}
{% if not loop.first %}<br />{% endif %}{{ intf[af] }}
{% endfor %}
</td>
<td>
{{ intf.name }}{% if 'vrf' in intf %} (VRF: {{ intf.vrf }}){% endif +%}
</td>
</tr>
{% endfor %}
{% endfor %}
<h1>Node/Interface Addressing</h1>
{% include 'addressing-node.html.j2' %}
<h1>Link/Interface Addressing</h1>
{% include 'addressing-link.html.j2' %}
7 changes: 6 additions & 1 deletion netsim/reports/page.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4a09727

Please sign in to comment.