-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathcisco_nxos.yml
More file actions
executable file
·129 lines (129 loc) · 5.31 KB
/
cisco_nxos.yml
File metadata and controls
executable file
·129 lines (129 loc) · 5.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
---
sync_devices:
hostname:
commands:
- command: "show version"
parser: "textfsm"
jpath: "[*].hostname"
serial:
commands:
- command: "show inventory"
parser: "textfsm"
jpath: "[?name=='Chassis'].sn"
device_type:
commands:
- command: "show inventory"
parser: "textfsm"
jpath: "[?name=='Chassis'].descr"
mgmt_interface:
commands:
- command: "show ip interface brief vrf all"
parser: "textfsm"
jpath: "[?ip_address=='{{ obj }}'].interface || [`mgmt0`]"
mask_length:
commands:
- command: "show ip interface vrf all"
parser: "textfsm"
jpath: "[?ip_address=='{{ obj }}'].subnet"
post_processor: "{% if '/' in obj[0] %}{{ obj[0].split('/')[1] }}{% else %}31{% endif %}"
iterable_type: "int"
sync_network_data:
pre_processor:
vlan_map:
commands:
- command: "show vlan"
parser: "textfsm"
# Since we use the jdiff custom jmespath we have access to save keys with $ syntax.
jpath: "[*].[$vlan_id$,vlan_name]"
post_processor: "{{ obj | flatten_list_of_dict_from_value('vlan_name') | tojson }}"
serial:
commands:
- command: "show inventory"
parser: "textfsm"
jpath: "[?name=='Chassis'].sn"
interfaces:
root_key: true
commands:
- command: "show interface"
parser: "textfsm"
jpath: "[*].interface" # when root_key=true this extracted value is what becomes interable in keys using __ under `current_key`.
post_processor: "{% set result={} %}{% for interface in obj %}{{ result.update({interface: {}}) or '' }}{% endfor %}{{ result | tojson }}"
interfaces__type:
commands:
- command: "show interface"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].hardware_type"
post_processor: "{{ obj[0] | map_interface_type }}"
interfaces__ip_addresses:
commands:
- command: "show ip interface vrf all"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].{ip_address: ip_address, prefix_length: subnet}"
post_processor: "{% set result = [] %}{% for ip in obj %}{% set _=result.append({'ip_address': ip['ip_address'], 'prefix_length': ip['prefix_length'] | extract_prefix }) %}{% endfor %}{{ result | tojson }}"
iterable_type: "list"
interfaces__mtu:
commands:
- command: "show interface"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].mtu"
iterable_type: "str"
interfaces__mac_address:
commands:
- command: "show interface"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].mac_address"
interfaces__description:
commands:
- command: "show interface"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].description"
interfaces__link_status:
commands:
- command: "show interface"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].link_status"
post_processor: "{{ obj[0] | cisco_interface_status_to_bool }}"
interfaces__802.1Q_mode:
commands:
- command: "show interface switchport"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].{mode: mode, trunking_vlans: trunking_vlans}"
post_processor: "{{ obj | nxos_switchport_mode_to_nautobot_interface_mode }}"
iterable_type: "str"
interfaces__lag:
commands:
- command: "show port-channel summary"
parser: "textfsm"
jpath: "[?contains(@.member_interface, '{{ current_key | abbreviated_interface_name(addl_reverse_map={'Ethernet': 'Eth'}) }}')].bundle_name"
post_processor: "{% if obj | length > 0 %}{{ obj[0] | canonical_interface_name(addl_name_map={'Po': 'port-channel'}) }}{% else %}[]{% endif %}"
iterable_type: "str"
interfaces__vrf:
commands:
- command: "show vrf interface"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].{name:name}"
iterable_type: "dict"
interfaces__tagged_vlans:
commands:
- command: "show interface switchport"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].{admin_mode: mode, mode: mode, access_vlan: access_vlan, trunking_vlans: trunking_vlans, native_vlan: native_vlan}"
post_processor: "{{ obj | get_vlan_data(vlan_map, 'tagged') | tojson }}"
interfaces__untagged_vlan:
commands:
- command: "show interface switchport"
parser: "textfsm"
jpath: "[?interface=='{{ current_key }}'].{admin_mode: mode, mode: mode, access_vlan: access_vlan, trunking_vlans: trunking_vlans, native_vlan: native_vlan}"
post_processor: "{{ obj | get_vlan_data(vlan_map, 'untagged') | tojson }}"
iterable_type: "dict"
cables:
commands:
- command: "show cdp neighbors detail"
parser: "textfsm"
jpath: "[*].{local_interface:local_interface, remote_interface:neighbor_interface, remote_device:neighbor_name}"
post_processor: "{% set result = [] %}{% for cable in obj %}{% set _=result.append({'local_interface': cable['local_interface'], 'remote_interface': cable['remote_interface'], 'remote_device': cable['remote_device'] | remove_fqdn }) %}{% endfor %}{{ result | tojson }}"
software_version:
commands:
- command: "show version"
parser: "textfsm"
jpath: "[*].os"