ttp_templates 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ttp_templates/__init__.py +2 -0
- ttp_templates/misc/N2G/cli_ip_data/a10.txt +23 -0
- ttp_templates/misc/N2G/cli_ip_data/cisco_ios.txt +33 -0
- ttp_templates/misc/N2G/cli_ip_data/cisco_nxos.txt +39 -0
- ttp_templates/misc/N2G/cli_ip_data/cisco_xr.txt +30 -0
- ttp_templates/misc/N2G/cli_ip_data/fortinet.txt +32 -0
- ttp_templates/misc/N2G/cli_ip_data/huawei.txt +33 -0
- ttp_templates/misc/N2G/cli_ip_data/readme.md +53 -0
- ttp_templates/misc/N2G/cli_isis_data/cisco_xr.txt +12 -0
- ttp_templates/misc/N2G/cli_isis_data/juniper.txt +12 -0
- ttp_templates/misc/N2G/cli_isis_data/readme.md +14 -0
- ttp_templates/misc/N2G/cli_l2_data/cisco_ios.txt +72 -0
- ttp_templates/misc/N2G/cli_l2_data/cisco_nxos.txt +90 -0
- ttp_templates/misc/N2G/cli_l2_data/cisco_xr.txt +105 -0
- ttp_templates/misc/N2G/cli_l2_data/huawei.txt +79 -0
- ttp_templates/misc/N2G/cli_l2_data/juniper.txt +81 -0
- ttp_templates/misc/N2G/cli_l2_data/readme.md +87 -0
- ttp_templates/misc/N2G/cli_ospf_data/cisco_ios.txt +18 -0
- ttp_templates/misc/N2G/cli_ospf_data/cisco_xr.txt +19 -0
- ttp_templates/misc/N2G/cli_ospf_data/huawei.txt +14 -0
- ttp_templates/misc/N2G/cli_ospf_data/readme.md +14 -0
- ttp_templates/misc/Netmiko/cisco.ios.arp.txt +48 -0
- ttp_templates/misc/Netmiko/cisco.ios.cfg.bgp.txt +28 -0
- ttp_templates/misc/Netmiko/cisco.ios.cfg.interface.txt +9 -0
- ttp_templates/misc/Netmiko/cisco.ios.cfg.ip.txt +108 -0
- ttp_templates/misc/Netmiko/cisco.ios.cfg.nat.static.txt +30 -0
- ttp_templates/misc/Netmiko/cisco.iosxr.arp.txt +48 -0
- ttp_templates/misc/Netmiko/cisco.iosxr.cfg.interface.txt +9 -0
- ttp_templates/misc/Netmiko/cisco.iosxr.cfg.ip.txt +280 -0
- ttp_templates/misc/Netmiko/huawei.vrp.cfg.interface.txt +9 -0
- ttp_templates/misc/Netmiko/huawei.vrp.cfg.ip.txt +99 -0
- ttp_templates/misc/ttp_templates_tests/cisco_ios_interfaces_cfg_per_ip.txt +95 -0
- ttp_templates/misc/ttp_templates_tests/netmiko_cisco_ios_interfaces.txt +19 -0
- ttp_templates/misc/vars/short_interface_names.txt +35 -0
- ttp_templates/platform/arista_eos_show_hostname.txt +8 -0
- ttp_templates/platform/cisco_ios_show_ip_arp.txt +66 -0
- ttp_templates/platform/cisco_ios_show_ip_ospf_database_external.txt +55 -0
- ttp_templates/platform/cisco_ios_show_ip_ospf_database_router.txt +92 -0
- ttp_templates/platform/cisco_ios_show_ip_ospf_database_summary.txt +53 -0
- ttp_templates/platform/cisco_ios_show_running_config_pipe_include_source_static.txt +119 -0
- ttp_templates/platform/cisco_ios_show_running_config_pipe_section_interface.txt +25 -0
- ttp_templates/platform/cisco_ios_show_running_configuration_pipe_section_bgp.txt +237 -0
- ttp_templates/platform/cisco_xr_show_arp_vrf_all.txt +7 -0
- ttp_templates/platform/cisco_xr_show_isis_database_verbose.txt +75 -0
- ttp_templates/platform/cisco_xr_show_ospf_database_external.txt +54 -0
- ttp_templates/platform/cisco_xr_show_ospf_database_router.txt +91 -0
- ttp_templates/platform/cisco_xr_show_ospf_database_summary.txt +59 -0
- ttp_templates/platform/cisco_xr_show_running_config_interface.txt +21 -0
- ttp_templates/platform/huawei_display_current_configuration_interface.txt +19 -0
- ttp_templates/platform/huawei_display_ospf_lsdb_router.txt +71 -0
- ttp_templates/platform/juniper_show_isis_database_verbose_pipe_no_more.txt +114 -0
- ttp_templates/platform/test_platform_show_run_pipe_sec_interface.txt +11 -0
- ttp_templates/ttp_templates.py +105 -0
- ttp_templates/ttp_vars.py +67 -0
- ttp_templates/yang/ietf-interfaces_cisco_ios.txt +259 -0
- ttp_templates/yang/openconfig-lldp_cisco_ios.txt +182 -0
- ttp_templates/yang/openconfig-lldp_cisco_nxos.txt +173 -0
- ttp_templates/yang/openconfig-lldp_cisco_xr.txt +176 -0
- ttp_templates-0.2.0.dist-info/LICENSE +21 -0
- ttp_templates-0.2.0.dist-info/METADATA +256 -0
- ttp_templates-0.2.0.dist-info/RECORD +62 -0
- ttp_templates-0.2.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<template name="a10" results="per_template">
|
|
2
|
+
|
|
3
|
+
<doc>
|
|
4
|
+
Template to parse A10 devices interfaces configuration and IP ARP cache.
|
|
5
|
+
</doc>
|
|
6
|
+
|
|
7
|
+
<vars>local_hostname="gethostname"</vars>
|
|
8
|
+
|
|
9
|
+
<!-- Interfaces configuration group -->
|
|
10
|
+
<group name="{{ local_hostname }}.interfaces.{{ interface }}">
|
|
11
|
+
interface {{ interface | PHRASE | resuball("IfsNormalize") }}
|
|
12
|
+
description {{ port_description | re(".+") }}
|
|
13
|
+
<group name="ip_addresses*" chain="add_network()" method="table">
|
|
14
|
+
ip address {{ ip | IP }} {{ netmask }}
|
|
15
|
+
</group>
|
|
16
|
+
</group>
|
|
17
|
+
|
|
18
|
+
<!-- ARP cache group -->
|
|
19
|
+
<group name="{{ local_hostname }}.interfaces.{{ interface }}.arp*" method="table">
|
|
20
|
+
{{ ip | IP }} {{ mac | MAC | mac_eui }} Dynamic {{ age }} {{ interface | PHRASE | resuball("IfsNormalize") }} {{ vlan }}
|
|
21
|
+
</group>
|
|
22
|
+
|
|
23
|
+
</template>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template name="cisco_ios" results="per_template">
|
|
2
|
+
|
|
3
|
+
<doc>
|
|
4
|
+
Template to parse Cisco IOS interfaces configuration and ARP cache.
|
|
5
|
+
</doc>
|
|
6
|
+
|
|
7
|
+
<vars>local_hostname="gethostname"</vars>
|
|
8
|
+
|
|
9
|
+
<!-- Interfaces configuration group -->
|
|
10
|
+
<group name="{{ local_hostname }}.interfaces.{{ interface }}">
|
|
11
|
+
interface {{ interface | resuball("IfsNormalize") }}
|
|
12
|
+
description {{ port_description | re(".+") }}
|
|
13
|
+
vrf forwarding {{ vrf }}
|
|
14
|
+
ip vrf forwarding {{ vrf }}
|
|
15
|
+
ip access-group {{ ACL_IN }} in
|
|
16
|
+
ip access-group {{ ACL_OUT }} out
|
|
17
|
+
<group name="ip_addresses*" chain="add_network()" method="table">
|
|
18
|
+
ip address {{ ip | IP }} {{ netmask }}
|
|
19
|
+
ip address {{ ip | IP }} {{ netmask }} secondary
|
|
20
|
+
</group>
|
|
21
|
+
<group name="fhrp*" method="table">
|
|
22
|
+
standby {{ group | let("type", "HSRP") }} {{ ip | IP }}
|
|
23
|
+
vrrp {{ group | let("type", "VRRP") }} ip {{ ip | IP }}
|
|
24
|
+
</group>
|
|
25
|
+
! {{ _end_ }}
|
|
26
|
+
</group>
|
|
27
|
+
|
|
28
|
+
<!-- ARP cache group -->
|
|
29
|
+
<group name="{{ local_hostname }}.interfaces.{{ interface }}.arp*" method="table">
|
|
30
|
+
Internet {{ ip | IP }} {{ age }} {{ mac | MAC | mac_eui }} {{ type }} {{ interface | resuball("IfsNormalize") }}
|
|
31
|
+
</group>
|
|
32
|
+
|
|
33
|
+
</template>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template name="cisco_nxos" results="per_template">
|
|
2
|
+
|
|
3
|
+
<doc>
|
|
4
|
+
Template to parse Cisco NXOS interfaces configuration and ARP cache.
|
|
5
|
+
</doc>
|
|
6
|
+
|
|
7
|
+
<vars>local_hostname="gethostname"</vars>
|
|
8
|
+
|
|
9
|
+
<!-- Interfaces configuration group -->
|
|
10
|
+
<group name="{{ local_hostname }}.interfaces.{{ interface }}">
|
|
11
|
+
interface {{ interface | resuball("IfsNormalize") }}
|
|
12
|
+
description {{ port_description | re(".+") }}
|
|
13
|
+
vrf member {{ vrf }}
|
|
14
|
+
ip access-group {{ ACL_IN }} in
|
|
15
|
+
ip access-group {{ ACL_OUT }} out
|
|
16
|
+
<group name="ip_addresses*" chain="add_network()" method="table">
|
|
17
|
+
ip address {{ ip | IP }}/{{ netmask }}
|
|
18
|
+
ip address {{ ip | IP }}/{{ netmask }} secondary
|
|
19
|
+
</group>
|
|
20
|
+
<group name="fhrp*" method="table">
|
|
21
|
+
<group>
|
|
22
|
+
hsrp {{ group | let("type", "HSRP") }}
|
|
23
|
+
ip {{ ip | IP }}
|
|
24
|
+
</group>
|
|
25
|
+
<group>
|
|
26
|
+
vrrpv3 {{ group | let("type", "VRRP") }} address-family ipv4
|
|
27
|
+
address {{ ip | IP }} primary
|
|
28
|
+
</group>
|
|
29
|
+
</group>
|
|
30
|
+
! {{ _end_ }}
|
|
31
|
+
</group>
|
|
32
|
+
|
|
33
|
+
<!-- ARP cache group -->
|
|
34
|
+
<group name="{{ local_hostname }}.interfaces.{{ interface }}.arp*" method="table">
|
|
35
|
+
{{ ip | IP }} {{ age }} {{ mac | MAC | mac_eui }} {{ interface | resuball("IfsNormalize") }}
|
|
36
|
+
{{ ip | IP }} {{ age }} {{ mac | MAC | mac_eui }} {{ interface | resuball("IfsNormalize") }} *
|
|
37
|
+
</group>
|
|
38
|
+
|
|
39
|
+
</template>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<template name="cisco_xr" results="per_template">
|
|
2
|
+
|
|
3
|
+
<doc>
|
|
4
|
+
Template to parse Cisco IOSXR interfaces configuration and ARP cache.
|
|
5
|
+
</doc>
|
|
6
|
+
|
|
7
|
+
<vars>local_hostname="gethostname"</vars>
|
|
8
|
+
|
|
9
|
+
<group record="local_hostname" void="">
|
|
10
|
+
hostname {{ local_hostname }}
|
|
11
|
+
</group>
|
|
12
|
+
|
|
13
|
+
<!-- Interfaces configuration group -->
|
|
14
|
+
<group name="{{ local_hostname }}.interfaces.{{ interface }}">
|
|
15
|
+
interface {{ interface | resuball("IfsNormalize") }}
|
|
16
|
+
description {{ port_description | re(".+") }}
|
|
17
|
+
vrf {{ vrf }}
|
|
18
|
+
<group name="ip_addresses*" chain="add_network()" method="table">
|
|
19
|
+
ipv4 address {{ ip | IP }} {{ netmask }}
|
|
20
|
+
ipv4 address {{ ip | IP }} {{ netmask }} secondary
|
|
21
|
+
</group>
|
|
22
|
+
! {{ _end_ }}
|
|
23
|
+
</group>
|
|
24
|
+
|
|
25
|
+
<!-- ARP cache group -->
|
|
26
|
+
<group name="{{ local_hostname }}.interfaces.{{ interface }}.arp*" method="table">
|
|
27
|
+
{{ ip | IP }} {{ age | replace("-", "-1") }} {{ mac | MAC| mac_eui }} {{ ignore }} {{ ignore }} {{ interface | resuball("IfsNormalize") }}
|
|
28
|
+
</group>
|
|
29
|
+
|
|
30
|
+
</template>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template name="fortinet" results="per_template">
|
|
2
|
+
|
|
3
|
+
<doc>
|
|
4
|
+
Template to parse Fortinet fortigate firewalls interfaces configuration and ARP cache.
|
|
5
|
+
</doc>
|
|
6
|
+
|
|
7
|
+
<vars>local_hostname="gethostname"</vars>
|
|
8
|
+
|
|
9
|
+
<!-- Interfaces configuration group -->
|
|
10
|
+
<group name="{{ local_hostname }}.interfaces**">
|
|
11
|
+
config system interface {{ _start_ }}
|
|
12
|
+
<group name="{{ interface }}">
|
|
13
|
+
edit "{{ interface }}"
|
|
14
|
+
set description "{{ port_description | re(".+") }}"
|
|
15
|
+
set vdom "{{ vrf }}"
|
|
16
|
+
set allowaccess {{ ACL_IN | ORPHRASE }}
|
|
17
|
+
set interface "{{ parent_interface }}"
|
|
18
|
+
set vlanid {{ vid }}
|
|
19
|
+
<group name="ip_addresses*" chain="add_network()" method="table">
|
|
20
|
+
set ip {{ ip | IP }} {{ netmask }}
|
|
21
|
+
set ip {{ ip | IP }} {{ netmask }}
|
|
22
|
+
</group>
|
|
23
|
+
next{{ _end_ }}
|
|
24
|
+
</group>
|
|
25
|
+
</group>
|
|
26
|
+
|
|
27
|
+
<!-- ARP cache group -->
|
|
28
|
+
<group name="{{ local_hostname }}.interfaces.{{ interface }}.arp*" method="table">
|
|
29
|
+
{{ ip | IP }} {{ age }} {{ mac | MAC | mac_eui }} {{ interface }}
|
|
30
|
+
</group>
|
|
31
|
+
|
|
32
|
+
</template>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<template name="huawei" results="per_template">
|
|
2
|
+
|
|
3
|
+
<doc>
|
|
4
|
+
Template to parse Huawei interfaces configuration and ARP cache.
|
|
5
|
+
</doc>
|
|
6
|
+
|
|
7
|
+
<vars>local_hostname="gethostname"</vars>
|
|
8
|
+
|
|
9
|
+
<!-- Interfaces configuration group -->
|
|
10
|
+
<group name="{{ local_hostname }}.interfaces.{{ interface }}">
|
|
11
|
+
interface {{ interface | resuball("IfsNormalize") }}
|
|
12
|
+
description {{ port_description | re(".+") }}
|
|
13
|
+
ip binding vpn-instance {{ vrf }}
|
|
14
|
+
<group name="ip_addresses*" chain="add_network()" method="table">
|
|
15
|
+
ip address {{ ip | IP }} {{ netmask }}
|
|
16
|
+
ip address {{ ip | IP }} {{ netmask }} sub
|
|
17
|
+
ipv6 address {{ ip | IPV6 }}/{{ netmask }}
|
|
18
|
+
ipv6 address {{ ip | IPV6 }}/{{ netmask }} sub
|
|
19
|
+
</group>
|
|
20
|
+
<group name="fhrp*" method="table">
|
|
21
|
+
vrrp vrid {{ group | let("type", "VRRP") }} virtual-ip {{ ip | IP }}
|
|
22
|
+
</group>
|
|
23
|
+
</group>
|
|
24
|
+
|
|
25
|
+
<!-- ARP cache group -->
|
|
26
|
+
<group name="{{ local_hostname }}.interfaces.{{ interface }}.arp*" method="table">
|
|
27
|
+
{{ ip | IP }} {{ mac | MAC | mac_eui }} {{ expire | re("\\d+") }} {{ type | notdigit }} {{ interface | resuball("IfsNormalize") }} {{ vrf }}
|
|
28
|
+
{{ ip | IP }} {{ mac | MAC | mac_eui }} {{ type | notdigit }} {{ interface | resuball("IfsNormalize") }} {{ vrf }}
|
|
29
|
+
{{ ip | IP }} {{ mac | MAC | mac_eui }} {{ expire | re("\\d+") }} {{ type | notdigit }} {{ interface | resuball("IfsNormalize") }}
|
|
30
|
+
{{ ip | IP }} {{ mac | MAC | mac_eui }} {{ type | notdigit }} {{ interface | resuball("IfsNormalize") }}
|
|
31
|
+
</group>
|
|
32
|
+
|
|
33
|
+
</template>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# cli_ip_data Templates
|
|
2
|
+
|
|
3
|
+
cli_ip_data templates designed to parse show commands output from networking devices into a
|
|
4
|
+
structured data for the use of N2G application to produce diagrams.
|
|
5
|
+
|
|
6
|
+
Parsing results example:
|
|
7
|
+
|
|
8
|
+
```
|
|
9
|
+
{'cisco_ios': {'switch_1': {'interfaces': {'SVI123': {'arp': [{'age': '-',
|
|
10
|
+
'ip': '10.123.111.1',
|
|
11
|
+
'mac': 'd094.6643.1111',
|
|
12
|
+
'type': 'ARPA'}],
|
|
13
|
+
'ip_addresses': [{'ip': '10.123.111.1',
|
|
14
|
+
'netmask': '24',
|
|
15
|
+
'network': '10.123.111.0/24'},
|
|
16
|
+
{'ip': '10.123.222.1',
|
|
17
|
+
'netmask': '24',
|
|
18
|
+
'network': '10.123.222.0/24'}],
|
|
19
|
+
'port_description': 'Workstations Vlan',
|
|
20
|
+
'vrf': 'CORP'}}},
|
|
21
|
+
'switch_2': {'interfaces': {'SVI11': {'ip_addresses': [{'ip': '10.11.11.1',
|
|
22
|
+
'netmask': '24',
|
|
23
|
+
'network': '10.11.11.0/24'}],
|
|
24
|
+
'port_description': 'Workstations Vlan'},
|
|
25
|
+
'SVI22': {'arp': [{'age': '-',
|
|
26
|
+
'ip': '10.22.22.1',
|
|
27
|
+
'mac': 'd094.7890.1111',
|
|
28
|
+
'type': 'ARPA'},
|
|
29
|
+
{'age': '106',
|
|
30
|
+
'ip': '10.22.22.4',
|
|
31
|
+
'mac': 'd867.7890.1444',
|
|
32
|
+
'type': 'ARPA'}],
|
|
33
|
+
'ip_addresses': [{'ip': '10.22.22.1',
|
|
34
|
+
'netmask': '24',
|
|
35
|
+
'network': '10.22.22.0/24'}],
|
|
36
|
+
'port_description': 'Workstations Vlan'},
|
|
37
|
+
'Te1/1/71': {'arp': [{'age': '5',
|
|
38
|
+
'ip': '10.1.234.1',
|
|
39
|
+
'mac': 'd867.d9b7.1111',
|
|
40
|
+
'type': 'ARPA'}],
|
|
41
|
+
'fhrp': [{'hsrp_group': '1',
|
|
42
|
+
'vip': '10.1.234.1.99',
|
|
43
|
+
'type': 'hsrp'}],
|
|
44
|
+
'ip_addresses': [{'ip': '10.1.234.2',
|
|
45
|
+
'netmask': '24',
|
|
46
|
+
'network': '10.1.234.0/24'}],
|
|
47
|
+
'port_description': 'to SWITCH_2 shared '
|
|
48
|
+
'subnet'}}}}}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Parsing results schema:
|
|
52
|
+
|
|
53
|
+
TBD
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<doc>
|
|
2
|
+
Template to parse Cisco IOSXR "show isis database verbose" output.
|
|
3
|
+
</doc>
|
|
4
|
+
|
|
5
|
+
<input load="python">
|
|
6
|
+
# Starting with Netmiko 3.4.0 can use run_ttp method to populate this template with below commands output
|
|
7
|
+
commands = [
|
|
8
|
+
"show isis database verbose",
|
|
9
|
+
]
|
|
10
|
+
</input>
|
|
11
|
+
|
|
12
|
+
<extend template="ttp://platform/cisco_xr_show_isis_database_verbose.txt"/>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<doc>
|
|
2
|
+
Template to parse Juniper JunOS "show isis database extensive | no-more" output.
|
|
3
|
+
</doc>
|
|
4
|
+
|
|
5
|
+
<input load="python">
|
|
6
|
+
# Starting with Netmiko 3.4.0 can use run_ttp method to populate this template with below commands output
|
|
7
|
+
commands = [
|
|
8
|
+
"show isis database extensive | no-more",
|
|
9
|
+
]
|
|
10
|
+
</input>
|
|
11
|
+
|
|
12
|
+
<extend template="ttp://platform/juniper_show_isis_database_verbose_pipe_no_more.txt"/>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# cli_isis_data Templates
|
|
2
|
+
|
|
3
|
+
cli_isis_data template designed for use with N2G library to produce network diagrams based on ISIS
|
|
4
|
+
link state database of Cisco IOS-XR devices.
|
|
5
|
+
|
|
6
|
+
Caveats:
|
|
7
|
+
|
|
8
|
+
- need `ttp>=0.8.0` for extend to work
|
|
9
|
+
|
|
10
|
+
Results structure example:
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
TBD
|
|
14
|
+
```
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<template name="cisco_ios" results="per_template">
|
|
2
|
+
|
|
3
|
+
<doc>
|
|
4
|
+
This template designed to parse Cisco IOS configuration and CDP and LLDP neighbors.
|
|
5
|
+
</doc>
|
|
6
|
+
|
|
7
|
+
<vars>local_hostname="gethostname"</vars>
|
|
8
|
+
|
|
9
|
+
<macro>
|
|
10
|
+
def process_vlans(data):
|
|
11
|
+
return {data["vid"]: data["name"]}
|
|
12
|
+
|
|
13
|
+
def check_is_physical_port(data):
|
|
14
|
+
for item in _ttp_["vars"]["physical_ports"]:
|
|
15
|
+
if data.startswith(item) and not "." in item:
|
|
16
|
+
return data, {"is_physical_port": True}
|
|
17
|
+
return data
|
|
18
|
+
</macro>
|
|
19
|
+
|
|
20
|
+
<!-- Interfaces configuration group -->
|
|
21
|
+
<group name="{{ local_hostname }}.interfaces**.{{ interface }}**">
|
|
22
|
+
interface {{ interface | resuball(IfsNormalize) }}
|
|
23
|
+
description {{ description | re(".+") }}
|
|
24
|
+
switchport {{ is_l2 | set(True) }}
|
|
25
|
+
switchport access vlan {{ access_vlan }}
|
|
26
|
+
switchport mode {{ l2_mode }}
|
|
27
|
+
vrf forwarding {{ vrf }}
|
|
28
|
+
ip address {{ ip | PHRASE | joinmatches(",") }}
|
|
29
|
+
ip address {{ ip | PHRASE | joinmatches(",") }} secondary
|
|
30
|
+
switchport trunk allowed vlan {{ trunk_vlans | unrange("-", ",") | joinmatches(",") }}
|
|
31
|
+
channel-group {{ lag_id | DIGIT }} mode {{ lag_mode }}
|
|
32
|
+
mtu {{ mtu }}
|
|
33
|
+
</group>
|
|
34
|
+
|
|
35
|
+
<!-- Interfaces state group -->
|
|
36
|
+
<group name="{{ local_hostname }}.interfaces**.{{ interface }}**.state">
|
|
37
|
+
{{ interface | _start_ | resuball(IfsNormalize) | macro("check_is_physical_port") }} is {{ admin | ORPHRASE }}, line protocol is {{ line }}
|
|
38
|
+
{{ interface | _start_ | resuball(IfsNormalize) | macro("check_is_physical_port") }} is {{ admin | ORPHRASE }}, line protocol is {{ line }} ({{ line_status }})
|
|
39
|
+
Description: {{ description | re(".+") }}
|
|
40
|
+
Hardware is {{ hardware | ORPHRASE }}, address is {{ mac }} (bia {{ ignore }})
|
|
41
|
+
MTU {{ mtu }} bytes, BW {{ bw_kbits }} Kbit/sec, DLY 1000 usec,
|
|
42
|
+
{{ duplex }}-duplex, {{ link_type }}, media type is {{ media_type }}
|
|
43
|
+
{{ duplex }}-duplex, {{ link_speed }}-speed, link type is {{ link_type }}, media type is {{ media_type | ORPHRASE }}
|
|
44
|
+
{{ duplex }}-duplex, {{ link_speed }}, link type is {{ link_type }}, media type is {{ media_type | ORPHRASE }}
|
|
45
|
+
Members in this channel: {{ lag_members | ORPHRASE }}
|
|
46
|
+
</group>
|
|
47
|
+
|
|
48
|
+
<!-- node_facts VLANs group -->
|
|
49
|
+
<group name="{{ local_hostname }}.node_facts.vlans**" macro="process_vlans">
|
|
50
|
+
vlan {{ vid }}
|
|
51
|
+
name {{ name | ORPHRASE | default("no name") }}
|
|
52
|
+
</group>
|
|
53
|
+
|
|
54
|
+
<!-- LLDP peers group -->
|
|
55
|
+
<group name="{{ local_hostname }}.lldp_peers*" expand="">
|
|
56
|
+
Local Intf: {{ src_label | resuball(IfsNormalize) }}
|
|
57
|
+
Port id: {{ trgt_label | ORPHRASE | resuball(IfsNormalize) }}
|
|
58
|
+
System Name: {{ target.id | split(".") | item(0) | split("(") | item(0) }}
|
|
59
|
+
System Capabilities: {{ ignore(ORPHRASE) }}
|
|
60
|
+
IP: {{ target.top_label }}
|
|
61
|
+
{{ source | set("local_hostname") }}
|
|
62
|
+
</group>
|
|
63
|
+
|
|
64
|
+
<!-- CDP peers group -->
|
|
65
|
+
<group name="{{ local_hostname }}.cdp_peers*" expand="">
|
|
66
|
+
Device ID: {{ target.id | split(".") | item(0) | split("(") | item(0) }}
|
|
67
|
+
IP address: {{ target.top_label }}
|
|
68
|
+
Platform: {{ target.bottom_label | ORPHRASE }}, Capabilities: {{ ignore(ORPHRASE) }}
|
|
69
|
+
Interface: {{ src_label | resuball(IfsNormalize) }}, Port ID (outgoing port): {{ trgt_label | ORPHRASE | resuball(IfsNormalize) }}
|
|
70
|
+
{{ source | set("local_hostname") }}
|
|
71
|
+
</group>
|
|
72
|
+
</template>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<template name="cisco_nxos" results="per_template">
|
|
2
|
+
|
|
3
|
+
<doc>
|
|
4
|
+
This template designed to parse Cisco NXOS configuration and CDP and LLDP neighbors.
|
|
5
|
+
</doc>
|
|
6
|
+
|
|
7
|
+
<vars>local_hostname="gethostname"</vars>
|
|
8
|
+
|
|
9
|
+
<macro>
|
|
10
|
+
def process_vlans(data):
|
|
11
|
+
return {data["vid"]: data["name"]}
|
|
12
|
+
|
|
13
|
+
def check_is_physical_port(data):
|
|
14
|
+
for item in _ttp_["vars"]["physical_ports"]:
|
|
15
|
+
if data.startswith(item) and not "." in data:
|
|
16
|
+
return data, {"is_physical_port": True}
|
|
17
|
+
return data
|
|
18
|
+
</macro>
|
|
19
|
+
|
|
20
|
+
<macro>
|
|
21
|
+
def check_lldp_peer_name(data):
|
|
22
|
+
undef_names = ["not advertised", "null"]
|
|
23
|
+
if data.get("target.id", "").lower() in undef_names:
|
|
24
|
+
data["target.id"] = data["data.chassis_id"]
|
|
25
|
+
return data
|
|
26
|
+
</macro>
|
|
27
|
+
|
|
28
|
+
<!-- Interfaces configuration group -->
|
|
29
|
+
<group name="{{ local_hostname }}.interfaces**.{{ interface }}**">
|
|
30
|
+
interface {{ interface | resuball(IfsNormalize) }}
|
|
31
|
+
description {{ description | re(".+") }}
|
|
32
|
+
switchport {{ is_l2 | set(True) }}
|
|
33
|
+
switchport access vlan {{ access_vlan }}
|
|
34
|
+
switchport mode {{ l2_mode }}
|
|
35
|
+
switchport trunk allowed vlan {{ trunk_vlans | unrange("-", ",") | joinmatches(",") }}
|
|
36
|
+
switchport trunk allowed vlan add {{ trunk_vlans | unrange("-", ",") | joinmatches(",") }}
|
|
37
|
+
channel-group {{ lag_id | DIGIT }} mode {{ lag_mode }}
|
|
38
|
+
vpc {{ mlag_id | DIGIT }}
|
|
39
|
+
mtu {{ mtu }}
|
|
40
|
+
vrf member {{ vrf }}
|
|
41
|
+
ip address {{ ip | joinmatches(",") }}
|
|
42
|
+
ip address {{ ip | joinmatches(",") }} secondary
|
|
43
|
+
</group>
|
|
44
|
+
|
|
45
|
+
<group name="{{ local_hostname }}.interfaces**.{{ interface }}**.state">
|
|
46
|
+
{{ interface | _start_ | resuball(IfsNormalize) | macro("check_is_physical_port") }} is {{ admin | ORPHRASE }}, line protocol is {{ line }}, autostate enabled
|
|
47
|
+
{{ interface | _start_ | resuball(IfsNormalize) | macro("check_is_physical_port") }} is {{ line | ORPHRASE }}
|
|
48
|
+
admin state is {{ admin | ORPHRASE }},{{ ignore(".*") }}
|
|
49
|
+
admin state is {{ admin }}
|
|
50
|
+
Belongs to {{ parent_lag }}
|
|
51
|
+
Description: {{ description | re(".+") }}
|
|
52
|
+
Hardware: {{ hardware | ORPHRASE }}, address: {{ mac }} (bia {{ bia }})
|
|
53
|
+
Hardware is {{ hardware }}, address is {{ mac }}
|
|
54
|
+
MTU {{ mtu }} bytes, BW {{ bw_kbits }} Kbit, DLY 10 usec
|
|
55
|
+
Port mode is {{ mode }}
|
|
56
|
+
{{ duplex }}-duplex, {{ link_speed | PHRASE }}, media type is {{ media_type }}
|
|
57
|
+
{{ duplex }}-duplex, {{ link_speed | PHRASE | exclude(",media") }}
|
|
58
|
+
Members in this channel: {{ lag_members | ORPHRASE }}
|
|
59
|
+
</group>
|
|
60
|
+
|
|
61
|
+
<!-- node_facts VLANs group -->
|
|
62
|
+
<group name="{{ local_hostname }}.node_facts.vlans**" macro="process_vlans">
|
|
63
|
+
vlan {{ vid | exclude(",") }}
|
|
64
|
+
name {{ name | ORPHRASE | default("no name") }}
|
|
65
|
+
</group>
|
|
66
|
+
|
|
67
|
+
<!-- LLDP peers group -->
|
|
68
|
+
<group name="{{ local_hostname }}.lldp_peers*" chain="macro('check_lldp_peer_name') | expand()">
|
|
69
|
+
Chassis id: {{ data.chassis_id }}
|
|
70
|
+
Port id: {{ trgt_label | ORPHRASE | resuball(IfsNormalize) }}
|
|
71
|
+
Local Port id: {{ src_label | resuball(IfsNormalize) }}
|
|
72
|
+
Port Description: {{ data.peer_port_description | re(".+") }}
|
|
73
|
+
System Name: {{ target.id | ORPHRASE | split(".") | item(0) | split("(") | item(0) }}
|
|
74
|
+
System Description: {{ data.peer_system | ORPHRASE}}
|
|
75
|
+
System Capabilities: {{ data.peer_capabilities | ORPHRASE }}
|
|
76
|
+
Management Address: {{ target.top_label }}
|
|
77
|
+
{{ source | set("local_hostname") }}
|
|
78
|
+
</group>
|
|
79
|
+
|
|
80
|
+
<!-- CDP peers group -->
|
|
81
|
+
<group name="{{ local_hostname }}.cdp_peers*" expand="">
|
|
82
|
+
Device ID:{{ target.id | split(".") | item(0) | split("(") | item(0) }}
|
|
83
|
+
IPv4 Address: {{ target.top_label }}
|
|
84
|
+
Platform: {{ target.bottom_label | ORPHRASE }}, Capabilities: {{ data.peer_capabilities | ORPHRASE }}
|
|
85
|
+
Interface: {{ src_label | resuball(IfsNormalize) }}, Port ID (outgoing port): {{ trgt_label | ORPHRASE | resuball(IfsNormalize) }}
|
|
86
|
+
MTU: {{ data.peer_mtu }}
|
|
87
|
+
Physical Location: {{ data.peer_location | ORPHRASE }}
|
|
88
|
+
{{ source | set("local_hostname") }}
|
|
89
|
+
</group>
|
|
90
|
+
</template>
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<template name="cisco_xr" results="per_template">
|
|
2
|
+
|
|
3
|
+
<doc>
|
|
4
|
+
This template designed to parse Cisco IOSXR configuration and CDP and LLDP neighbors.
|
|
5
|
+
|
|
6
|
+
Commands parsed:
|
|
7
|
+
|
|
8
|
+
- show lldp - to extract local hostname
|
|
9
|
+
- show lldp neighbors detail - to extract LLDP neighbors
|
|
10
|
+
- show running-config interface - to extract interfaces description and LAGs
|
|
11
|
+
- show cdp neighbors detail - show extract CDP neighbors
|
|
12
|
+
- show interfaces - to extract interface state to add all connected nodes
|
|
13
|
+
</doc>
|
|
14
|
+
|
|
15
|
+
<!-- gethostname used if no show lldp output provided -->
|
|
16
|
+
<vars>local_hostname="gethostname"</vars>
|
|
17
|
+
|
|
18
|
+
<macro>
|
|
19
|
+
def check_is_physical_port(data):
|
|
20
|
+
for item in _ttp_["vars"]["physical_ports"]:
|
|
21
|
+
if data.startswith(item) and not "." in item:
|
|
22
|
+
return data, {"is_physical_port": True}
|
|
23
|
+
return data
|
|
24
|
+
|
|
25
|
+
def add_lldp_target_id(data):
|
|
26
|
+
"""
|
|
27
|
+
Some LLDP peers output does not contain System Name, this macro
|
|
28
|
+
is to make sure we assign chassis_id as target.id in that case.
|
|
29
|
+
"""
|
|
30
|
+
if (
|
|
31
|
+
not data.get("target", {}).get("id") and
|
|
32
|
+
data.get("data", {}).get("chassis_id")
|
|
33
|
+
):
|
|
34
|
+
data.setdefault("target", {})
|
|
35
|
+
data["target"]["id"] = data["data"]["chassis_id"]
|
|
36
|
+
return data
|
|
37
|
+
</macro>
|
|
38
|
+
|
|
39
|
+
<!-- show lldp - parse global params -->
|
|
40
|
+
<group void="">
|
|
41
|
+
Global LLDP information: {{ _start_ }}
|
|
42
|
+
LLDP System Name: {{ local_hostname | record("local_hostname") }}
|
|
43
|
+
</group>
|
|
44
|
+
|
|
45
|
+
<!-- Interfaces configuration group -->
|
|
46
|
+
<group name="{{ local_hostname }}.interfaces**.{{ interface }}**">
|
|
47
|
+
interface {{ interface | resuball(IfsNormalize) }}
|
|
48
|
+
mtu {{ mtu }}
|
|
49
|
+
vrf {{ vrf }}
|
|
50
|
+
description {{ description | re(".+") }}
|
|
51
|
+
ipv4 address {{ ip | PHRASE | joinmatches(",") }}
|
|
52
|
+
ipv4 address {{ ip | PHRASE | joinmatches(",") }} secondary
|
|
53
|
+
ipv6 address {{ ip | joinmatches(",") }}
|
|
54
|
+
bundle id {{ lag_id | DIGIT }} mode {{ lag_mode }}
|
|
55
|
+
</group>
|
|
56
|
+
|
|
57
|
+
<!-- Interfaces state group -->
|
|
58
|
+
<group name="{{ local_hostname }}.interfaces**.{{ interface }}**.state">
|
|
59
|
+
{{ interface | _start_ | resuball(IfsNormalize) | macro("check_is_physical_port") }} is {{ admin | ORPHRASE }}, line protocol is {{ line | ORPHRASE }}
|
|
60
|
+
Hardware is {{ hardware }} interface(s)
|
|
61
|
+
Hardware is {{ hardware }} interface
|
|
62
|
+
Hardware is {{ hardware | ORPHRASE }} interface(s), address is {{ mac }}
|
|
63
|
+
Hardware is {{ hardware | ORPHRASE }}, address is {{ mac }} (bia {{ ignore }})
|
|
64
|
+
Description: {{ description | re(".+") }}
|
|
65
|
+
Internet address is {{ ip }}
|
|
66
|
+
MTU {{ mtu }} bytes, BW {{ bw_kbits }} Kbit (Max: 1000000 Kbit)
|
|
67
|
+
MTU {{ mtu }} bytes, BW {{ bw_kbits }} Kbit
|
|
68
|
+
{{ duplex }}-duplex, {{ link_speed }}
|
|
69
|
+
{{ duplex }}-duplex, {{ link_speed }}, link type is {{ link_type }}
|
|
70
|
+
{{ duplex }}-duplex, {{ link_speed }}, {{ media_type }}, link type is {{ link_type }}
|
|
71
|
+
{{ lag_members | joinmatches(" ") }} {{ ignore }}-duplex {{ ignore }} {{ ignore }}
|
|
72
|
+
</group>
|
|
73
|
+
|
|
74
|
+
<!-- LLDP peers group -->
|
|
75
|
+
<group name="{{ local_hostname }}.lldp_peers*" functions="expand() | macro(add_lldp_target_id)">
|
|
76
|
+
Local Interface: {{ src_label | resuball(IfsNormalize) }}
|
|
77
|
+
Chassis id: {{ data.chassis_id }}
|
|
78
|
+
Port id: {{ trgt_label | ORPHRASE | resuball(IfsNormalize) }}
|
|
79
|
+
Port Description: {{ data.peer_port_description | re(".+") }}
|
|
80
|
+
System Name: {{ target.id | split("(") | item(0) }}
|
|
81
|
+
System Name: {{ data.peer_system_name | PHRASE }}
|
|
82
|
+
System Capabilities: {{ data.peer_capabilities | ORPHRASE }}
|
|
83
|
+
IPv4 address: {{ target.top_label }}
|
|
84
|
+
{{ source | set("local_hostname") }}
|
|
85
|
+
|
|
86
|
+
<group name="data**">
|
|
87
|
+
System Description: {{ _start_ }}
|
|
88
|
+
{{ peer_system_description | ORPHRASE | contains(",") }}
|
|
89
|
+
{{ peer_system_description | ORPHRASE | contains(",") }}
|
|
90
|
+
{{ _end_ }}
|
|
91
|
+
</group>
|
|
92
|
+
|
|
93
|
+
</group>
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
<!-- CDP peers group -->
|
|
97
|
+
<group name="{{ local_hostname }}.cdp_peers*" expand="">
|
|
98
|
+
Device ID: {{ target.id | split(".") | item(0) | split("(") | item(0) }}
|
|
99
|
+
IPv4 address: {{ target.top_label }}
|
|
100
|
+
Platform: {{ target.bottom_label | ORPHRASE }}, Capabilities: {{ data.peer_capabilities | ORPHRASE }}
|
|
101
|
+
Interface: {{ src_label | resuball(IfsNormalize) }}
|
|
102
|
+
Port ID (outgoing port): {{ trgt_label | ORPHRASE | resuball(IfsNormalize) }}
|
|
103
|
+
{{ source | set("local_hostname") }}
|
|
104
|
+
</group>
|
|
105
|
+
</template>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<template name="huawei" results="per_template">
|
|
2
|
+
|
|
3
|
+
<doc>
|
|
4
|
+
This template designed to parse Huawei configuration and LLDP neighbors.
|
|
5
|
+
</doc>
|
|
6
|
+
|
|
7
|
+
<vars>local_hostname="gethostname"</vars>
|
|
8
|
+
|
|
9
|
+
<macro>
|
|
10
|
+
def process_vlans(data):
|
|
11
|
+
return {data["vid"]: data["name"]}
|
|
12
|
+
|
|
13
|
+
def check_is_physical_port(data):
|
|
14
|
+
for item in _ttp_["vars"]["physical_ports"]:
|
|
15
|
+
if data.startswith(item) and not "." in data:
|
|
16
|
+
return data, {"is_physical_port": True}
|
|
17
|
+
return data
|
|
18
|
+
</macro>
|
|
19
|
+
|
|
20
|
+
<macro>
|
|
21
|
+
def check_lldp_peer_name(data):
|
|
22
|
+
undef_names = ["not advertised", "null", "--"]
|
|
23
|
+
if data.get("target.id", "").lower() in undef_names:
|
|
24
|
+
data["target.id"] = data["data.chassis_id"]
|
|
25
|
+
return data
|
|
26
|
+
|
|
27
|
+
def lldp_choose_bottom_label(data):
|
|
28
|
+
if "target.bottom_label_2" in data:
|
|
29
|
+
data["target.bottom_label"] = data.pop("target.bottom_label_2")
|
|
30
|
+
elif "target.bottom_label" in data:
|
|
31
|
+
data["data.peer_system"] = str(data["target.bottom_label"])
|
|
32
|
+
data["target.bottom_label"] = "{}..".format(data["target.bottom_label"][:18])
|
|
33
|
+
return data
|
|
34
|
+
</macro>
|
|
35
|
+
|
|
36
|
+
<!-- Interfaces configuration group -->
|
|
37
|
+
<group name="{{ local_hostname }}.interfaces**.{{ interface }}**">
|
|
38
|
+
interface {{ interface | resuball(IfsNormalize) }}
|
|
39
|
+
description {{ description | re(".+") }}
|
|
40
|
+
port link-type {{ l2_mode }}
|
|
41
|
+
dot1q termination vid {{ dot1q_vid }}
|
|
42
|
+
port trunk allow-pass vlan {{ trunk_vlans | unrange("to", " ") | replace(' ', ',') | joinmatches(",") }}
|
|
43
|
+
port trunk allow-pass vlan all {{ trunk_vlans | set("ALL") }}
|
|
44
|
+
dfs-group 1 m-lag {{ mlag_id | DIGIT }}
|
|
45
|
+
eth-trunk {{ lag_id | DIGIT }}
|
|
46
|
+
mode {{ lag_mode }}
|
|
47
|
+
port trunk pvid vlan {{ access_vlan }}
|
|
48
|
+
ip address {{ ip | PHRASE | joinmatches(",") }}
|
|
49
|
+
ip binding vpn-instance {{ vrf }}
|
|
50
|
+
peer-link 1 {{ peer_link | set(True) }}
|
|
51
|
+
</group>
|
|
52
|
+
|
|
53
|
+
<!-- Interfaces state group
|
|
54
|
+
<group name="{{ local_hostname }}.interfaces**.{{ interface }}**.state">
|
|
55
|
+
|
|
56
|
+
</group>
|
|
57
|
+
-->
|
|
58
|
+
|
|
59
|
+
<!-- node_facts VLANs group -->
|
|
60
|
+
<group name="{{ local_hostname }}.node_facts.vlans**" macro="process_vlans">
|
|
61
|
+
vlan {{ vid | exclude(",") }}
|
|
62
|
+
name {{ name | ORPHRASE | default("no name") }}
|
|
63
|
+
</group>
|
|
64
|
+
|
|
65
|
+
<!-- LLDP peers group -->
|
|
66
|
+
<group name="{{ local_hostname }}.lldp_peers*" chain="macro('check_lldp_peer_name') | macro(lldp_choose_bottom_label) | expand()">
|
|
67
|
+
{{ src_label | resuball(IfsNormalize) }} has 1 neighbor(s):
|
|
68
|
+
Port ID :{{ trgt_label | ORPHRASE | resuball(IfsNormalize) }}
|
|
69
|
+
Chassis ID :{{ data.chassis_id }}
|
|
70
|
+
System name :{{ target.id | split(".") | item(0) | split("(") | item(0) }}
|
|
71
|
+
HUAWEI {{ target.bottom_label_2 }}
|
|
72
|
+
System description :{{ target.bottom_label | ORPHRASE }}
|
|
73
|
+
Port description :{{ data.peer_port_description | re(".+") | notequal("--") }}
|
|
74
|
+
System capabilities supported :{{ data.peer_capabilities | ORPHRASE | notequal("--") }}
|
|
75
|
+
Maximum frame Size :{{ data.peer_mtu | notequal("--") }}
|
|
76
|
+
Management address :{{ target.top_label }}
|
|
77
|
+
{{ source | set("local_hostname") }}
|
|
78
|
+
</group>
|
|
79
|
+
</template>
|