From 010681d7d950c11b0f50ea63ff20a714798949b8 Mon Sep 17 00:00:00 2001
From: Pierre Riteau <pierre@stackhpc.com>
Date: Thu, 9 Apr 2020 08:35:45 +0200
Subject: [PATCH] Filter out switch port descriptions on Ruckus switches

Some Ruckus switches, e.g. the Ruckus ICX 7150, advertise switch
interface names as switch port descriptions. Unlike Dell switches, there
is no space character between port type and port number. For example:
GigabitEthernet1/1/9.

Update regular expression to match both styles.

Change-Id: I359b07abadc8665ff0a8c3407ca0fc5effc504cf
Story: 2007532
Task: 39343
---
 ansible/group_vars/all/inspector                  | 15 ++++++++-------
 ...us-lldp-port-description-ad2b0774609aedbf.yaml |  6 ++++++
 2 files changed, 14 insertions(+), 7 deletions(-)
 create mode 100644 releasenotes/notes/filter-out-ruckus-lldp-port-description-ad2b0774609aedbf.yaml

diff --git a/ansible/group_vars/all/inspector b/ansible/group_vars/all/inspector
index 8a6e4ca6..b51f8eb4 100644
--- a/ansible/group_vars/all/inspector
+++ b/ansible/group_vars/all/inspector
@@ -194,24 +194,25 @@ inspector_rule_lldp_switch_port_desc_to_name:
       op: "is-empty"
       invert: True
     # Filter out switch port descriptions using the switch's interface names.
-    # On some switches (including Dell Network OS 9.10(0.1)), the port
-    # description TLV is sent but contains the interface name rather than the
-    # interface's description.
+    # On some switches (including Dell Network OS 9.10(0.1) and some Ruckus
+    # switches), the port description TLV is sent but contains the interface
+    # name rather than the interface's description. Dell switches use a space
+    # character between port type and port number, while Ruckus switches don't.
     - field: "data://all_interfaces.{{inspector_rule_var_lldp_switch_port_interface}}.lldp_processed.switch_port_description"
       op: "matches"
-      value: "^GigabitEthernet ([0-9/]*)$"
+      value: "^GigabitEthernet ?([0-9/]*)$"
       invert: True
     - field: "data://all_interfaces.{{inspector_rule_var_lldp_switch_port_interface}}.lldp_processed.switch_port_description"
       op: "matches"
-      value: "^TenGigabitEthernet ([0-9/]*)$"
+      value: "^TenGigabitEthernet ?([0-9/]*)$"
       invert: True
     - field: "data://all_interfaces.{{inspector_rule_var_lldp_switch_port_interface}}.lldp_processed.switch_port_description"
       op: "matches"
-      value: "^fortyGigE ([0-9/]*)$"
+      value: "^fortyGigE ?([0-9/]*)$"
       invert: True
     - field: "data://all_interfaces.{{inspector_rule_var_lldp_switch_port_interface}}.lldp_processed.switch_port_description"
       op: "matches"
-      value: "^Port-channel ([0-9/]*)$"
+      value: "^Port-channel ?([0-9/]*)$"
       invert: True
   actions:
     - action: "set-attribute"
diff --git a/releasenotes/notes/filter-out-ruckus-lldp-port-description-ad2b0774609aedbf.yaml b/releasenotes/notes/filter-out-ruckus-lldp-port-description-ad2b0774609aedbf.yaml
new file mode 100644
index 00000000..93f5a9c9
--- /dev/null
+++ b/releasenotes/notes/filter-out-ruckus-lldp-port-description-ad2b0774609aedbf.yaml
@@ -0,0 +1,6 @@
+---
+issues:
+  - |
+    Fixes an issue where the default inspector rule setting node names from
+    LLDP switch port descriptions would fail to filter out interface names on
+    Ruckus switches.
-- 
GitLab