From 661bc348365924b9892f204215c00a0b36285aea Mon Sep 17 00:00:00 2001 From: Kyle Robertson Date: Wed, 29 Jan 2020 12:03:35 -0500 Subject: [PATCH 1/2] New Template: Cisco NXOS show vdc Added template with tests to parse the `show vdc` command on Cisco NXOS devices. Useful if you are only given the IP to the default VDC but need to retrieve info from other vdcs as well. Modified index to include new template. --- templates/cisco_nxos_show_vdc.textfsm | 10 +++++++++ templates/index | 1 + .../show_vdc/cisco_nxos_show_vdc.raw | 8 +++++++ .../show_vdc/cisco_nxos_show_vdc.yml | 22 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 templates/cisco_nxos_show_vdc.textfsm create mode 100644 tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.raw create mode 100644 tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.yml diff --git a/templates/cisco_nxos_show_vdc.textfsm b/templates/cisco_nxos_show_vdc.textfsm new file mode 100644 index 0000000000..7c3c336b10 --- /dev/null +++ b/templates/cisco_nxos_show_vdc.textfsm @@ -0,0 +1,10 @@ +Value VDC_ID (\d+) +Value VDC_NAME (\S+) +Value STATE (\S+) +Value MAC (\S+) +Value TYPE (\S+) +Value LC (\S+) + +Start + ^\s*${VDC_ID}\s+${VDC_NAME}\s+${STATE}\s+${MAC}\s+${TYPE}\s+${LC} -> Record + diff --git a/templates/index b/templates/index index 5bbd3f556f..536f3a91c1 100644 --- a/templates/index +++ b/templates/index @@ -246,6 +246,7 @@ cisco_nxos_show_module.textfsm, .*, cisco_nxos, sh[[ow]] mod[[ule]] cisco_nxos_show_clock.textfsm, .*, cisco_nxos, sh[[ow]] clo[[ck]] cisco_nxos_show_vlan.textfsm, .*, cisco_nxos, sh[[ow]] vl[[an]] cisco_nxos_show_fex.textfsm, .*, cisco_nxos, sh[[ow]] fex +cisco_nxos_show_vdc.textfsm, .*, cisco_nxos, sh[[ow]] vdc cisco_nxos_show_vpc.textfsm, .*, cisco_nxos, sh[[ow]] vpc cisco_nxos_show_vrf.textfsm, .*, cisco_nxos, sh[[ow]] vrf diff --git a/tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.raw b/tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.raw new file mode 100644 index 0000000000..4f40b3e02e --- /dev/null +++ b/tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.raw @@ -0,0 +1,8 @@ + +Switchwide mode is m1 f1 m1xl f2 m2xl f2e f3 + +vdc_id vdc_name state mac type lc +------ -------- ----- ---------- --------- ------ +1 not1.barr1 active e4:c7:22:0c:67:c1 Admin None +2 foo1.bar1.bazz1 active e4:c7:22:0c:67:c2 Ethernet f2e +3 foo2.bar2.bazz2 active e4:c7:22:0c:67:c3 Ethernet f2e diff --git a/tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.yml b/tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.yml new file mode 100644 index 0000000000..058d192982 --- /dev/null +++ b/tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.yml @@ -0,0 +1,22 @@ +--- +parsed_sample: +- vdc_id: "1" + vdc_name: "not1.barr1" + state: "active" + mac: "e4:c7:22:0c:67:c1" + type: "Admin" + lc: "None" + +- vdc_id: "2" + vdc_name: "foo1.bar1.bazz1" + state: "active" + mac: "e4:c7:22:0c:67:c2" + type: "Ethernet" + lc: "f2e" + +- vdc_id: "3" + vdc_name: "foo2.bar2.bazz2" + state: "active" + mac: "e4:c7:22:0c:67:c3" + type: "Ethernet" + lc: "f2e" From 8262359bd528ad418623e48f24d600ac04df4e08 Mon Sep 17 00:00:00 2001 From: Mikhail Yohman Date: Tue, 4 Feb 2020 18:20:06 +0000 Subject: [PATCH 2/2] Applied requested changes --- templates/cisco_nxos_show_vdc.textfsm | 6 ++- .../show_vdc/cisco_nxos_show_vdc.yml | 38 +++++++++---------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/templates/cisco_nxos_show_vdc.textfsm b/templates/cisco_nxos_show_vdc.textfsm index 7c3c336b10..7187bf5518 100644 --- a/templates/cisco_nxos_show_vdc.textfsm +++ b/templates/cisco_nxos_show_vdc.textfsm @@ -6,5 +6,9 @@ Value TYPE (\S+) Value LC (\S+) Start + ^[Ss]witchwide\s+mode + ^vdc_id\s+vdc_name\s+state\s+mac\s+type\s+lc\s*$$ + ^-+ ^\s*${VDC_ID}\s+${VDC_NAME}\s+${STATE}\s+${MAC}\s+${TYPE}\s+${LC} -> Record - + ^\s*$$ + ^. -> Error diff --git a/tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.yml b/tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.yml index 058d192982..0e04e53359 100644 --- a/tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.yml +++ b/tests/cisco_nxos/show_vdc/cisco_nxos_show_vdc.yml @@ -1,22 +1,20 @@ --- parsed_sample: -- vdc_id: "1" - vdc_name: "not1.barr1" - state: "active" - mac: "e4:c7:22:0c:67:c1" - type: "Admin" - lc: "None" - -- vdc_id: "2" - vdc_name: "foo1.bar1.bazz1" - state: "active" - mac: "e4:c7:22:0c:67:c2" - type: "Ethernet" - lc: "f2e" - -- vdc_id: "3" - vdc_name: "foo2.bar2.bazz2" - state: "active" - mac: "e4:c7:22:0c:67:c3" - type: "Ethernet" - lc: "f2e" + - vdc_id: "1" + vdc_name: "not1.barr1" + state: "active" + mac: "e4:c7:22:0c:67:c1" + type: "Admin" + lc: "None" + - vdc_id: "2" + vdc_name: "foo1.bar1.bazz1" + state: "active" + mac: "e4:c7:22:0c:67:c2" + type: "Ethernet" + lc: "f2e" + - vdc_id: "3" + vdc_name: "foo2.bar2.bazz2" + state: "active" + mac: "e4:c7:22:0c:67:c3" + type: "Ethernet" + lc: "f2e"