Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

Commit 9d740d3f authored by Jérémie Gaidamour's avatar Jérémie Gaidamour
Browse files

[dev] run-g5kchecks: force ruby version + exception handling

parent 2448b015
......@@ -11,39 +11,49 @@ require 'pathname'
require 'yaml'
require '../lib/hash/hash'
if RUBY_VERSION < "2.1"
puts "This script requires ruby >= 2.1"
exit
end
puts 'Postprocessing of output/. Copying files into ../../input/'
list_of_yaml_files = Dir['output/*.y*ml'].sort_by { |x| -x.count('/') }
list_of_yaml_files.each { |filename|
file = filename.split("/")[1]
node_uid = file.split(".")[0]
site_uid = file.split(".")[1]
cluster_uid = node_uid.split("-")[0]
hash = YAML::load_file(filename)
if hash == false
puts "Error found in #{filename}"
next
begin
file = filename.split("/")[1]
node_uid = file.split(".")[0]
site_uid = file.split(".")[1]
cluster_uid = node_uid.split("-")[0]
hash = YAML::load_file(filename)
if hash == false
puts "Error found in #{filename}"
next
end
hash["storage_devices"] = hash.delete("block_devices")
hash["storage_devices"] = hash["storage_devices"].sort_by_array(["sda", "sdb", "sdc", "sdd", "sde"])
hash["storage_devices"].each {|k, v| v.delete("device") }
hash["network_adapters"] = hash.delete("network_interfaces")
hash["network_adapters"] = hash["network_adapters"].sort_by_array(["eth0", "eth1", "eth2", "eth3", "eth4", "eth5", "eth6", "ib0", "ib1", "ib2", "ib3", "bmc"])
hash["chassis"]["name"] = hash["chassis"].delete("product_name")
hash["chassis"]["serial"] = hash["chassis"].delete("serial_number")
hash = {node_uid => hash}
new_filename = "../../input/grid5000/sites/#{site_uid}/clusters/#{cluster_uid}/nodes/" + node_uid + ".yaml"
write_yaml(new_filename, hash)
contents = File.read(new_filename)
File.open(new_filename, 'w') { |file|
file.write("# Generated by g5k-checks (g5k-checks -m api)\n")
file.write(contents)
}
rescue Exception => e
puts "#{node_uid} - #{e.class}: #{e.message}"
end
hash["storage_devices"] = hash.delete("block_devices")
hash["storage_devices"] = hash["storage_devices"].sort_by_array(["sda", "sdb", "sdc", "sdd", "sde"])
hash["storage_devices"].each {|k, v| v.delete("device") }
hash["network_adapters"] = hash.delete("network_interfaces")
hash["network_adapters"] = hash["network_adapters"].sort_by_array(["eth0", "eth1", "eth2", "eth3", "eth4", "eth5", "eth6", "ib0", "ib1", "ib2", "ib3", "bmc"])
hash["chassis"]["name"] = hash["chassis"].delete("product_name")
hash["chassis"]["serial"] = hash["chassis"].delete("serial_number")
hash = {node_uid => hash}
new_filename = "../../input/grid5000/sites/#{site_uid}/clusters/#{cluster_uid}/nodes/" + node_uid + ".yaml"
write_yaml(new_filename, hash)
contents = File.read(new_filename)
File.open(new_filename, 'w') { |file|
file.write("# Generated by g5k-checks (g5k-checks -m api)\n")
file.write(contents)
}
}
......@@ -15,6 +15,11 @@ require 'peach'
require '../lib/input_loader'
require 'pp'
if RUBY_VERSION < "2.1"
puts "This script requires ruby >= 2.1"
exit
end
# puts 'Init ruby-cute'
$g5k = Cute::G5K::API.new()
# puts '...done'
......
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