From d1f16a8512c3a1fc3949b8f9944550416ef777ef Mon Sep 17 00:00:00 2001 From: pskliarenko <“pskliarenko@bsh.ru”> Date: Sun, 10 Sep 2023 21:46:16 +0400 Subject: [PATCH 1/2] Template + test --- .../templates/cisco_ios_show_arp.textfsm | 16 ++++++++++ ntc_templates/templates/index | 1 + .../cisco_ios/show_arp/cisco_ios_show_arp.raw | 6 ++++ .../cisco_ios/show_arp/cisco_ios_show_arp.yml | 32 +++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 ntc_templates/templates/cisco_ios_show_arp.textfsm create mode 100644 tests/cisco_ios/show_arp/cisco_ios_show_arp.raw create mode 100644 tests/cisco_ios/show_arp/cisco_ios_show_arp.yml diff --git a/ntc_templates/templates/cisco_ios_show_arp.textfsm b/ntc_templates/templates/cisco_ios_show_arp.textfsm new file mode 100644 index 0000000000..8ff8c13675 --- /dev/null +++ b/ntc_templates/templates/cisco_ios_show_arp.textfsm @@ -0,0 +1,16 @@ +Value PROTOCOL (\S+) +Value ADDRESS (\S+) +Value AGE_MIN (\S+) +Value HARDWARE_ADDR ((?:([a-f0-9]{4}\.){2}[a-f0-9]{4})|Incomplete) +Value TYPE (\S+) +Value INTERFACE (\S+) + +Start + ^\s*Protocol\s+Address\s+Age\s+\(min\)\s+Hardware\s+Addr\s+Type\s+Interface\s*$$ -> ArpTable + ^\s*$$ + ^. -> Error + +ArpTable + ^\s*${PROTOCOL}\s+${ADDRESS}\s+${AGE_MIN}\s+${HARDWARE_ADDR}\s+${TYPE}(?:\s+${INTERFACE})?\s*$$ -> Record + ^\s*$$ + ^. -> Error diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 3a5b516184..0d551e70ce 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -304,6 +304,7 @@ cisco_ios_show_dmvpn.textfsm, .*, cisco_ios, sh[[ow]] dm[[vpn]] cisco_ios_traceroute.textfsm, .*, cisco_ios, tr[[aceroute]] cisco_ios_show_boot.textfsm, .*, cisco_ios, sh[[ow]] boot cisco_ios_show_vlan.textfsm, .*, cisco_ios, sh[[ow]] vlan +cisco_ios_show_arp.textfsm, .*, cisco_ios, sh[[ow]] arp cisco_ios_show_vrf.textfsm, .*, cisco_ios, sh[[ow]] vrf cisco_ios_ping.textfsm, .*, cisco_ios, ping cisco_ios_dir.textfsm, .*, cisco_ios, dir diff --git a/tests/cisco_ios/show_arp/cisco_ios_show_arp.raw b/tests/cisco_ios/show_arp/cisco_ios_show_arp.raw new file mode 100644 index 0000000000..3fc0b4827c --- /dev/null +++ b/tests/cisco_ios/show_arp/cisco_ios_show_arp.raw @@ -0,0 +1,6 @@ +Protocol Address Age (min) Hardware Addr Type Interface +Internet 10.100.88.1 - c4f7.d564.b716 ARPA Vlan10 +Internet 10.100.88.199 0 Incomplete ARPA +Internet 10.152.1.229 0 488f.5a5a.87ea ARPA Vlan1 +Internet 1.2.3.4 0 c4ad.3425.b7be ARPA FastEthernet4 +Internet 1.2.3.5 - c4f7.d564.b71a ARPA FastEthernet4 diff --git a/tests/cisco_ios/show_arp/cisco_ios_show_arp.yml b/tests/cisco_ios/show_arp/cisco_ios_show_arp.yml new file mode 100644 index 0000000000..6ed204ab62 --- /dev/null +++ b/tests/cisco_ios/show_arp/cisco_ios_show_arp.yml @@ -0,0 +1,32 @@ +--- +parsed_sample: + - address: "10.100.88.1" + age_min: "-" + hardware_addr: "c4f7.d564.b716" + interface: "Vlan10" + protocol: "Internet" + type: "ARPA" + - address: "10.100.88.199" + age_min: "0" + hardware_addr: "Incomplete" + interface: "" + protocol: "Internet" + type: "ARPA" + - address: "10.152.1.229" + age_min: "0" + hardware_addr: "488f.5a5a.87ea" + interface: "Vlan1" + protocol: "Internet" + type: "ARPA" + - address: "1.2.3.4" + age_min: "0" + hardware_addr: "c4ad.3425.b7be" + interface: "FastEthernet4" + protocol: "Internet" + type: "ARPA" + - address: "1.2.3.5" + age_min: "-" + hardware_addr: "c4f7.d564.b71a" + interface: "FastEthernet4" + protocol: "Internet" + type: "ARPA" From 6005ab64b5b10c2a32cde755819f1938e2c947b1 Mon Sep 17 00:00:00 2001 From: Jacob McGill <9847006+jmcgill298@users.noreply.github.com> Date: Mon, 22 Jul 2024 10:51:47 -0400 Subject: [PATCH 2/2] Apply suggestions from code review --- ntc_templates/templates/cisco_ios_show_arp.textfsm | 4 ++-- tests/cisco_ios/show_arp/cisco_ios_show_arp.yml | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ntc_templates/templates/cisco_ios_show_arp.textfsm b/ntc_templates/templates/cisco_ios_show_arp.textfsm index 8ff8c13675..b01b3460d9 100644 --- a/ntc_templates/templates/cisco_ios_show_arp.textfsm +++ b/ntc_templates/templates/cisco_ios_show_arp.textfsm @@ -1,7 +1,7 @@ Value PROTOCOL (\S+) Value ADDRESS (\S+) Value AGE_MIN (\S+) -Value HARDWARE_ADDR ((?:([a-f0-9]{4}\.){2}[a-f0-9]{4})|Incomplete) +Value HARDWARE_ADDRESS ((?:([a-f0-9]{4}\.){2}[a-f0-9]{4})|Incomplete) Value TYPE (\S+) Value INTERFACE (\S+) @@ -11,6 +11,6 @@ Start ^. -> Error ArpTable - ^\s*${PROTOCOL}\s+${ADDRESS}\s+${AGE_MIN}\s+${HARDWARE_ADDR}\s+${TYPE}(?:\s+${INTERFACE})?\s*$$ -> Record + ^\s*${PROTOCOL}\s+${ADDRESS}\s+${AGE_MIN}\s+${HARDWARE_ADDRESS}\s+${TYPE}(?:\s+${INTERFACE})?\s*$$ -> Record ^\s*$$ ^. -> Error diff --git a/tests/cisco_ios/show_arp/cisco_ios_show_arp.yml b/tests/cisco_ios/show_arp/cisco_ios_show_arp.yml index 6ed204ab62..222a2d01d6 100644 --- a/tests/cisco_ios/show_arp/cisco_ios_show_arp.yml +++ b/tests/cisco_ios/show_arp/cisco_ios_show_arp.yml @@ -2,31 +2,31 @@ parsed_sample: - address: "10.100.88.1" age_min: "-" - hardware_addr: "c4f7.d564.b716" + hardware_address: "c4f7.d564.b716" interface: "Vlan10" protocol: "Internet" type: "ARPA" - address: "10.100.88.199" age_min: "0" - hardware_addr: "Incomplete" + hardware_address: "Incomplete" interface: "" protocol: "Internet" type: "ARPA" - address: "10.152.1.229" age_min: "0" - hardware_addr: "488f.5a5a.87ea" + hardware_address: "488f.5a5a.87ea" interface: "Vlan1" protocol: "Internet" type: "ARPA" - address: "1.2.3.4" age_min: "0" - hardware_addr: "c4ad.3425.b7be" + hardware_address: "c4ad.3425.b7be" interface: "FastEthernet4" protocol: "Internet" type: "ARPA" - address: "1.2.3.5" age_min: "-" - hardware_addr: "c4f7.d564.b71a" + hardware_address: "c4f7.d564.b71a" interface: "FastEthernet4" protocol: "Internet" type: "ARPA"