Commit 0fd495a8 authored by Jérémie Gaidamour's avatar Jérémie Gaidamour

[all] Large update of the node descriptions from g5k-checks output

parent 96f3bee9
......@@ -11,6 +11,40 @@ def deep_merge_entries(a, b)
end
end
# Write pretty and sorted JSON files
def write_json(filepath, data)
def rec_sort(h)
case h
when Array
h.map{|v| rec_sort(v)}#.sort_by!{|v| (v.to_s rescue nil) }
when Hash
Hash[Hash[h.map{|k,v| [rec_sort(k),rec_sort(v)]}].sort_by{|k,v| [(k.to_s rescue nil), (v.to_s rescue nil)]}]
else
h
end
end
File.open(filepath, 'w') do |f|
f.write(JSON.pretty_generate(rec_sort(data)))
end
end
# Write sorted YAML files
def write_yaml(filepath, data)
def rec_sort(h)
case h
when Array
h.map{|v| rec_sort(v)}#.sort_by!{|v| (v.to_s rescue nil) }
when Hash
Hash[Hash[h.map{|k,v| [rec_sort(k),rec_sort(v)]}].sort_by{|k,v| [(k.to_s rescue nil), (v.to_s rescue nil)]}]
else
h
end
end
File.open(filepath, 'w') do |f|
f.write(rec_sort(data).to_yaml)
end
end
# Extend Hash with helper methods needed to convert input data files to ruby Hash
class ::Hash
......
......@@ -16,23 +16,6 @@ refapi_path = "/tmp/data"
#global_hash = load_yaml_file_hierarchy("../../input/example/")
global_hash = load_yaml_file_hierarchy("../../input/grid5000/")
# Write pretty and sorted JSON files
def write_json(filepath, data)
def rec_sort(h)
case h
when Array
h.map{|v| rec_sort(v)}#.sort_by!{|v| (v.to_s rescue nil) }
when Hash
Hash[Hash[h.map{|k,v| [rec_sort(k),rec_sort(v)]}].sort_by{|k,v| [(k.to_s rescue nil), (v.to_s rescue nil)]}]
else
h
end
end
File.open(filepath, 'w') do |f|
f.write(JSON.pretty_generate(rec_sort(data)))
end
end
# Parse network equipment description and return switch name and port connected to given node
# In the network description, if the node interface is given (using "port" attribute),
# the interface parameter must be used.
......@@ -195,7 +178,7 @@ global_hash["sites"].each do |site_uid, site|
end
}
pp node["monitoring"]["wattmeter"]
#pp node["monitoring"]["wattmeter"]
if node["monitoring"]["wattmeter"] != "false"
node["sensors"]["power"]["via"]["api"] ||= {}
......
#!/usr/bin/ruby
require 'pp'
require 'erb'
require 'fileutils'
require 'pathname'
require 'yaml'
require '../lib/hash/hash'
####
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)
hash["storage_devices"] = hash.delete("block_devices")
hash["storage_devices"] = hash["storage_devices"].sort_by_array(["sda", "sdb", "sdc", "sdd", "sde"])
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)
}
}
---
nodes:
adonis-[1-10]:
network_adapters:
eth0:
enabled: true
mountable: true
eth1:
enabled: false
mountable: false
ib0:
enabled: true
mountable: true
processor:
cache_l1d: 32768
cache_l1i: 32768
cache_l2: 262144
cache_l3: 8388608
clock_speed: 2270000000
instruction_set: x86-64
model: Intel Xeon
other_description: Intel(R) Xeon(R) CPU E5520 @ 2.27GHz
vendor: Intel
version: E5520
storage_devices:
sda:
vendor: Western Digital
adonis-1:
chassis:
serial: '1234567890'
network_adapters:
bmc:
ip: 172.17.18.1
mac: 00:30:48:cc:b0:58
eth0:
ip6: fe80::230:48ff:fecc:7fd8
adonis-10:
chassis:
serial: '1234567890'
network_adapters:
bmc:
ip: 172.17.18.10
mac: 00:30:48:cc:ad:df
eth0:
ip6: fe80::230:48ff:fecc:8310
mountable: true
adonis-2:
chassis:
serial: '1234567890'
network_adapters:
bmc:
ip: 172.17.18.2
mac: 00:30:48:cc:b0:59
eth0:
ip6: fe80::230:48ff:fecc:7fda
adonis-3:
chassis:
serial: '1234567890'
network_adapters:
bmc:
ip: 172.17.18.3
mac: 00:30:48:cc:b5:f6
eth0:
ip6: fe80::230:48ff:fecd:c6a4
adonis-4:
chassis:
serial: '1234567890'
network_adapters:
bmc:
ip: 172.17.18.4
mac: 00:30:48:cc:b6:6c
eth0:
ip6: fe80::230:48ff:fecd:c0ac
adonis-5:
chassis:
serial: '1234567890'
network_adapters:
bmc:
ip: 172.17.18.5
mac: 00:30:48:cc:af:61
eth0:
ip6: fe80::230:48ff:fecc:7e0a
adonis-6:
chassis:
serial: '1234567890'
network_adapters:
bmc:
ip: 172.17.18.6
mac: 00:30:48:cc:ad:f2
eth0:
ip6: fe80::230:48ff:fecc:7abc
adonis-8:
chassis:
serial: '1234567890'
network_adapters:
bmc:
ip: 172.17.18.8
mac: 00:30:48:cc:b6:6d
eth0:
ip6: fe80::230:48ff:fecd:c0ae
adonis-9:
chassis:
serial: '1234567890'
network_adapters:
bmc:
ip: 172.17.18.9
mac: 00:25:90:4b:bd:b1
eth0:
ip6: fe80::225:90ff:fe4c:e984
# Generated by g5k-checks (g5k-checks -m api)
---
adonis-1:
architecture:
platform_type: x86_64
smp_size: 2
smt_size: 8
bios:
version: R4222X80
release_date: 05/20/2010
vendor: American Megatrends Inc.
storage_devices:
sda:
model: WDC WD2502ABYS-0
device: sda
size: 251059544064
rev: 3.0
vendor: Western Digital
version: R4222X80
chassis:
manufacturer: Bull SAS
name: bullx
serial: 1234567890
main_memory:
ram_size: 25769803776
network_adapters:
ib0:
mounted: true
guid: 20:00:55:00:41:80:00:00:00:00:00:00:00:30:48:ff:ff:cc:17:55
rate: 40000000000
ip6: fe80::230:48ff:ffcc:1755
management: false
enabled: true
interface: InfiniBand
version: MT26428
ip: 172.18.18.1
driver: mlx4_core
mountable: true
eth0:
mounted: true
rate: 1000000000
mac: 00:30:48:cc:7f:d8
ip6: fe80::230:48ff:fecc:7fd8
management: false
enabled: true
interface: Ethernet
driver: igb
mountable: true
interface: Ethernet
ip: 172.16.18.1
mac: 00:30:48:cc:7f:d8
management: false
mounted: true
rate: 1000000000
eth1:
mounted: false
driver: igb
interface: Ethernet
mac: 00:30:48:cc:7f:d9
management: false
enabled: false
interface: Ethernet
driver: igb
mountable: false