Commit 01480990 authored by RINGOT Patrice's avatar RINGOT Patrice

[kavlang5k.rb] allow kavlan pattern to be given at the port level

parent 25c73d8b
Pipeline #200733 passed with stages
in 5 minutes and 41 seconds
......@@ -4,9 +4,11 @@ def kavlan_switch_port_lookup(switch, node_uid, interface='')
switch["linecards"].each_with_index do |lc, lc_uid|
next if not lc["ports"]
lc["ports"].each_with_index do |port, port_uid|
pattern_source = lc
if port.is_a?(Hash)
switch_remote_port = port["port"] || lc["port"] || ""
switch_remote_uid = port["uid"]
pattern_source = port if port.has_key?('snmp_pattern') or port.has_key?('kavlan_pattern')
else
switch_remote_port = lc["port"] || ""
switch_remote_uid = port
......@@ -15,7 +17,7 @@ def kavlan_switch_port_lookup(switch, node_uid, interface='')
if switch_remote_uid == node_uid and switch_remote_port == interface
# Build port name from snmp_naming_pattern
# Example: '3 2 GigabitEthernet%LINECARD%/%PORT%' -> 'GigabitEthernet3/2'
pattern = lc.has_key?("kavlan_pattern") ? lc["kavlan_pattern"] : lc["snmp_pattern"]
pattern = pattern_source.has_key?("kavlan_pattern") ? pattern_source["kavlan_pattern"] : pattern_source["snmp_pattern"]
port_name = pattern.sub("%LINECARD%",lc_uid.to_s).sub("%PORT%",port_uid.to_s)
return port_name
end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment