From edc31a2aba30e6a84649da3ea33038747c886e53 Mon Sep 17 00:00:00 2001 From: PavloSkliarenko <78343937+PavloSkliarenko@users.noreply.github.com> Date: Mon, 22 Jul 2024 19:00:31 +0400 Subject: [PATCH] Add IOS show users template (#1475) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pskliarenko <“pskliarenko@bsh.ru”> Co-authored-by: Jacob McGill <9847006+jmcgill298@users.noreply.github.com> --- .../templates/cisco_ios_show_users.textfsm | 16 +++++++++++ ntc_templates/templates/index | 1 + .../show_users/cisco_ios_show_users.raw | 4 +++ .../show_users/cisco_ios_show_users.yml | 7 +++++ .../show_users/cisco_ios_show_users_all.raw | 8 ++++++ .../show_users/cisco_ios_show_users_all.yml | 27 +++++++++++++++++++ 6 files changed, 63 insertions(+) create mode 100644 ntc_templates/templates/cisco_ios_show_users.textfsm create mode 100644 tests/cisco_ios/show_users/cisco_ios_show_users.raw create mode 100644 tests/cisco_ios/show_users/cisco_ios_show_users.yml create mode 100644 tests/cisco_ios/show_users/cisco_ios_show_users_all.raw create mode 100644 tests/cisco_ios/show_users/cisco_ios_show_users_all.yml diff --git a/ntc_templates/templates/cisco_ios_show_users.textfsm b/ntc_templates/templates/cisco_ios_show_users.textfsm new file mode 100644 index 0000000000..385381a5fb --- /dev/null +++ b/ntc_templates/templates/cisco_ios_show_users.textfsm @@ -0,0 +1,16 @@ +Value LINE ((\*\s+)?\d+\s+(con|aux|tty|vty)\s+\d+) +Value USER (\S+) +Value HOSTS (\S+) +Value IDLE (\S+) +Value LOCATION (\S+) + +Start + ^\s*Line\s+User\s+Host\(s\)\s+Idle\s+Location\s*$$ -> UsersTable + ^\s*$$ + ^. -> Error + +UsersTable + ^\s*${LINE}(?:\s+${USER})?(?:\s+${HOSTS})?\s+${IDLE}(?:\s+${LOCATION})?\s*$$ -> Record + ^\s*Interface\s+User\s+Mode\s+Idle\s+Peer\s+Address\s*$$ + ^\s*$$ + ^. -> Error diff --git a/ntc_templates/templates/index b/ntc_templates/templates/index index 60b66e2c86..774dc3b01b 100644 --- a/ntc_templates/templates/index +++ b/ntc_templates/templates/index @@ -327,6 +327,7 @@ cisco_ios_show_ip_cef.textfsm, .*, cisco_ios, sh[[ow]] ip ce[[f]](?: vrf? \S+)?\ cisco_ios_show_tacacs.textfsm, .*, cisco_ios, sh[[ow]] tacacs cisco_ios_show_clock.textfsm, .*, cisco_ios, sh[[ow]] clo[[ck]] cisco_ios_show_dmvpn.textfsm, .*, cisco_ios, sh[[ow]] dm[[vpn]] +cisco_ios_show_users.textfsm, .*, cisco_ios, sh[[ow]] users(?: (?:a[[ll]]))? cisco_ios_show_vlans.textfsm, .*, cisco_ios, sh[[ow]] vlans cisco_ios_traceroute.textfsm, .*, cisco_ios, tr[[aceroute]] cisco_ios_show_boot.textfsm, .*, cisco_ios, sh[[ow]] boot diff --git a/tests/cisco_ios/show_users/cisco_ios_show_users.raw b/tests/cisco_ios/show_users/cisco_ios_show_users.raw new file mode 100644 index 0000000000..7851120a16 --- /dev/null +++ b/tests/cisco_ios/show_users/cisco_ios_show_users.raw @@ -0,0 +1,4 @@ + Line User Host(s) Idle Location +* 10 vty 0 arm idle 00:00:00 1.2.3.4 + + Interface User Mode Idle Peer Address diff --git a/tests/cisco_ios/show_users/cisco_ios_show_users.yml b/tests/cisco_ios/show_users/cisco_ios_show_users.yml new file mode 100644 index 0000000000..88abb8a2dd --- /dev/null +++ b/tests/cisco_ios/show_users/cisco_ios_show_users.yml @@ -0,0 +1,7 @@ +--- +parsed_sample: + - hosts: "idle" + idle: "00:00:00" + line: "* 10 vty 0" + location: "1.2.3.4" + user: "arm" diff --git a/tests/cisco_ios/show_users/cisco_ios_show_users_all.raw b/tests/cisco_ios/show_users/cisco_ios_show_users_all.raw new file mode 100644 index 0000000000..3bc9356ad2 --- /dev/null +++ b/tests/cisco_ios/show_users/cisco_ios_show_users_all.raw @@ -0,0 +1,8 @@ + Line User Host(s) Idle Location + 0 con 0 00:00:00 + 1 aux 0 00:00:00 +* 10 vty 0 arm idle 00:00:00 1.2.3.4 + 11 vty 1 00:00:00 + 12 vty 2 00:00:00 + + Interface User Mode Idle Peer Address diff --git a/tests/cisco_ios/show_users/cisco_ios_show_users_all.yml b/tests/cisco_ios/show_users/cisco_ios_show_users_all.yml new file mode 100644 index 0000000000..3be5e26fc6 --- /dev/null +++ b/tests/cisco_ios/show_users/cisco_ios_show_users_all.yml @@ -0,0 +1,27 @@ +--- +parsed_sample: + - hosts: "" + idle: "00:00:00" + line: "0 con 0" + location: "" + user: "" + - hosts: "" + idle: "00:00:00" + line: "1 aux 0" + location: "" + user: "" + - hosts: "idle" + idle: "00:00:00" + line: "* 10 vty 0" + location: "1.2.3.4" + user: "arm" + - hosts: "" + idle: "00:00:00" + line: "11 vty 1" + location: "" + user: "" + - hosts: "" + idle: "00:00:00" + line: "12 vty 2" + location: "" + user: ""