Commit 2dcbc3ec authored by DELABROYE Dimitri's avatar DELABROYE Dimitri
Browse files

Merge branch 'bug_9938' into 'master'

Bug 9861 changement des donnees d'entrees des generateurs

See merge request !11
parents 3d5e6b50 a5658453
Pipeline #87156 passed with stages
in 1 minute and 48 seconds
{
"created_at": "Thu, 22 Mar 2018 11:00:00 GMT",
"created_at": "Thu, 22 Mar 2018 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge C6420",
"priority": "201800",
......
{
"created_at": "Tue, 16 Jan 2018 15:00:00 GMT",
"created_at": "Tue, 16 Jan 2018 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R940",
"queues": [
......
{
"created_at": "Wed, 30 Nov 2016 23:00:00 GMT",
"created_at": "Thu, 01 Dec 2016 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R630",
"priority": "201650",
......
{
"created_at": "Sun, 05 Aug 2018 22:00:00 GMT",
"created_at": "Mon, 06 Aug 2018 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R7425",
"priority": "201850",
......
{
"created_at": "Wed, 30 Nov 2016 23:00:00 GMT",
"created_at": "Thu, 01 Dec 2016 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R730",
"priority": "201670",
......
{
"created_at": "Tue, 31 Jul 2018 22:00:00 GMT",
"created_at": "Wed, 01 Aug 2018 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R740",
"priority": "201870",
......
{
"created_at": "Wed, 30 Nov 2011 23:00:00 GMT",
"created_at": "Thu, 01 Dec 2011 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge 1950",
"queues": [
......
{
"created_at": "Mon, 09 Sep 2013 22:00:00 GMT",
"created_at": "Tue, 10 Sep 2013 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge M620",
"queues": [
......
{
"created_at": "Tue, 02 Oct 2012 12:00:00 GMT",
"created_at": "Tue, 02 Oct 2012 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge C6220",
"priority": "201299",
......
{
"created_at": "Thu, 01 Dec 2016 12:00:00 GMT",
"created_at": "Thu, 01 Dec 2016 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R430",
"priority": "201700",
......
{
"created_at": "Fri, 14 Sep 2012 12:00:00 GMT",
"created_at": "Fri, 14 Sep 2012 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R720",
"priority": "201299",
......
{
"created_at": "Sat, 01 Jul 2006 12:00:00 GMT",
"created_at": "Sat, 01 Jul 2006 00:00:00 GMT",
"kavlan": true,
"model": "Sun Fire V20z",
"priority": "201899",
......
{
"created_at": "Fri, 14 Sep 2012 12:00:00 GMT",
"created_at": "Fri, 14 Sep 2012 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R720",
"queues": [
......
{
"created_at": "Thu, 06 Jun 2019 22:00:00 GMT",
"created_at": "Fri, 07 Jun 2019 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge T640",
"queues": [
......
{
"created_at": "Sun, 03 Jan 2016 23:00:00 GMT",
"created_at": "Mon, 04 Jan 2016 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R630",
"queues": [
......
{
"created_at": "Tue, 12 May 2015 17:00:00 GMT",
"created_at": "Tue, 12 May 2015 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R720",
"queues": [
......
{
"created_at": "Wed, 04 Dec 2013 23:00:00 GMT",
"created_at": "Thu, 05 Dec 2013 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R720",
"queues": [
......
{
"created_at": "Mon, 08 Apr 2013 22:00:00 GMT",
"created_at": "Tue, 09 Apr 2013 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge C6220",
"queues": [
......
{
"created_at": "Sun, 25 Jun 2017 22:00:00 GMT",
"created_at": "Mon, 26 Jun 2017 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R730",
"queues": [
......
{
"created_at": "Mon, 29 Aug 2016 22:00:00 GMT",
"created_at": "Tue, 30 Aug 2016 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R730",
"queues": [
......
{
"created_at": "Thu, 21 Jan 2016 23:00:00 GMT",
"created_at": "Fri, 22 Jan 2016 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R630",
"queues": [
......
{
"created_at": "Sun, 03 Jan 2016 23:00:00 GMT",
"created_at": "Mon, 04 Jan 2016 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R630",
"priority": "201201",
......
{
"created_at": "Tue, 10 Apr 2018 22:00:00 GMT",
"created_at": "Wed, 11 Apr 2018 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge C6420",
"queues": [
......
{
"created_at": "Tue, 15 Apr 2014 22:00:00 GMT",
"created_at": "Wed, 16 Apr 2014 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge C6220",
"queues": [
......
{
"created_at": "Mon, 16 Oct 2017 17:40:55 GMT",
"created_at": "Mon, 16 Oct 2017 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R630",
"queues": [
......
{
"created_at": "Thu, 20 Feb 2014 23:00:00 GMT",
"created_at": "Fri, 21 Feb 2014 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge C6220 II",
"queues": [
......
{
"created_at": "Sun, 24 Jan 2010 23:00:00 GMT",
"created_at": "Mon, 25 Jan 2010 00:00:00 GMT",
"kavlan": true,
"model": "SUN FIRE X2270",
"queues": [
......
{
"created_at": "Mon, 01 Nov 2010 23:00:00 GMT",
"created_at": "Tue, 02 Nov 2010 00:00:00 GMT",
"kavlan": true,
"model": "HP ProLiant DL165 G7",
"queues": [
......
{
"created_at": "Mon, 12 Jan 2015 23:00:00 GMT",
"created_at": "Tue, 13 Jan 2015 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R630",
"queues": [
......
{
"created_at": "Mon, 12 Jan 2015 23:00:00 GMT",
"created_at": "Tue, 13 Jan 2015 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R630",
"queues": [
......
{
"created_at": "Tue, 26 Jan 2010 23:00:00 GMT",
"created_at": "Wed, 27 Jan 2010 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge R410",
"queues": [
......
{
"created_at": "Mon, 03 Jan 2011 23:00:00 GMT",
"created_at": "Tue, 04 Jan 2011 00:00:00 GMT",
"kavlan": true,
"model": "Dell PowerEdge C6100",
"queues": [
......
......@@ -25,3 +25,4 @@ end
# load sub-parts that are used by many scripts anyway
require 'refrepo/utils'
require 'refrepo/input_loader'
require 'refrepo/data_loader'
......@@ -22,7 +22,7 @@ def load_data_hierarchy
path_hierarchy = File.dirname(filename).split('/') # Split the file path (path relative to input/)
path_hierarchy = [] if path_hierarchy == ['.']
if ['nodes', 'network_equipments'].include?(path_hierarchy.last)
if ['nodes', 'network_equipments', 'servers', 'pdus'].include?(path_hierarchy.last)
# it's a node or a network_equipment, add the uid
path_hierarchy << file_hash['uid']
end
......
......@@ -145,7 +145,7 @@ def get_networks_records(site, key)
next
end
eth_net_uid = node['network_adapters'].select{ |u, h| h['mounted'] && /^eth[0-9]$/.match(u) } # eth* interfaces
eth_net_uid = node['network_adapters'].select{ |u, h| h['mounted'] && /^eth[0-9]$/.match(u) } # eth* interfaces
node['network_adapters'].each { |net_uid, net_hash|
if ! eth_net_uid.include?(net_uid) && node['network_adapters'].size > 1
hostsuffix = "-#{net_uid}"
......@@ -164,7 +164,7 @@ end
def get_node_records(cluster_uid, node_uid, network_adapters)
records = []
network_adapters.each { |net_uid, net_hash|
next unless net_hash['ip']
......@@ -415,7 +415,7 @@ def generate_puppet_bindg5k(options)
$written_files = []
refapi = load_yaml_file_hierarchy
refapi = load_data_hierarchy
# Loop over Grid'5000 sites
refapi["sites"].each { |site_uid, site|
......@@ -445,7 +445,7 @@ def generate_puppet_bindg5k(options)
site_records['pdus'] = get_pdus_records(site) unless site['pdus'].nil?
# Networks and laptops (same input format)
site_records['networks'] = get_networks_records(site, 'networks') unless site['networks'].nil?
site_records['networks'] = get_networks_records(site, 'network_equipments') unless site['network_equipments'].nil?
site_records['laptops'] = get_networks_records(site, 'laptops') unless site['laptops'].nil?
site.fetch("clusters", []).sort.each { |cluster_uid, cluster|
......@@ -457,8 +457,8 @@ def generate_puppet_bindg5k(options)
network_adapters = {}
# Nodes
node.fetch('network_adapters').each { |net_uid, net_hash|
network_adapters[net_uid] = {"ip" => net_hash["ip"], "mounted" => net_hash["mounted"], "alias" => net_hash["alias"]}
node.fetch('network_adapters').each { |net|
network_adapters[net['device']] = {"ip" => net["ip"], "mounted" => net["mounted"], 'alias' => net['alias']}
}
# Mic
......@@ -474,9 +474,15 @@ def generate_puppet_bindg5k(options)
kavlan_adapters = {}
node.fetch('kavlan').each { |net_uid, net_hash|
net_hash.each { |kavlan_net_uid, ip|
kavlan_adapters["#{net_uid}-#{kavlan_net_uid}"] = {"ip" => ip, "mounted" => node['network_adapters'][net_uid]['mounted']}
kavlan_adapters["#{net_uid}-#{kavlan_net_uid}"] = {
'ip' => ip,
'mounted' => node['network_adapters'].select { |n|
n['device'] == net_uid
}[0]['mounted']
}
}
}
site_records["#{cluster_uid}-kavlan"] ||= []
site_records["#{cluster_uid}-kavlan"] += get_node_kavlan_records(cluster_uid, node_uid, network_adapters, kavlan_adapters)
end
......
......@@ -23,7 +23,7 @@ def generate_puppet_conmang5k(options)
puts "Using configuration directory: #{options[:conf_dir]}"
puts "For site(s): #{options[:sites].join(', ')}"
refapi = load_yaml_file_hierarchy
refapi = load_data_hierarchy
config = YAML::load_file(options[:conf_dir] + 'console.yaml')
credentials = YAML::load_file(options[:conf_dir] + 'console-password.yaml')
......
......@@ -6,19 +6,22 @@ def get_network_info(node_hash, network_interface)
# For the production network, find the mounted interface (either eth0 or eth1)
neti = network_interface
if neti == "eth" then
(0..5).each {|i|
if node_network_adapters.fetch("eth#{i}").fetch("mounted")
neti = "eth#{i}"
break
end
}
raise 'none of the eth[0-4] interfaces have the property "mounted" set to "true"' if neti == 'eth'
neti = node_network_adapters.select { |i| i['device'] =~ /eth/ and i['mounted'] }[0]['device']
unless neti
raise 'none of the eth[0-4] interfaces have the property "mounted" set to "true"' if neti == 'eth'
end
end
node_network_interface = node_network_adapters.fetch(neti)
node_network_interface = nil
case node_network_adapters
when Array
node_network_interface = node_network_adapters.select { |i| i['device'] == neti }[0]
when Hash
node_network_interface = node_network_adapters[neti]
end
node_mac = node_network_interface.fetch("mac")
node_ip = node_network_interface.fetch("ip")
node_mac = node_network_interface.fetch('mac')
node_ip = node_network_interface.fetch('ip')
raise '"mac" is nil' unless node_mac
raise '"ip" is nil' unless node_ip
......@@ -39,7 +42,7 @@ def write_dhcp_file(data, options)
end
def generate_puppet_dhcpg5k(options)
global_hash = load_yaml_file_hierarchy
global_hash = load_data_hierarchy
puts "Writing DHCP configuration files to: #{options[:output_dir]}"
......@@ -62,10 +65,12 @@ def generate_puppet_dhcpg5k(options)
next if node_hash == nil || node_hash['status'] == 'retired'
if node_hash['mic'] && node_hash['mic']['ip'] && node_hash['mic']['mac']
node_hash['network_adapters'] ||= {}
node_hash['network_adapters']['mic0'] ||= {}
node_hash['network_adapters']['mic0']['ip'] = node_hash['mic'].delete('ip')
node_hash['network_adapters']['mic0']['mac'] = node_hash['mic'].delete('mac')
node_hash['network_adapters'] ||= []
node_hash['network_adapters'].push({
'device' => 'mic0',
'ip'=> node_hash['mic'].delete('ip'),
'mac' => node_hash['mic'].delete('mac')
})
end
}
}
......@@ -74,7 +79,6 @@ def generate_puppet_dhcpg5k(options)
site_hash.fetch("clusters").each { |cluster_uid, cluster_hash|
# networks = ["eth", "bmc"]
# networks << 'mic0' if cluster_hash['nodes'].values.any? {|x| x['network_adapters']['mic0'] }
write_dhcp_file({
"filename" => "cluster-" + cluster_uid + ".conf",
"site_uid" => site_uid,
......@@ -84,9 +88,6 @@ def generate_puppet_dhcpg5k(options)
}, options)
}
#
#
#
# Other dhcp files
["networks", "laptops", "servers"].each { |key|
......
......@@ -26,16 +26,14 @@ end
# Extract the node ip from the node hash
def get_ip(node)
node['network_adapters'].each { |device, network_adapter|
if network_adapter['mounted'] && /^eth[0-9]$/.match(device)
return network_adapter['ip']
end
}
return node['network_adapters'].select { |n|
n['mounted'] && n['device'] =~ /eth/
}[0]['ip']
end
def generate_puppet_kadeployg5k(options)
global_hash = load_yaml_file_hierarchy
global_hash = load_data_hierarchy
if not options[:conf_dir]
options[:conf_dir] = "#{options[:output_dir]}/platforms/production/generators/kadeploy"
......
require 'refrepo/hash/hash'
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|
if port.is_a?(Hash)
switch_remote_port = port["port"] || lc["port"] || ""
switch_remote_uid = port["uid"]
else
switch_remote_port = lc["port"] || ""
switch_remote_uid = port
end
#warn "#{node_uid}, #{switch_uid}, #{lc_uid}, #{port_uid}, #{switch_remote_uid}, #{switch_remote_port}, #{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"]
port_name = pattern.sub("%LINECARD%",lc_uid.to_s).sub("%PORT%",port_uid.to_s)
return port_name
end
end
end
return nil
end
def generate_puppet_kavlang5k(options)
if not options[:conf_dir]
......@@ -12,7 +36,7 @@ def generate_puppet_kavlang5k(options)
puts "Using configuration directory: #{options[:conf_dir]}"
puts "For site(s): #{options[:sites].join(', ')}"
refapi = load_yaml_file_hierarchy
refapi = load_data_hierarchy
refapi['sites'].each { |site_uid, site_refapi|
......@@ -41,7 +65,8 @@ def generate_puppet_kavlang5k(options)
end
# Look for site's global kavlan
kavlan_id = refapi['sites'][site_uid]['kavlans'].each_key.select {|k| k.is_a?(Numeric) and k>9}.pop()
# TODO fix dirty convertion to_i below
kavlan_id = refapi['sites'][site_uid]['kavlans'].each_key.select {|k| k.to_i > 9}.pop()
output = ERB.new(File.read(File.expand_path('templates/kavlan-dhcp.conf.erb', File.dirname(__FILE__))), nil, '-').result(binding)
output_file = Pathname("#{options[:output_dir]}//platforms/production/modules/generated/files/grid5000/kavlan/#{site_uid}/dhcp/dhcpd-0.conf")
File.write(output_file, output)
......
......@@ -16,7 +16,7 @@ def generate_puppet_lanpowerg5k(options)
config = YAML::load_file("#{options[:conf_dir]}/console.yaml")
credentials = YAML::load_file("#{options[:conf_dir]}/console-password.yaml")
refapi = load_yaml_file_hierarchy
refapi = load_data_hierarchy
refapi['sites'].each { |site_uid, site_refapi|
......
......@@ -8,7 +8,7 @@
data.fetch('network_adapters').each { |network_interface|
dhcp_entries = []
data.fetch('nodes').each_sort_by_node_uid { |node_uid, node|
data.fetch('nodes').each_sort_by_node_uid { |node_uid, node|
next if node == nil || (node['status'] && node['status'] == 'retired')
case network_interface
......@@ -30,7 +30,6 @@
next
end
}
if not dhcp_entries.empty?
%>
group {
......
......@@ -3,32 +3,6 @@
# GENERATED by kavlang5k.rb
#
<%
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)
switch_remote_port = port["port"] || lc["port"] || ""
switch_remote_uid = port["uid"]
else
switch_remote_port = lc["port"] || ""
switch_remote_uid = port
end
#warn "#{node_uid}, #{switch_uid}, #{lc_uid}, #{port_uid}, #{switch_remote_uid}, #{switch_remote_port}, #{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"]
port_name = pattern.sub("%LINECARD%",lc_uid.to_s).sub("%PORT%",port_uid.to_s)
return switch_uid, port_name
end
end
end
end
return nil
end
refapi['sites'][site_uid]['clusters'].sort.to_h.each do |cluster_uid, cluster|
-%>
<% if cluster['kavlan'] -%>
......@@ -36,15 +10,17 @@ refapi['sites'][site_uid]['clusters'].sort.to_h.each do |cluster_uid, cluster|
<%
cluster['nodes'].sort.to_h.each do |node_uid, node|
next if node['status'] and node['status'] == "retired"
node['network_adapters'].each do |interface_uid, interface|
interface_has_kavlan = interface.has_key?('kavlan') ? interface['kavlan'] : node['kavlan'].has_key?(interface_uid)
node['network_adapters'].each do |interface|
# puts interface.class
# pp interface
#nil.crash
interface_has_kavlan = interface['kavlan']
if interface_has_kavlan
switch_uid, kavlan_port_name = net_switch_port_lookup(refapi['sites'][site_uid], node_uid, interface_uid)
if switch_uid and kavlan_port_name
switch_uid = interface['switch']
kavlan_port_name = kavlan_switch_port_lookup(refapi['sites'][site_uid]["network_equipments"][switch_uid], node_uid, interface['device'])
-%>
<%= node_uid %><%= interface['mounted']? "" : "-"+interface_uid %>.<%= site_uid %>.grid5000.fr <%= kavlan_port_name %> <%= switch_uid %>
<%= node_uid %><%= interface['mounted']? "" : "-"+interface['device'] %>.<%= site_uid %>.grid5000.fr <%= kavlan_port_name %> <%= switch_uid %>
<%
end
end
end