Commit 0f041aba authored by DELABROYE Dimitri's avatar DELABROYE Dimitri

[lib/gen/refapi] adapt refapi to new refapinet (backward compatible)

parent 6cff4de3
{
"backplane_bps": 36000000000000,
"channels": {
"port-channel-1": {
"kind": "router",
"ports": [
"Ethernet1/53",
"Ethernet1/54"
],
"rate": 200000000000,
"uid": "port-channel-1"
}
},
"ip": "172.17.47.221",
"kind": "switch",
"linecards": [
{
......@@ -7,7 +19,7 @@
{
"backplane_bps": 36000000000000,
"kavlan_pattern": "Ethernet%LINECARD%/%PORT%",
"kind": "virtual",
"kind": "node",
"ports": [
{
},
......@@ -212,15 +224,13 @@
{
},
{
"aggregation": "lacp",
"kind": "router",
"kind": "channel",
"port": "Ethernet1/52",
"rate": 100000000000,
"uid": "sw-chiclet-2"
},
{
"aggregation": "lacp",
"kind": "router",
"kind": "channel",
"port": "Ethernet1/51",
"rate": 100000000000,
"uid": "sw-chiclet-2"
......@@ -231,12 +241,6 @@
}
],
"model": "cisco 93180YC-EX",
"sensors": {
"network": {
"available": true,
"resolution": 1
}
},
"site": "lille",
"snmp_community": "public",
"type": "network_equipment",
......
{
"backplane_bps": 36000000000000,
"channels": {
"port-channel-1": {
"kind": "switch",
"ports": [
"Ethernet1/51",
"Ethernet1/52"
],
"rate": 200000000000,
"uid": "port-channel-1"
},
"port-channel-2": {
"kind": "switch",
"ports": [
"Ethernet1/53",
"Ethernet1/54"
],
"rate": 200000000000,
"uid": "port-channel-1"
}
},
"ip": "172.17.47.222",
"kind": "router",
"linecards": [
{
......@@ -7,8 +28,7 @@
{
"backplane_bps": 36000000000000,
"kavlan_pattern": "Ethernet%LINECARD%/%PORT%",
"kind": "virtual",
"port": "eth0",
"kind": "other",
"ports": [
{
},
......@@ -78,14 +98,13 @@
},
{
"kind": "other",
"port": "eth0",
"uid": "renater5-FON"
},
{
},
{
"kind": "other",
"port": "eth0",
"rate": 1000000000,
"uid": "labo"
},
{
......@@ -119,29 +138,25 @@
{
},
{
"aggregation": "lacp",
"kind": "switch",
"kind": "channel",
"port": "Ethernet1/54",
"rate": 100000000000,
"uid": "sw-chiclet-1"
},
{
"aggregation": "lacp",
"kind": "switch",
"kind": "channel",
"port": "Ethernet1/53",
"rate": 100000000000,
"uid": "sw-chiclet-1"
},
{
"aggregation": "lacp",
"kind": "switch",
"kind": "channel",
"port": "Ethernet1/53",
"rate": 100000000000,
"uid": "sw-chiclet-3"
},
{
"aggregation": "lacp",
"kind": "switch",
"kind": "channel",
"port": "Ethernet1/54",
"rate": 100000000000,
"uid": "sw-chiclet-3"
......@@ -152,12 +167,6 @@
}
],
"model": "cisco 93180YC-EX",
"sensors": {
"network": {
"available": true,
"resolution": 1
}
},
"site": "lille",
"snmp_community": "public",
"type": "network_equipment",
......
{
"backplane_bps": 36000000000000,
"channels": {
"port-channel-1": {
"kind": "router",
"ports": [
"Ethernet1/53",
"Ethernet1/54"
],
"rate": 200000000000,
"uid": "port-channel-2"
}
},
"ip": "172.17.47.223",
"kind": "switch",
"linecards": [
{
......@@ -7,7 +19,7 @@
{
"backplane_bps": 36000000000000,
"kavlan_pattern": "Ethernet%LINECARD%/%PORT%",
"kind": "virtual",
"kind": "node",
"ports": [
{
},
......@@ -254,15 +266,13 @@
{
},
{
"aggregation": "lacp",
"kind": "router",
"kind": "channel",
"port": "Ethernet1/53",
"rate": 100000000000,
"uid": "sw-chiclet-2"
},
{
"aggregation": "lacp",
"kind": "router",
"kind": "channel",
"port": "Ethernet1/54",
"rate": 100000000000,
"uid": "sw-chiclet-2"
......@@ -273,12 +283,6 @@
}
],
"model": "cisco 93180YC-EX",
"sensors": {
"network": {
"available": true,
"resolution": 1
}
},
"site": "lille",
"snmp_community": "public",
"type": "network_equipment",
......
......@@ -115,7 +115,8 @@
},
{
"kind": "node",
"uid": "node-mapping-undocumented-for-this-ib-switch"
"port": "mapping-undocumented-for-this-ib-switch",
"uid": "node"
}
],
"rate": 20000000000,
......
......@@ -35,11 +35,13 @@
},
{
"kind": "node",
"uid": "grele-13-when-undead"
"port": "when-undead",
"uid": "grele-13"
},
{
"kind": "node",
"uid": "grele-14-when-undead"
"port": "when-undead",
"uid": "grele-14"
}
],
"rate": 100000000000,
......
......@@ -7,7 +7,6 @@ require 'refrepo/valid/input/monitoring'
# the interface parameter must be used.
def net_switch_port_lookup(site, node_uid, interface='')
site["networks"].each do |switch_uid, switch|
#pp switch_uid
switch["linecards"].each do |lc_uid,lc|
lc["ports"].each do |port_uid,port|
if port.is_a?(Hash)
......@@ -17,6 +16,11 @@ def net_switch_port_lookup(site, node_uid, interface='')
switch_remote_port = lc["port"] || ""
switch_remote_uid = port
end
if switch_remote_uid =~ /([a-z]*-[0-9]*)-(.*)/
n, p = switch_remote_uid.match(/([a-z]*-[0-9]*)-(.*)/).captures
switch_remote_uid = n
switch_remote_port = p
end
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'
......@@ -30,7 +34,7 @@ def net_switch_port_lookup(site, node_uid, interface='')
end
# Creation du fichier network_equipment
def create_network_equipment(network_uid, network, refapi_path, site_uid=nil)
def create_network_equipment(network_uid, network, refapi_path, site_uid = nil)
network["type"] = "network_equipment"
network["uid"] = network_uid
......@@ -60,16 +64,19 @@ def create_network_equipment(network_uid, network, refapi_path, site_uid=nil)
if port['kind'].nil? and linecard['kind']
port['kind'] = linecard['kind']
end
if (!linecard['kind'].nil? and port['kind'].nil? and linecard['kind'] == 'node') or
port['kind'] == 'node' and
if ((!linecard['kind'].nil? &&
port['kind'].nil? &&
linecard['kind'] == 'node') ||
port['kind'] == 'node') &&
port['port'].nil?
p = port['uid'].match(/([a-z]*)-([0-9]*)-?(.*)/).captures[2]
p = port['uid'].match(/([a-z]*-[0-9]*)-?(.*)/).captures[1]
port['port'] = p != '' ? p : 'eth0'
port['uid'] = port['uid'].gsub(/-#{p}$/, '')
end
end
ports[port_index] = port
end
linecard["ports"] = ports.map{|p| p || {}}
linecard["ports"] = ports.map { |p| p || {} }
linecards_array[linecard_index] = linecard
end
network["linecards"] = linecards_array.map{|l| l || {}}
......
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