-
Notifications
You must be signed in to change notification settings - Fork 7
/
lldp_topo.dot.j2
executable file
·24 lines (22 loc) · 1.17 KB
/
lldp_topo.dot.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
digraph G {
splines=true;
overlap=scalexy;
edge [
arrowhead="none"
];
node [style="rounded,filled,bold", shape=box, width=1.3, fontname="Arial"];
edge [fontsize=10];
{% set already_done = [] %}
{% for host in hostvars %}
{% if 'napalm_lldp_neighbors' in hostvars[host]['ansible_facts'] %}
{% set fqdn = hostvars[host]['ansible_facts']['napalm_fqdn'] %}
{% set lldp_data = hostvars[host]['ansible_facts']['napalm_lldp_neighbors'] %}
{% for interface in lldp_data %}
{% if { lldp_data[interface][0]['hostname'] : lldp_data[interface][0]['port'] | lower|regex_replace('(?P<slot>^\\D\\D)\\D+(?P<portnumber>\\d.+)','\\g<slot>\\g<portnumber>') } not in already_done %}
"{{ fqdn }}" -> "{{ lldp_data[interface][0]['hostname'] }}" [minlen=2 headlabel="{{ lldp_data[interface][0]['port'] }}" taillabel="{{ interface | regex_replace('(?P<slot>^\\D\\D)\\D+(?P<portnumber>\\d.+)','\\g<slot>\\g<portnumber>') }}"];
{% endif %}
{{ already_done.append( { fqdn : interface | lower|regex_replace('(?P<slot>^\\D\\D)\\D+(?P<portnumber>\\d.+)','\\g<slot>\\g<portnumber>') }) }}
{% endfor %}
{% endif %}
{% endfor %}
}