diff --git a/data/grid5000/sites/nantes/clusters/ecotype/nodes/ecotype-47.json b/data/grid5000/sites/nantes/clusters/ecotype/nodes/ecotype-47.json index 80dbd332a3dcae164337388a3ca4e84cd9937d7a..8424a30b7f509430ac297f9911d2e19c32cfaa76 100644 --- a/data/grid5000/sites/nantes/clusters/ecotype/nodes/ecotype-47.json +++ b/data/grid5000/sites/nantes/clusters/ecotype/nodes/ecotype-47.json @@ -194,7 +194,7 @@ "device": "bmc", "enabled": true, "interface": "Ethernet", - "ip": "0.0.0.0", + "ip": "172.17.193.47", "kavlan": false, "mac": "50:9a:4c:a8:8d:9c", "management": true, diff --git a/lib/refrepo/input_loader.rb b/lib/refrepo/input_loader.rb index ec631f909eee4ce9bf3bcd34842db278932136e6..ca4171ccafc8be0531375030f75fb7ecfe828be2 100644 --- a/lib/refrepo/input_loader.rb +++ b/lib/refrepo/input_loader.rb @@ -452,6 +452,8 @@ def add_kavlan_ips(h) end end +BMC_OFFSET=256**2 + def add_ipv4(h) allocated = {} base = IPAddress::IPv4::new(h['ipv4']['base']).to_u32 @@ -463,13 +465,23 @@ def add_ipv4(h) raise "Node hash for #{node_uid} is nil" if hn.nil? node_id = node_uid.split('-')[1].to_i hn['network_adapters'].each_pair do |iface, v| - # only allocate mountable ethernet interfaces - next if not (v['mountable'] and ['Ethernet','FPGA/Ethernet'].include?(v['interface'])) - k = [site_uid, cluster_uid, iface] - if not iface_offsets.has_key?(k) - raise "Missing IPv4 information for #{k}" + # only allocate mountable ethernet interfaces and BMC + next if not ((v['mountable'] or v['management']) and ['Ethernet','FPGA/Ethernet'].include?(v['interface'])) + if iface == 'bmc' + # We pick up the mounted Ethernet interface and add an offset + prod_name = hn['network_adapters'].to_a.select { |e| e[1]['mounted'] and e[1]['interface'] == 'Ethernet' }.first[0] + k = [site_uid, cluster_uid, prod_name] + if not iface_offsets.has_key?(k) + raise "Missing IPv4 information for #{k}" + end + ip = IPAddress::IPv4::parse_u32(base + sites_offsets[site_uid] + iface_offsets[k] + node_id + BMC_OFFSET).to_s + else + k = [site_uid, cluster_uid, iface] + if not iface_offsets.has_key?(k) + raise "Missing IPv4 information for #{k}" + end + ip = IPAddress::IPv4::parse_u32(base + sites_offsets[site_uid] + iface_offsets[k] + node_id).to_s end - ip = IPAddress::IPv4::parse_u32(base + sites_offsets[site_uid] + iface_offsets[k] + node_id).to_s a = [ site_uid, node_uid, iface ] raise "IP already allocated: #{ip} (trying to add it to #{a} ; allocated to #{allocated[ip]})" if allocated[ip] allocated[ip] = a