Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 2181f487 authored by Samir Noir's avatar Samir Noir :cheese:
Browse files

[scripts] fix some errors in edit-input-files script

parent 61623529
Branches
No related tags found
1 merge request!267WIP: [all] add SR-IOV detection on network interfaces
...@@ -9,7 +9,7 @@ require 'erb' ...@@ -9,7 +9,7 @@ require 'erb'
require 'fileutils' require 'fileutils'
require 'pathname' require 'pathname'
require 'yaml' require 'yaml'
require '../lib/hash/hash' require './lib/refrepo/hash/hash'
if RUBY_VERSION < "2.1" if RUBY_VERSION < "2.1"
puts "This script requires ruby >= 2.1" puts "This script requires ruby >= 2.1"
...@@ -50,32 +50,38 @@ end.parse! ...@@ -50,32 +50,38 @@ end.parse!
if options[:site].empty? || options[:clusters].empty? if options[:site].empty? || options[:clusters].empty?
puts "Not copying anything, post-processing file from 'output'" puts "Not copying anything, post-processing file from 'output'"
else else
options[:clusters].each{ |cluster_uid| FileUtils.mkdir_p 'output'
node_files = Dir["../../input/grid5000/sites/#{options[:site]}/clusters/#{cluster_uid}/nodes/*.yaml"] options[:clusters].each do |cluster_uid|
node_files.each{|f| node_files = Dir["./input/grid5000/sites/#{options[:site]}/clusters/#{cluster_uid}/nodes/*.yaml"]
node_files.each do |f|
filename = [f.split("/").last.split(".").first, options[:site], "grid5000", "fr", "yaml"].join(".") filename = [f.split("/").last.split(".").first, options[:site], "grid5000", "fr", "yaml"].join(".")
puts "Copying #{filename} to output/" puts "Copying #{filename} to output/"
FileUtils.cp(f, "./output/#{filename}") FileUtils.cp(f, "./output/#{filename}")
} end
} end
end end
##Modify node yaml hash here ##Modify node yaml hash here
def modify_node_data(hash, node_uid, cluster_uid, site_uid) #rubocop:disable Lint/UnusedMethodArgument def modify_node_data(hash, node_uid, cluster_uid, site_uid) #rubocop:disable Lint/UnusedMethodArgument
#example content: #example content:
hash["network_adapters"].each{ |na_id, na| hash["network_adapters"].each do |na_id, na|
if (na_id == "ib0" && na["firmware_version"] != "2.7.700") if !na['management'] && !na['sriov'] && na['interface'] == 'Ethernet'
puts "#{node_uid}" + na.inspect if na_id == 'eth0' || na_id == 'eth1'
na["firmware_version"] = "2.7.700" na['sriov'] = true
# na["mac"] = "80:00:02:0a:fe:" + na["mac"].split(":")[5..20].join(":") na['sriov_totalvfs'] = 63
else
na['sriov'] = true
na['sriov_totalvfs'] = 7
end
end end
} end
hash hash
end end
list_of_yaml_files = Dir['output/*.y*ml'].sort_by { |x| -x.count('/') } list_of_yaml_files = Dir['output/*.y*ml'].sort_by { |x| -x.count('/') }
list_of_yaml_files.each { |filename| list_of_yaml_files.each do |filename|
begin begin
file = filename.split("/")[1] file = filename.split("/")[1]
node_uid = file.split(".")[0] node_uid = file.split(".")[0]
...@@ -96,7 +102,7 @@ list_of_yaml_files.each { |filename| ...@@ -96,7 +102,7 @@ list_of_yaml_files.each { |filename|
hash = {node_uid => hash} hash = {node_uid => hash}
new_filename = Pathname("../../input/grid5000/sites/#{site_uid}/clusters/#{cluster_uid}/nodes/" + node_uid + ".yaml") new_filename = Pathname("./input/grid5000/sites/#{site_uid}/clusters/#{cluster_uid}/nodes/" + node_uid + ".yaml")
new_filename.dirname.mkpath() new_filename.dirname.mkpath()
...@@ -105,14 +111,14 @@ list_of_yaml_files.each { |filename| ...@@ -105,14 +111,14 @@ list_of_yaml_files.each { |filename|
contents = File.read(new_filename) contents = File.read(new_filename)
File.open(new_filename, 'w') { |fd| File.open(new_filename, 'w') { |fd|
fd.write("# Generated by g5k-checks (g5k-checks -m api)\n") fd.write("# Generated by g5k-checks (g5k-checks -m api)\n")
fd.write(contents) fd.write(contents)
} }
rescue StandardError => e rescue StandardError => e
puts "#{node_uid} - #{e.class}: #{e.message}" puts "#{node_uid} - #{e.class}: #{e.message}"
puts e.backtrace puts e.backtrace
end end
} end
if options[:rm_output] if options[:rm_output]
puts "Cleaning up output directory" puts "Cleaning up output directory"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment