Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 84d3610f authored by Lucas Nussbaum's avatar Lucas Nussbaum
Browse files

[dev] also adjust schema after moving linecards populating to input_loader

parent 5b502811
Branches
No related tags found
1 merge request!223move as much stuff as possible from refrepo/gen/reference-api.rb to input_loader.rb (bug 13083)
Pipeline #250843 passed
......@@ -630,8 +630,8 @@ def complete_one_network_equipment(network_uid, network)
network["linecards"].each do |linecard_index, linecard|
ports = []
linecard.delete("ports").each do |port_index, port|
port = { "uid"=> port } if port.is_a? String
if port.is_a? Hash
if not port.nil?
port = { "uid"=> port } if port.is_a? String
# complete entries (see bug 8587)
if port['port'].nil? and linecard['port']
port['port'] = linecard['port']
......@@ -644,14 +644,14 @@ def complete_one_network_equipment(network_uid, network)
end
if port['snmp_pattern']
port['snmp_name'] = port['snmp_pattern']
.sub('%LINECARD%',linecard_index.to_s).sub('%PORT%',port_index.to_s)
.sub('%LINECARD%',linecard_index.to_s).sub('%PORT%',port_index.to_s)
port.delete('snmp_pattern')
end
if ((!linecard['kind'].nil? &&
port['kind'].nil? &&
linecard['kind'] == 'node') ||
port['kind'] == 'node') &&
port['port'].nil?
port['kind'].nil? &&
linecard['kind'] == 'node') ||
port['kind'] == 'node') &&
port['port'].nil?
p = port['uid'].match(/([a-z]*-[0-9]*)-?(.*)/).captures[1]
port['port'] = p != '' ? p : 'eth0'
port['uid'] = port['uid'].gsub(/-#{p}$/, '')
......
......@@ -18,10 +18,10 @@ class HashValidator::Validator::LinecardPortValidator < HashValidator::Validator
if values["uid"].nil? || values["uid"].empty?
errors[key] = "port 'uid' property should be defined."
end
elsif values.is_a?(String) || values == nil
elsif values.is_a?(String) || values.is_a?(Numeric) || values == nil
#Allow any string and nil values
else
errors[key] = "port definition should be either empty, a String or a Hash (with required 'uid' and #{@port_properties} allowed properties)."
errors[key] = "port definition should be either empty, a String, a Numeric or a Hash (with required 'uid' and #{@port_properties} allowed properties)."
end
end
end
......
......@@ -29,17 +29,18 @@ vlans:
addresses: optional_array
mtu: optional_integer
linecards:
<multi>:
snmp_pattern: string
kavlan_pattern: optional_string
kind: optional_string
rate: integer
model: optional_string
backplane_bps: optional_integer
port: optional_string
ports:
# custom linecard port validation (see lib/custom-validators.rb)
<multi>: linecard_port
<array>:
snmp_pattern: optional_string
kavlan_pattern: optional_string
kind: optional_string
rate: optional_integer
model: optional_string
backplane_bps: optional_integer
port: optional_string
ports:
# custom linecard port validation (see lib/custom-validators.rb)
<optional_array>:
<multi>: linecard_port
channels:
<optional_hash>:
<multi>:
......@@ -48,3 +49,5 @@ channels:
kind: string
rate: integer
metrics: optional_array
uid: string
type: string
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment