From 57449a3767f20b2f71884d6a575d80aafcb9b8ff Mon Sep 17 00:00:00 2001 From: Kaigan Woodford Date: Thu, 10 Oct 2024 11:53:22 +1000 Subject: [PATCH 1/4] fix: Mikrotik ```interface print detail``` Update the Mikrotik ```interface print detail``` textfsm template to support routeros 7 changes. New supporting test validation & updated old test yaml to ensure backwards compatibility --- ...ik_routeros_interface_print_detail.textfsm | 11 +- ...krotik_routeros_interface_print_detail.yml | 34 +- ...tik_routeros_interface_print_detail_01.raw | 71 +++ ...tik_routeros_interface_print_detail_01.yml | 461 ++++++++++++++++++ 4 files changed, 561 insertions(+), 16 deletions(-) create mode 100644 tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail_01.raw create mode 100644 tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail_01.yml diff --git a/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm b/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm index 4d2dcea58d..c5dc586ed5 100644 --- a/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm +++ b/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm @@ -3,7 +3,7 @@ Value DYNAMIC (D) Value STATUS (X|R) Value SLAVE (S) Value NAME (\S+) -Value List DESCRIPTION ((?!\s*$).+[^\s]) +Value List DESCRIPTION (.+) Value DEFAULT_NAME (\S+) Value TYPE (\S+) Value MTU (\d+|auto) @@ -11,12 +11,13 @@ Value ACTUAL_MTU (\d+) Value L2MTU (\d+|auto) Value MAX_L2MTU (\d+) Value MAC_ADDRESS ([a-zA-Z0-9]{2}(?::[a-zA-Z0-9]{2}){5}) -Value LAST_LINK_DOWN_TIME ([a-z]{3}/\d+/\d+\s\d+\:\d+\:\d+) -Value LAST_LINK_UP_TIME ([a-z]{3}/\d+/\d+\s\d+\:\d+\:\d+) +Value LAST_LINK_DOWN_TIME ([a-z]{3}/\d+/\d+\s\d+\:\d+\:\d+|\d+-\d+-\d+\s*\d+:\d+:\d+) +Value LAST_LINK_UP_TIME ([a-z]{3}/\d+/\d+\s\d+\:\d+\:\d+|\d+-\d+-\d+\s*\d+:\d+:\d+) Value LINK_DOWNS (\d+) +Value VRF (\S+) Start - ^\s*Flags:\s+D\s+-\s+dynamic,\s+X\s+-\s+disabled,\s+R\s+-\s+running,\s+S\s+-\s+slave\s*$$ -> Interface + ^\s*Flags:\s+D\s+-\s+dynamic(;|,)\s+X\s+-\s+disabled,\s+R\s+-\s+running(;|,)\s+S\s+-\s+slave(;|,)?\s*(P\s+-\s+passthrough)?\s*$$ -> Interface ^\s*$$ ^. -> Error @@ -24,6 +25,8 @@ Interface ^\s*\d+(?:\s+D)?(?:\s*X|R)?(?:\s*S)?\s+ -> Continue.Record ^\s*${ID}(?:\s+${DYNAMIC})?(?:\s*${STATUS})?(?:\s*${SLAVE})?\s+name="${NAME}"(?:\s+default-name="${DEFAULT_NAME}")?\s+type="${TYPE}"(\s+mtu=${MTU})?(?:\s+actual-mtu=${ACTUAL_MTU})?(?:\s+l2mtu=${L2MTU})?(?:\s+max-l2mtu=${MAX_L2MTU})?(?:\s+mac-address=${MAC_ADDRESS})?(?:\s+last-link-down-time=${LAST_LINK_DOWN_TIME})?(?:\s+last-link-up-time=${LAST_LINK_UP_TIME})?(?:\s+link-downs=${LINK_DOWNS})?\s*$$ ^\s*name="${NAME}"(?:\s+default-name="${DEFAULT_NAME}")?\s+type="${TYPE}"(\s+mtu=${MTU})?(?:\s+actual-mtu=${ACTUAL_MTU})?(?:\s+l2mtu=${L2MTU})?(?:\s+max-l2mtu=${MAX_L2MTU})?(?:\s+mac-address=${MAC_ADDRESS})?(?:\s+last-link-down-time=${LAST_LINK_DOWN_TIME})?(?:\s+last-link-up-time=${LAST_LINK_UP_TIME})?(?:\s+link-downs=${LINK_DOWNS})?\s*$$ + ^\s*${ID}+\s*(?:${DYNAMIC})?\s*(?:${STATUS})?\s*(?:${SLAVE})?\s*name="${NAME}"(?:\s*default-name="${DEFAULT_NAME}")?\s*type="${TYPE}"\s*mtu=${MTU}\s*actual-mtu=${ACTUAL_MTU}\s*l2mtu=${L2MTU}\s*(max-l2mtu=${MAX_L2MTU}|vrf=${VRF})?\s*mac-address=${MAC_ADDRESS}\s*ifname="(\S+)"\s*ifindex=(\d+)\s*id=(\d+)(?:\s*last-link-down-time=${LAST_LINK_DOWN_TIME})?(?:\s*last-link-up-time=${LAST_LINK_UP_TIME})?\s*link-downs=${LINK_DOWNS}\s*$$ + ^\s*name="${NAME}"(?:\s*default-name="${DEFAULT_NAME}")?\s*type="${TYPE}"\s*mtu=${MTU}\s*actual-mtu=${ACTUAL_MTU}\s*l2mtu=${L2MTU}\s*(max-l2mtu=${MAX_L2MTU}|vrf=${VRF})?\s*mac-address=${MAC_ADDRESS}\s*ifname="(\S+)"\s*ifindex=(\d+)\s*id=(\d+)(?:\s*last-link-down-time=${LAST_LINK_DOWN_TIME})?(?:\s*last-link-up-time=${LAST_LINK_UP_TIME})?\s*link-downs=${LINK_DOWNS}\s*$$ ^\s*${ID}(?:\s+${DYNAMIC})?(?:\s*${STATUS})?(?:\s*${SLAVE})?\s+;{3}\s+${DESCRIPTION}\s*$$ ^${DESCRIPTION}\s*$$ ^\s*$$ diff --git a/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml index 2cc4e96b91..5576be86e9 100644 --- a/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml +++ b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml @@ -2,6 +2,7 @@ parsed_sample: - actual_mtu: "1500" default_name: "ether1" + description: [] dynamic: "" id: "0" l2mtu: "1598" @@ -12,12 +13,13 @@ parsed_sample: max_l2mtu: "2028" mtu: "1500" name: "ether1" - description: [] slave: "" status: "" type: "ether" + vrf: "" - actual_mtu: "1500" default_name: "ether2" + description: [] dynamic: "D" id: "1" l2mtu: "1598" @@ -28,12 +30,13 @@ parsed_sample: max_l2mtu: "2028" mtu: "1500" name: "ether2" - description: [] slave: "" status: "" type: "ether" + vrf: "" - actual_mtu: "1500" default_name: "ether3" + description: [] dynamic: "" id: "2" l2mtu: "1598" @@ -44,12 +47,13 @@ parsed_sample: max_l2mtu: "2028" mtu: "1500" name: "ether3" - description: [] slave: "" status: "R" type: "ether" + vrf: "" - actual_mtu: "1500" default_name: "ether4" + description: [] dynamic: "" id: "3" l2mtu: "1598" @@ -60,12 +64,13 @@ parsed_sample: max_l2mtu: "2028" mtu: "1500" name: "ether4" - description: [] slave: "S" status: "" type: "ether" + vrf: "" - actual_mtu: "1500" default_name: "ether5" + description: [] dynamic: "D" id: "4" l2mtu: "1598" @@ -76,12 +81,13 @@ parsed_sample: max_l2mtu: "2028" mtu: "1500" name: "ether5" - description: [] slave: "" status: "R" type: "ether" + vrf: "" - actual_mtu: "1500" default_name: "ether6" + description: [] dynamic: "" id: "5" l2mtu: "1598" @@ -92,12 +98,13 @@ parsed_sample: max_l2mtu: "2028" mtu: "1500" name: "ether6" - description: [] slave: "S" status: "R" type: "ether" + vrf: "" - actual_mtu: "1500" default_name: "" + description: [] dynamic: "D" id: "6" l2mtu: "" @@ -108,12 +115,16 @@ parsed_sample: max_l2mtu: "" mtu: "1500" name: "lte1" - description: [] slave: "S" status: "" type: "lte" + vrf: "" - actual_mtu: "1450" default_name: "" + description: + - "very very long" + - "multiline description " + - " " dynamic: "D" id: "7" l2mtu: "" @@ -124,14 +135,14 @@ parsed_sample: max_l2mtu: "" mtu: "1450" name: "pptp-out1" - description: - - "very very long" - - "multiline description" slave: "S" status: "R" type: "pptp-out" + vrf: "" - actual_mtu: "1596" default_name: "" + description: + - "Free Wi-Fi HTTPS" dynamic: "" id: "8" l2mtu: "" @@ -142,8 +153,7 @@ parsed_sample: max_l2mtu: "" mtu: "1596" name: "pptp-to-AH1100-HS" - description: - - "Free Wi-Fi HTTPS" slave: "S" status: "R" type: "pptp-out" + vrf: "" diff --git a/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail_01.raw b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail_01.raw new file mode 100644 index 0000000000..59046a801c --- /dev/null +++ b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail_01.raw @@ -0,0 +1,71 @@ +Flags: D - dynamic; X - disabled, R - running; S - slave; P - passthrough + 0 R ;;; Management Port - 4G OOB + name="ether1" default-name="ether1" type="ether" mtu=1500 actual-mtu=1500 l2mtu=1600 max-l2mtu=9586 mac-address=AA:BB:CC:11:22:33 ifname="eth0" ifindex=7 id=1 last-link-down-time=2024-10-08 11:14:27 last-link-up-time=2024-10-08 11:14:36 link-downs=166 + + 1 R ;;; Uplink + name="sfp-sfpplus1" default-name="sfp-sfpplus1" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth1" ifindex=9 id=2 last-link-up-time=2024-07-23 10:13:23 link-downs=0 + + 2 X ;;; Spare Optic + name="sfp-sfpplus2" default-name="sfp-sfpplus2" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth2" ifindex=10 id=3 link-downs=0 + + 3 X name="sfp-sfpplus3" default-name="sfp-sfpplus3" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth3" ifindex=11 id=4 link-downs=0 + + 4 X name="sfp-sfpplus4" default-name="sfp-sfpplus4" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth4" ifindex=12 id=5 link-downs=0 + + 5 X name="sfp-sfpplus5" default-name="sfp-sfpplus5" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth5" ifindex=13 id=6 link-downs=0 + + 6 X name="sfp-sfpplus6" default-name="sfp-sfpplus6" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth6" ifindex=14 id=7 link-downs=0 + + 7 X name="sfp-sfpplus7" default-name="sfp-sfpplus7" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth7" ifindex=15 id=8 link-downs=0 + + 8 X name="sfp-sfpplus8" default-name="sfp-sfpplus8" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth8" ifindex=16 id=9 link-downs=0 + + 9 RS ;;; Link to + name="sfp-sfpplus9" default-name="sfp-sfpplus9" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth9" ifindex=17 id=10 last-link-down-time=2024-08-23 12:53:56 last-link-up-time=2024-08-23 12:53:56 link-downs=4 + +10 RS ;;; Link to + name="sfp-sfpplus10" default-name="sfp-sfpplus10" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth10" ifindex=18 id=11 last-link-down-time=2024-08-23 12:53:27 last-link-up-time=2024-08-23 12:53:55 link-downs=5 + +11 R ;;; Cust + name="sfp-sfpplus11" default-name="sfp-sfpplus11" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth11" ifindex=19 id=12 last-link-down-time=2024-08-29 20:57:53 last-link-up-time=2024-09-19 23:00:35 link-downs=1 + +12 X ;;; Cust + name="sfp-sfpplus12" default-name="sfp-sfpplus12" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth12" ifindex=20 id=13 link-downs=0 + +13 X name="sfp28-1" default-name="sfp28-1" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth13" ifindex=21 id=14 link-downs=0 + +14 X name="sfp28-2" default-name="sfp28-2" type="ether" mtu=9216 actual-mtu=9216 l2mtu=9216 max-l2mtu=9578 mac-address=AA:BB:CC:11:22:33 ifname="eth14" ifindex=22 id=15 link-downs=0 + +15 R ;;; Loopback + name="Lo0" type="bridge" mtu=auto actual-mtu=1500 l2mtu=65535 mac-address=AA:BB:CC:11:22:33 ifname="br0" ifindex=24 id=23 last-link-up-time=2024-07-23 10:13:19 link-downs=0 + +16 R ;;; INET Loopback + name="Lo1" type="bridge" mtu=auto actual-mtu=1500 l2mtu=65535 vrf=INET mac-address=AA:BB:CC:11:22:33 ifname="br1" ifindex=36 id=27 last-link-up-time=2024-07-23 10:19:01 link-downs=0 + +17 R ;;; Link to + name="bond1" type="bond" mtu=1500 actual-mtu=1500 l2mtu=9216 mac-address=AA:BB:CC:11:22:33 ifname="bond24" ifindex=23 id=24 last-link-down-time=2024-08-23 12:53:27 last-link-up-time=2024-08-23 12:53:55 link-downs=3 + +18 R name="pppoe-out1" type="pppoe-out" mtu=1400 actual-mtu=1400 ifname="ppp25889" ifindex=25948 id=20 last-link-down-time=2024-10-08 12:36:57 last-link-up-time=2024-10-08 12:39:16 link-downs=7208 + +19 R ;;; MGMT + name="vlan1@bond1" type="vlan" mtu=1574 actual-mtu=1574 l2mtu=9212 mac-address=AA:BB:CC:11:22:33 ifname="vlan25" ifindex=27 id=25 last-link-down-time=2024-08-23 12:53:27 last-link-up-time=2024-08-23 12:53:55 link-downs=3 + +20 R ;;; INET + name="vlan2@bond1" type="vlan" mtu=1574 actual-mtu=1574 l2mtu=9212 vrf=INET mac-address=AA:BB:CC:11:22:33 ifname="vlan26" ifindex=28 id=26 last-link-down-time=2024-08-23 12:53:27 last-link-up-time=2024-08-23 12:53:55 link-downs=3 + +21 R ;;; MGMT Uplink YDCE-M1 + name="vlan10@vlan975@sfp-sfpplus1" type="vlan" mtu=1574 actual-mtu=1574 l2mtu=9208 mac-address=AA:BB:CC:11:22:33 ifname="vlan22" ifindex=33 id=22 last-link-up-time=2024-07-23 10:13:23 link-downs=0 + +22 R ;;; INET: IX + name="vlan11@vlan975@sfp-sfpplus1" type="vlan" mtu=1500 actual-mtu=1500 l2mtu=9208 vrf=INET mac-address=AA:BB:CC:11:22:33 ifname="vlan21" ifindex=31 id=21 last-link-up-time=2024-07-23 10:13:23 link-downs=0 + +23 R ;;; INET: IX + name="vlan12@vlan975@sfp-sfpplus1" type="vlan" mtu=1500 actual-mtu=1500 l2mtu=9208 vrf=INET mac-address=AA:BB:CC:11:22:33 ifname="vlan29" ifindex=38 id=29 last-link-up-time=2024-07-23 11:45:31 link-downs=0 + +24 R ;;; INET: IX + name="vlan111@sfp-sfpplus1" type="vlan" mtu=1500 actual-mtu=1500 l2mtu=9212 vrf=INET mac-address=AA:BB:CC:11:22:33 ifname="vlan18" ifindex=26 id=18 last-link-up-time=2024-07-23 10:13:23 link-downs=0 + +25 R ;;; Intercap + name="vlan975@sfp-sfpplus1" type="vlan" mtu=1500 actual-mtu=1500 l2mtu=9212 mac-address=AA:BB:CC:11:22:33 ifname="vlan16" ifindex=25 id=16 last-link-up-time=2024-07-23 10:13:23 link-downs=0 + +26 R name="vlan4050@sfp-sfpplus11" type="vlan" mtu=9212 actual-mtu=9212 l2mtu=9212 vrf=INET mac-address=AA:BB:CC:11:22:33 ifname="vlan30" ifindex=239 id=30 last-link-down-time=2024-08-29 20:57:53 last-link-up-time=2024-09-19 23:00:35 link-downs=1 \ No newline at end of file diff --git a/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail_01.yml b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail_01.yml new file mode 100644 index 0000000000..5214a024e9 --- /dev/null +++ b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail_01.yml @@ -0,0 +1,461 @@ +--- +parsed_sample: + - actual_mtu: "1500" + default_name: "ether1" + description: + - "Management Port - 4G OOB" + dynamic: "" + id: "0" + l2mtu: "1600" + last_link_down_time: "2024-10-08 11:14:27" + last_link_up_time: "2024-10-08 11:14:36" + link_downs: "166" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9586" + mtu: "1500" + name: "ether1" + slave: "" + status: "R" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus1" + description: + - "Uplink" + dynamic: "" + id: "1" + l2mtu: "9216" + last_link_down_time: "" + last_link_up_time: "2024-07-23 10:13:23" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus1" + slave: "" + status: "R" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus2" + description: + - "Spare Optic" + dynamic: "" + id: "2" + l2mtu: "9216" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus2" + slave: "" + status: "X" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus3" + description: [] + dynamic: "" + id: "3" + l2mtu: "9216" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus3" + slave: "" + status: "X" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus4" + description: [] + dynamic: "" + id: "4" + l2mtu: "9216" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus4" + slave: "" + status: "X" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus5" + description: [] + dynamic: "" + id: "5" + l2mtu: "9216" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus5" + slave: "" + status: "X" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus6" + description: [] + dynamic: "" + id: "6" + l2mtu: "9216" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus6" + slave: "" + status: "X" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus7" + description: [] + dynamic: "" + id: "7" + l2mtu: "9216" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus7" + slave: "" + status: "X" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus8" + description: [] + dynamic: "" + id: "8" + l2mtu: "9216" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus8" + slave: "" + status: "X" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus9" + description: + - "Link to" + dynamic: "" + id: "9" + l2mtu: "9216" + last_link_down_time: "2024-08-23 12:53:56" + last_link_up_time: "2024-08-23 12:53:56" + link_downs: "4" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus9" + slave: "S" + status: "R" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus10" + description: + - "Link to" + dynamic: "" + id: "10" + l2mtu: "9216" + last_link_down_time: "2024-08-23 12:53:27" + last_link_up_time: "2024-08-23 12:53:55" + link_downs: "5" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus10" + slave: "S" + status: "R" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus11" + description: + - "Cust" + dynamic: "" + id: "11" + l2mtu: "9216" + last_link_down_time: "2024-08-29 20:57:53" + last_link_up_time: "2024-09-19 23:00:35" + link_downs: "1" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus11" + slave: "" + status: "R" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp-sfpplus12" + description: + - "Cust" + dynamic: "" + id: "12" + l2mtu: "9216" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp-sfpplus12" + slave: "" + status: "X" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp28-1" + description: [] + dynamic: "" + id: "13" + l2mtu: "9216" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp28-1" + slave: "" + status: "X" + type: "ether" + vrf: "" + - actual_mtu: "9216" + default_name: "sfp28-2" + description: [] + dynamic: "" + id: "14" + l2mtu: "9216" + last_link_down_time: "" + last_link_up_time: "" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "9578" + mtu: "9216" + name: "sfp28-2" + slave: "" + status: "X" + type: "ether" + vrf: "" + - actual_mtu: "1500" + default_name: "" + description: + - "Loopback" + dynamic: "" + id: "15" + l2mtu: "65535" + last_link_down_time: "" + last_link_up_time: "2024-07-23 10:13:19" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "" + mtu: "auto" + name: "Lo0" + slave: "" + status: "R" + type: "bridge" + vrf: "" + - actual_mtu: "1500" + default_name: "" + description: + - "INET Loopback" + dynamic: "" + id: "16" + l2mtu: "65535" + last_link_down_time: "" + last_link_up_time: "2024-07-23 10:19:01" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "" + mtu: "auto" + name: "Lo1" + slave: "" + status: "R" + type: "bridge" + vrf: "INET" + - actual_mtu: "1500" + default_name: "" + description: + - "Link to" + dynamic: "" + id: "17" + l2mtu: "9216" + last_link_down_time: "2024-08-23 12:53:27" + last_link_up_time: "2024-08-23 12:53:55" + link_downs: "3" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "" + mtu: "1500" + name: "bond1" + slave: "" + status: "R" + type: "bond" + vrf: "" + - actual_mtu: "1574" + default_name: "" + description: + - "MGMT" + dynamic: "" + id: "19" + l2mtu: "9212" + last_link_down_time: "2024-08-23 12:53:27" + last_link_up_time: "2024-08-23 12:53:55" + link_downs: "3" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "" + mtu: "1574" + name: "vlan1@bond1" + slave: "" + status: "R" + type: "vlan" + vrf: "" + - actual_mtu: "1574" + default_name: "" + description: + - "INET" + dynamic: "" + id: "20" + l2mtu: "9212" + last_link_down_time: "2024-08-23 12:53:27" + last_link_up_time: "2024-08-23 12:53:55" + link_downs: "3" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "" + mtu: "1574" + name: "vlan2@bond1" + slave: "" + status: "R" + type: "vlan" + vrf: "INET" + - actual_mtu: "1574" + default_name: "" + description: + - "MGMT Uplink YDCE-M1" + dynamic: "" + id: "21" + l2mtu: "9208" + last_link_down_time: "" + last_link_up_time: "2024-07-23 10:13:23" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "" + mtu: "1574" + name: "vlan10@vlan975@sfp-sfpplus1" + slave: "" + status: "R" + type: "vlan" + vrf: "" + - actual_mtu: "1500" + default_name: "" + description: + - "INET: IX" + dynamic: "" + id: "22" + l2mtu: "9208" + last_link_down_time: "" + last_link_up_time: "2024-07-23 10:13:23" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "" + mtu: "1500" + name: "vlan11@vlan975@sfp-sfpplus1" + slave: "" + status: "R" + type: "vlan" + vrf: "INET" + - actual_mtu: "1500" + default_name: "" + description: + - "INET: IX" + dynamic: "" + id: "23" + l2mtu: "9208" + last_link_down_time: "" + last_link_up_time: "2024-07-23 11:45:31" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "" + mtu: "1500" + name: "vlan12@vlan975@sfp-sfpplus1" + slave: "" + status: "R" + type: "vlan" + vrf: "INET" + - actual_mtu: "1500" + default_name: "" + description: + - "INET: IX" + dynamic: "" + id: "24" + l2mtu: "9212" + last_link_down_time: "" + last_link_up_time: "2024-07-23 10:13:23" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "" + mtu: "1500" + name: "vlan111@sfp-sfpplus1" + slave: "" + status: "R" + type: "vlan" + vrf: "INET" + - actual_mtu: "1500" + default_name: "" + description: + - "Intercap" + dynamic: "" + id: "25" + l2mtu: "9212" + last_link_down_time: "" + last_link_up_time: "2024-07-23 10:13:23" + link_downs: "0" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "" + mtu: "1500" + name: "vlan975@sfp-sfpplus1" + slave: "" + status: "R" + type: "vlan" + vrf: "" + - actual_mtu: "9212" + default_name: "" + description: [] + dynamic: "" + id: "26" + l2mtu: "9212" + last_link_down_time: "2024-08-29 20:57:53" + last_link_up_time: "2024-09-19 23:00:35" + link_downs: "1" + mac_address: "AA:BB:CC:11:22:33" + max_l2mtu: "" + mtu: "9212" + name: "vlan4050@sfp-sfpplus11" + slave: "" + status: "R" + type: "vlan" + vrf: "INET" From 9765594fa379c898cf8c19a7b0dc3be0b1d1f08a Mon Sep 17 00:00:00 2001 From: Kaigan Woodford Date: Mon, 14 Oct 2024 15:40:38 +1100 Subject: [PATCH 2/4] Fix description multiline regex Remove leading & trailing whitespace in multiline comments --- .../templates/mikrotik_routeros_interface_print_detail.textfsm | 2 +- .../mikrotik_routeros_interface_print_detail.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm b/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm index c5dc586ed5..9fe241d2b5 100644 --- a/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm +++ b/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm @@ -3,7 +3,7 @@ Value DYNAMIC (D) Value STATUS (X|R) Value SLAVE (S) Value NAME (\S+) -Value List DESCRIPTION (.+) +Value List DESCRIPTION (\s*.+?) Value DEFAULT_NAME (\S+) Value TYPE (\S+) Value MTU (\d+|auto) diff --git a/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml index 5576be86e9..c499871ca9 100644 --- a/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml +++ b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml @@ -123,7 +123,7 @@ parsed_sample: default_name: "" description: - "very very long" - - "multiline description " + - "multiline description" - " " dynamic: "D" id: "7" From 400c105306c0cd0618e11d9bd4fe319ee56f31b6 Mon Sep 17 00:00:00 2001 From: Kaigan Woodford Date: Thu, 17 Oct 2024 08:39:38 +1100 Subject: [PATCH 3/4] Fixes multiline description regexes --- .../mikrotik_routeros_interface_print_detail.textfsm | 4 ++-- .../mikrotik_routeros_interface_print_detail.yml | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm b/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm index 9fe241d2b5..523c934fc1 100644 --- a/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm +++ b/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm @@ -3,7 +3,7 @@ Value DYNAMIC (D) Value STATUS (X|R) Value SLAVE (S) Value NAME (\S+) -Value List DESCRIPTION (\s*.+?) +Value List DESCRIPTION ((?:\S).+?) Value DEFAULT_NAME (\S+) Value TYPE (\S+) Value MTU (\d+|auto) @@ -28,6 +28,6 @@ Interface ^\s*${ID}+\s*(?:${DYNAMIC})?\s*(?:${STATUS})?\s*(?:${SLAVE})?\s*name="${NAME}"(?:\s*default-name="${DEFAULT_NAME}")?\s*type="${TYPE}"\s*mtu=${MTU}\s*actual-mtu=${ACTUAL_MTU}\s*l2mtu=${L2MTU}\s*(max-l2mtu=${MAX_L2MTU}|vrf=${VRF})?\s*mac-address=${MAC_ADDRESS}\s*ifname="(\S+)"\s*ifindex=(\d+)\s*id=(\d+)(?:\s*last-link-down-time=${LAST_LINK_DOWN_TIME})?(?:\s*last-link-up-time=${LAST_LINK_UP_TIME})?\s*link-downs=${LINK_DOWNS}\s*$$ ^\s*name="${NAME}"(?:\s*default-name="${DEFAULT_NAME}")?\s*type="${TYPE}"\s*mtu=${MTU}\s*actual-mtu=${ACTUAL_MTU}\s*l2mtu=${L2MTU}\s*(max-l2mtu=${MAX_L2MTU}|vrf=${VRF})?\s*mac-address=${MAC_ADDRESS}\s*ifname="(\S+)"\s*ifindex=(\d+)\s*id=(\d+)(?:\s*last-link-down-time=${LAST_LINK_DOWN_TIME})?(?:\s*last-link-up-time=${LAST_LINK_UP_TIME})?\s*link-downs=${LINK_DOWNS}\s*$$ ^\s*${ID}(?:\s+${DYNAMIC})?(?:\s*${STATUS})?(?:\s*${SLAVE})?\s+;{3}\s+${DESCRIPTION}\s*$$ - ^${DESCRIPTION}\s*$$ ^\s*$$ + ^\s*${DESCRIPTION}\s*$$ ^. -> Error diff --git a/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml index c499871ca9..6d16deaed3 100644 --- a/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml +++ b/tests/mikrotik_routeros/interface_print_detail/mikrotik_routeros_interface_print_detail.yml @@ -124,7 +124,6 @@ parsed_sample: description: - "very very long" - "multiline description" - - " " dynamic: "D" id: "7" l2mtu: "" From c5466bd49da01c66c4a79e9273e4b6e249a9c497 Mon Sep 17 00:00:00 2001 From: Kaigan Woodford Date: Thu, 17 Oct 2024 08:45:52 +1100 Subject: [PATCH 4/4] Removed left over regex from testing --- .../templates/mikrotik_routeros_interface_print_detail.textfsm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm b/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm index 523c934fc1..2fec94d7ec 100644 --- a/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm +++ b/ntc_templates/templates/mikrotik_routeros_interface_print_detail.textfsm @@ -3,7 +3,7 @@ Value DYNAMIC (D) Value STATUS (X|R) Value SLAVE (S) Value NAME (\S+) -Value List DESCRIPTION ((?:\S).+?) +Value List DESCRIPTION (.+?) Value DEFAULT_NAME (\S+) Value TYPE (\S+) Value MTU (\d+|auto)