Skip to content

Commit

Permalink
add OTC attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Teun Vink committed Mar 16, 2023
1 parent 944b9df commit edb8287
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions nlnog_lg.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,10 @@ def show_route_for_prefix(prefix=None, netmask=None):
for route in result.get("rib", []):
delta = timedelta(seconds=int(route.get("last_update_sec", 0)))
timestamp = now - delta
otc = ""
for attribute in route.get("attributes", []):
if attribute["type"] == "OTC":
otc = (attribute["as"], get_asn_name(str(attribute["as"])))
if route["prefix"] not in routes:
routes[route["prefix"]] = []
routes[route["prefix"]].append({
Expand All @@ -681,6 +685,7 @@ def show_route_for_prefix(prefix=None, netmask=None):
"last_update": route["last_update"],
"last_update_at": timestamp.strftime("%Y-%m-%d %H:%M:%S UTC"),
"metric": route["metric"],
"otc": otc,
})

# sort output by peername per prefix
Expand Down
1 change: 1 addition & 0 deletions templates/route-text.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ <h5 class="modal-title" id="staticModalLabel">Permalink</h5>
Next-hop: <a href="/whois?q={{ route.exit_nexthop }}" class="whois">{{ route.exit_nexthop }}</a>
Origin validation state: <span class="{{route.ovs}}">{{route.ovs}}</span>
ASPA validation state: <span class="{{route.avs}}">{{route.avs}}</span>
Only-To-Customer (OTC): {% if route.otc %}yes, ASN: <span data-toggle="tooltip" data-placement="top" title="{{ route.otc[1] }}{% if route.otc[0]|int in ringnodes.keys() %}<br><span class=ringnodes>{{ ringnodes[route.otc[0]|int]|length}} NLNOG RING node{% if ringnodes[route.otc[0]|int]|length > 1 %}s{% endif %}</span>{% endif %}"><a href="/whois?q={{ route.otc[0] }}" class="whois asnumber">{{ route.otc[0] }}</a></span>{%else %}no{% endif %}
MED: {{route.metric}}
Last update: {{route.last_update_at}} ({{route.last_update}} ago)
{%- if route.communities %}
Expand Down
6 changes: 5 additions & 1 deletion templates/route.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ <h2 class="accordion-header" id="panelsStayOpen-heading{{loop.index}}">
<table class="table">
<tr>
<td width="15%">AS-Path</td>
<td class="data">{% for as in route.aspath %}{% if as[0] == '{' or as[0] == '}'%}{{ as[0] }}{% else %}<button type="button" class="btn btn-community btn-outline-primary" data-toggle="tooltip" data-placement="top" title="{{ as[1] }}{% if as[0]|int in ringnodes.keys() %}<br><span class=ringnodes>{{ ringnodes[as[0]|int]|length}} NLNOG RING node{% if ringnodes[as[0]|int]|length > 1 %}s{% endif %}</span>{% endif %}"><a href="/whois?q={{ as[0] }}" class="whois asn">{{ as[0] }}</a></button>{% endif %} {% endfor %}via next-hop <a href="/whois?q={{ route.exit_nexthop }}" class="whois">{{ route.exit_nexthop }}</a></td>
<td class="data">{% for as in route.aspath %}{% if as[0] == '{' or as[0] == '}'%}{{ as[0] }}{% else %}<button type="button" class="btn btn-sm btn-community btn-outline-primary" data-toggle="tooltip" data-placement="top" title="{{ as[1] }}{% if as[0]|int in ringnodes.keys() %}<br><span class=ringnodes>{{ ringnodes[as[0]|int]|length}} NLNOG RING node{% if ringnodes[as[0]|int]|length > 1 %}s{% endif %}</span>{% endif %}"><a href="/whois?q={{ as[0] }}" class="whois asn">{{ as[0] }}</a></button>{% endif %} {% endfor %}via next-hop <a href="/whois?q={{ route.exit_nexthop }}" class="whois">{{ route.exit_nexthop }}</a></td>
</tr>
<tr>
<td>Origin validation state</td>
Expand All @@ -71,6 +71,10 @@ <h2 class="accordion-header" id="panelsStayOpen-heading{{loop.index}}">
<td>ASPA validation state</td>
<td class="data"><button type="button" class="btn btn-sm btn-{% if route.avs == "valid" %}success{% elif route.avs == "invalid" %}danger{% else %}secondary{% endif %}">{{ route.avs }}</button></td>
</tr>
<tr>
<td>Only To Customer (OTC)</td>
<td class="data">{% if route.otc %}yes, ASN: <button type="button" class="btn btn-sm btn-community btn-outline-primary" data-toggle="tooltip" data-placement="top" title="{{ route.otc[1] }}{% if route.otc[0]|int in ringnodes.keys() %}<br><span class=ringnodes>{{ ringnodes[route.otc[0]|int]|length}} NLNOG RING node{% if ringnodes[route.otc[0]|int]|length > 1 %}s{% endif %}</span>{% endif %}"><a href="/whois?q={{ route.otc[0] }}" class="whois asn">{{ route.otc[0] }}</a></button{%else %}no{% endif %}</td>
</tr>
<tr>
<td>Origin</td>
<td class="data">{{ route.origin }}</td>
Expand Down

0 comments on commit edb8287

Please sign in to comment.