From e2b4bc6c7228d2bd3391e55d70dbd1dbc2e382eb Mon Sep 17 00:00:00 2001 From: Olof Lundgren Date: Mon, 1 Oct 2018 20:31:44 +0200 Subject: [PATCH 1/2] ubiquiti edgeswitch show arp, show vlan --- templates/index | 3 +++ .../ubiquiti_edgeswitch_show_arp.template | 13 +++++++++++ .../ubiquiti_edgeswitch_show_vlan.template | 11 ++++++++++ tests/test_index_order.py | 4 ++-- .../ubiquiti_edgeswitch_show_arp.parsed | 22 +++++++++++++++++++ .../show_arp/ubiquiti_edgeswitch_show_arp.raw | 15 +++++++++++++ .../ubiquiti_edgeswitch_show_vlan.parsed | 17 ++++++++++++++ .../ubiquiti_edgeswitch_show_vlan.raw | 7 ++++++ 8 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 templates/ubiquiti_edgeswitch_show_arp.template create mode 100644 templates/ubiquiti_edgeswitch_show_vlan.template create mode 100644 tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.parsed create mode 100644 tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.raw create mode 100644 tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.parsed create mode 100644 tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.raw diff --git a/templates/index b/templates/index index 452145d8b5..713b908bf3 100644 --- a/templates/index +++ b/templates/index @@ -262,5 +262,8 @@ paloalto_panos_show_counter_global.template, .*, paloalto_panos, sh[[ow]] coun[[ paloalto_panos_show_system_info.template, .*, paloalto_panos, sh[[ow]] sys[[tem]] in[[fo]] paloalto_panos_show_jobs_all.template, .*, paloalto_panos, sh[[ow]] jo[[bs]] all +ubiquiti_edgeswitch_show_vlan.template, .*, ubiquiti_edgeswitch, sh[[ow]] vl[[an]] +ubiquiti_edgeswitch_show_arp.template, .*, ubiquiti_edgeswitch, sh[[ow]] ar[[p]] + vmware_nsxv_show_ip_bgp_neighbors.template, .*, vmware_nsxv, sh[[ow]] ip b[[gp]] n[[eighbors]] vmware_nsxv_show_ip_route.template, .*, vmware_nsxv, sh[[ow]] ip r[[oute]] diff --git a/templates/ubiquiti_edgeswitch_show_arp.template b/templates/ubiquiti_edgeswitch_show_arp.template new file mode 100644 index 0000000000..daab738982 --- /dev/null +++ b/templates/ubiquiti_edgeswitch_show_arp.template @@ -0,0 +1,13 @@ +Value ADDRESS (\d+\.\d+\.\d+\.\d+) +Value MAC (\S+) +Value INTERFACE (\S+) +Value TYPE (\S+) +Value AGE (.*) + +Start + ^\s+IP Address -> ARP + +ARP + ^${ADDRESS}\s+${MAC}\s+${INTERFACE}\s+${TYPE}\s+${AGE}.*$$ -> Record + ^-+\s+-+\s+-+\s+-+\s+-+\s*$$ + ^.*$$ -> Error diff --git a/templates/ubiquiti_edgeswitch_show_vlan.template b/templates/ubiquiti_edgeswitch_show_vlan.template new file mode 100644 index 0000000000..45d39b303c --- /dev/null +++ b/templates/ubiquiti_edgeswitch_show_vlan.template @@ -0,0 +1,11 @@ +Value VLAN_ID (\d+) +Value NAME (.*?) +Value TYPE (\w+) + +Start + ^VLAN ID -> VLAN + +VLAN + ^${VLAN_ID}\s+${NAME}\s+${TYPE}\s*$$ -> Record + ^-+\s+-+\s+-+\s*$$ + ^.*$$ -> Error diff --git a/tests/test_index_order.py b/tests/test_index_order.py index a34adc1999..3380b135fd 100644 --- a/tests/test_index_order.py +++ b/tests/test_index_order.py @@ -66,8 +66,8 @@ def test_index_ordering(): 'checkpoint_gaia', 'cisco_asa', 'cisco_ios', 'cisco_nxos', 'cisco_s300', 'cisco_wlc', 'cisco_xe', 'cisco_xr', 'dell_force10', 'enterasys', 'extreme', 'f5_ltm', 'fortinet', 'hp_comware', 'hp_procurve', 'huawei', 'juniper', 'juniper_junos', 'juniper_screenos', - 'alcatel_sros', 'linux', 'ovs_linux', 'paloalto_panos', 'quanta_mesh', 'vmware_nsxv', - 'vyatta_vyos', 'vyos' + 'alcatel_sros', 'linux', 'ovs_linux', 'paloalto_panos', 'quanta_mesh', + 'ubiquiti_edgeswitch', 'vmware_nsxv', 'vyatta_vyos', 'vyos' ] prior_os = "" diff --git a/tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.parsed b/tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.parsed new file mode 100644 index 0000000000..34e145bd23 --- /dev/null +++ b/tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.parsed @@ -0,0 +1,22 @@ +--- +parsed_sample: +- address: "172.16.216.1" + age: "0h 0m 10s" + interface: "4/1" + mac: "80:2A:A8:F1:D2:46" + type: "Gateway" +- address: "172.16.216.2" + age: "0h 2m 16s" + interface: "4/1" + mac: "E2:91:F5:CC:E8:19" + type: "Dynamic" +- address: "172.16.216.4" + age: "n/a" + interface: "4/1" + mac: "78:8A:20:44:02:7F" + type: "Local" +- address: "172.16.216.33" + age: "0h 0m 5s" + interface: "4/1" + mac: "00:00:00:00:00:00" + type: "Dynamic" diff --git a/tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.raw b/tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.raw new file mode 100644 index 0000000000..c63c595324 --- /dev/null +++ b/tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.raw @@ -0,0 +1,15 @@ + +Age Time (seconds)............................. 300 +Response Time (seconds)........................ 1 +Retries........................................ 4 +Cache Size..................................... 493 +Dynamic Renew Mode ............................ Disable +Total Entry Count Current / Peak .............. 4 / 4 +Static Entry Count Configured / Active / Max .. 0 / 0 / 128 + + IP Address MAC Address Interface Type Age +--------------- ----------------- -------------- -------- ----------- +172.16.216.1 80:2A:A8:F1:D2:46 4/1 Gateway 0h 0m 10s +172.16.216.2 E2:91:F5:CC:E8:19 4/1 Dynamic 0h 2m 16s +172.16.216.4 78:8A:20:44:02:7F 4/1 Local n/a +172.16.216.33 00:00:00:00:00:00 4/1 Dynamic 0h 0m 5s \ No newline at end of file diff --git a/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.parsed b/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.parsed new file mode 100644 index 0000000000..4a1d4435c2 --- /dev/null +++ b/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.parsed @@ -0,0 +1,17 @@ +--- +parsed_sample: +- name: "default" + type: "Default" + vlan_id: "1" +- name: "ip tv" + type: "Static" + vlan_id: "101" +- name: "internet" + type: "Static" + vlan_id: "102" +- name: "hjemmenett" + type: "Static" + vlan_id: "216" +- name: "server" + type: "Static" + vlan_id: "217" \ No newline at end of file diff --git a/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.raw b/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.raw new file mode 100644 index 0000000000..7246b7e461 --- /dev/null +++ b/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.raw @@ -0,0 +1,7 @@ +VLAN ID VLAN Name VLAN Type +------- -------------------------------- ------------------- +1 default Default +101 ip tv Static +102 internet Static +216 hjemmenett Static +217 server Static \ No newline at end of file From 898dcebe75e238879fbb6d5ad19c51558a3719e7 Mon Sep 17 00:00:00 2001 From: jmcgill Date: Sun, 14 Oct 2018 19:15:21 -0400 Subject: [PATCH 2/2] Update match lines to be more specific --- templates/ubiquiti_edgeswitch_show_arp.template | 10 +++++----- templates/ubiquiti_edgeswitch_show_vlan.template | 11 +++++------ .../show_arp/ubiquiti_edgeswitch_show_arp.raw | 2 +- .../show_vlans/ubiquiti_edgeswitch_show_vlan.parsed | 2 +- .../show_vlans/ubiquiti_edgeswitch_show_vlan.raw | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/templates/ubiquiti_edgeswitch_show_arp.template b/templates/ubiquiti_edgeswitch_show_arp.template index daab738982..f408d5cefe 100644 --- a/templates/ubiquiti_edgeswitch_show_arp.template +++ b/templates/ubiquiti_edgeswitch_show_arp.template @@ -1,13 +1,13 @@ -Value ADDRESS (\d+\.\d+\.\d+\.\d+) +Value Required ADDRESS (\d+\.\d+\.\d+\.\d+) Value MAC (\S+) Value INTERFACE (\S+) Value TYPE (\S+) Value AGE (.*) Start - ^\s+IP Address -> ARP - -ARP ^${ADDRESS}\s+${MAC}\s+${INTERFACE}\s+${TYPE}\s+${AGE}.*$$ -> Record + ^.+\. + ^\s+IP\s+Address\s+MAC\s+Address\s+Interface\s+Type\s+Age ^-+\s+-+\s+-+\s+-+\s+-+\s*$$ - ^.*$$ -> Error + ^\s*$$ + ^. -> Error diff --git a/templates/ubiquiti_edgeswitch_show_vlan.template b/templates/ubiquiti_edgeswitch_show_vlan.template index 45d39b303c..4d1d86ac49 100644 --- a/templates/ubiquiti_edgeswitch_show_vlan.template +++ b/templates/ubiquiti_edgeswitch_show_vlan.template @@ -1,11 +1,10 @@ -Value VLAN_ID (\d+) +Value Required VLAN_ID (\d+) Value NAME (.*?) -Value TYPE (\w+) +Value TYPE (\S+) Start - ^VLAN ID -> VLAN - -VLAN ^${VLAN_ID}\s+${NAME}\s+${TYPE}\s*$$ -> Record + ^VLAN\s+ID\s+VLAN\s+Name\s+VLAN\s+Type\s*$$ ^-+\s+-+\s+-+\s*$$ - ^.*$$ -> Error + ^\s*$$ + ^. -> Error diff --git a/tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.raw b/tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.raw index c63c595324..0a393426b4 100644 --- a/tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.raw +++ b/tests/ubiquiti_edgeswitch/show_arp/ubiquiti_edgeswitch_show_arp.raw @@ -12,4 +12,4 @@ Static Entry Count Configured / Active / Max .. 0 / 0 / 128 172.16.216.1 80:2A:A8:F1:D2:46 4/1 Gateway 0h 0m 10s 172.16.216.2 E2:91:F5:CC:E8:19 4/1 Dynamic 0h 2m 16s 172.16.216.4 78:8A:20:44:02:7F 4/1 Local n/a -172.16.216.33 00:00:00:00:00:00 4/1 Dynamic 0h 0m 5s \ No newline at end of file +172.16.216.33 00:00:00:00:00:00 4/1 Dynamic 0h 0m 5s diff --git a/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.parsed b/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.parsed index 4a1d4435c2..9e1ee72639 100644 --- a/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.parsed +++ b/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.parsed @@ -14,4 +14,4 @@ parsed_sample: vlan_id: "216" - name: "server" type: "Static" - vlan_id: "217" \ No newline at end of file + vlan_id: "217" diff --git a/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.raw b/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.raw index 7246b7e461..9066be960e 100644 --- a/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.raw +++ b/tests/ubiquiti_edgeswitch/show_vlans/ubiquiti_edgeswitch_show_vlan.raw @@ -4,4 +4,4 @@ VLAN ID VLAN Name VLAN Type 101 ip tv Static 102 internet Static 216 hjemmenett Static -217 server Static \ No newline at end of file +217 server Static