Mentions légales du service

Skip to content
Snippets Groups Projects
Commit ce39340e authored by RINGOT Patrice's avatar RINGOT Patrice
Browse files

Merge branch 'kavlan_pattern' into 'master'

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

See merge request !160
parents 25c73d8b 01480990
1 merge request!160[kavlang5k.rb] allow kavlan pattern to be given at the port level
Pipeline #200736 passed
...@@ -4,9 +4,11 @@ def kavlan_switch_port_lookup(switch, node_uid, interface='') ...@@ -4,9 +4,11 @@ def kavlan_switch_port_lookup(switch, node_uid, interface='')
switch["linecards"].each_with_index do |lc, lc_uid| switch["linecards"].each_with_index do |lc, lc_uid|
next if not lc["ports"] next if not lc["ports"]
lc["ports"].each_with_index do |port, port_uid| lc["ports"].each_with_index do |port, port_uid|
pattern_source = lc
if port.is_a?(Hash) if port.is_a?(Hash)
switch_remote_port = port["port"] || lc["port"] || "" switch_remote_port = port["port"] || lc["port"] || ""
switch_remote_uid = port["uid"] switch_remote_uid = port["uid"]
pattern_source = port if port.has_key?('snmp_pattern') or port.has_key?('kavlan_pattern')
else else
switch_remote_port = lc["port"] || "" switch_remote_port = lc["port"] || ""
switch_remote_uid = port switch_remote_uid = port
...@@ -15,7 +17,7 @@ def kavlan_switch_port_lookup(switch, node_uid, interface='') ...@@ -15,7 +17,7 @@ def kavlan_switch_port_lookup(switch, node_uid, interface='')
if switch_remote_uid == node_uid and switch_remote_port == interface if switch_remote_uid == node_uid and switch_remote_port == interface
# Build port name from snmp_naming_pattern # Build port name from snmp_naming_pattern
# Example: '3 2 GigabitEthernet%LINECARD%/%PORT%' -> 'GigabitEthernet3/2' # 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) port_name = pattern.sub("%LINECARD%",lc_uid.to_s).sub("%PORT%",port_uid.to_s)
return port_name return port_name
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment