Skip to content

Commit be3d572

Browse files
author
Patrice RINGOT
committed
[wiki] same informations displayed for the header summary part on hardware and site_hardware pages (bug 13775)
1 parent bb81389 commit be3d572

File tree

2 files changed

+48
-64
lines changed

2 files changed

+48
-64
lines changed

lib/refrepo/gen/wiki/generators/hardware.rb

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,62 +14,14 @@ def generate_content(_options)
1414
@generated_content = "__NOEDITSECTION__\n"
1515
@generated_content += "{{Portal|User}}\n"
1616
@generated_content += "<div class=\"sitelink\">Hardware: [[Hardware|Global]] | " + G5K::SITES.map { |e| "[[#{e.capitalize}:Hardware|#{e.capitalize}]]" }.join(" | ") + "</div>\n"
17-
@generated_content += generate_summary
17+
@generated_content += SiteHardwareGenerator.generate_header_summary(@global_hash['sites'])
1818
@generated_content += "\n= Clusters =\n"
1919
@generated_content += SiteHardwareGenerator.generate_all_clusters
2020
@generated_content += generate_totals
2121
@generated_content += MW.italic(MW.small(generated_date_string))
2222
@generated_content += MW::LINE_FEED
2323
end
2424

25-
def generate_summary
26-
sites = @global_hash['sites'].length
27-
clusters = 0
28-
nodes = 0
29-
cores = 0
30-
gpus = 0
31-
hdds = 0
32-
ssds = 0
33-
storage_space = 0
34-
ram = 0
35-
pmem = 0
36-
flops = 0
37-
38-
@global_hash['sites'].sort.to_h.each do |site_uid, site_hash|
39-
clusters += site_hash['clusters'].length
40-
site_hash['clusters'].sort.to_h.each do |cluster_uid, cluster_hash|
41-
cluster_hash['nodes'].sort.to_h.each do |node_uid, node_hash|
42-
next if node_hash['status'] == 'retired'
43-
nodes += 1
44-
cores += node_hash['architecture']['nb_cores']
45-
ram += node_hash['main_memory']['ram_size']
46-
pmem += node_hash['main_memory']['pmem_size'] if node_hash['main_memory']['pmem_size']
47-
if node_hash['gpu_devices']
48-
gpus += node_hash['gpu_devices'].length
49-
end
50-
ssds += node_hash['storage_devices'].select { |d| d['storage'] == 'SSD' }.length
51-
hdds += node_hash['storage_devices'].select { |d| d['storage'] == 'HDD' }.length
52-
node_hash['storage_devices'].each do |i|
53-
storage_space += i['size']
54-
end
55-
flops += node_hash['performance']['node_flops']
56-
end
57-
end
58-
end
59-
tflops = sprintf("%.1f", flops.to_f / (10**12))
60-
return <<-EOF
61-
= Summary =
62-
* #{sites} sites
63-
* #{clusters} clusters
64-
* #{nodes} nodes
65-
* #{cores} CPU cores
66-
* #{gpus} GPUs
67-
* #{G5K.get_size(ram)} RAM + #{G5K.get_size(pmem)} PMEM
68-
* #{ssds} SSDs and #{hdds} HDDs on nodes (total: #{G5K.get_size(storage_space, 'metric')})
69-
* #{tflops} TFLOPS (excluding GPUs)
70-
EOF
71-
end
72-
7325
def generate_totals
7426
data = {
7527
'proc_families' => {},

lib/refrepo/gen/wiki/generators/site_hardware.rb

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def generate_content(_options)
2323
"{{Portal|User}}\n" +
2424
"<div class=\"sitelink\">Hardware: [[Hardware|Global]] | " + G5K::SITES.map { |e| "[[#{e.capitalize}:Hardware|#{e.capitalize}]]" }.join(" | ") + "</div>\n" +
2525
"'''See also:''' [[#{@site.capitalize}:Network|Network topology for #{@site.capitalize}]]\n" +
26-
"\n= Summary =\n" +
27-
"'''#{generate_oneline_summary}'''\n" +
26+
"#{SiteHardwareGenerator.generate_header_summary({@site => G5K::get_global_hash['sites'][@site]})}\n" +
27+
"= Clusters =\n" +
2828
self.class.generate_summary(@site, false) +
2929
(has_reservable_disks ? "''*: disk is [[Disk_reservation|reservable]]''" : '') +
3030
self.class.generate_description(@site) +
@@ -42,21 +42,53 @@ def self.generate_all_clusters
4242
MW.generate_table('class="wikitable sortable"', table_columns, table_data) + "\n"
4343
end
4444

45-
def generate_oneline_summary
46-
h = G5K::get_global_hash['sites'][@site]
47-
# remove retired nodes
48-
# FIXME this should probably move to a helper
49-
h['clusters'].each_pair do |cl, v|
50-
v['nodes'].delete_if { |n, v2| v2['status'] == 'retired' }
45+
def self.generate_header_summary(sites_hash)
46+
sites = sites_hash.length
47+
clusters = 0
48+
nodes = 0
49+
cores = 0
50+
gpus = 0
51+
hdds = 0
52+
ssds = 0
53+
storage_space = 0
54+
ram = 0
55+
pmem = 0
56+
flops = 0
57+
58+
sites_hash.sort.to_h.each do |site_uid, site_hash|
59+
clusters += site_hash['clusters'].length
60+
site_hash['clusters'].sort.to_h.each do |cluster_uid, cluster_hash|
61+
cluster_hash['nodes'].sort.to_h.each do |node_uid, node_hash|
62+
next if node_hash['status'] == 'retired'
63+
nodes += 1
64+
cores += node_hash['architecture']['nb_cores']
65+
ram += node_hash['main_memory']['ram_size']
66+
pmem += node_hash['main_memory']['pmem_size'] if node_hash['main_memory']['pmem_size']
67+
if node_hash['gpu_devices']
68+
gpus += node_hash['gpu_devices'].length
69+
end
70+
ssds += node_hash['storage_devices'].select { |d| d['storage'] == 'SSD' }.length
71+
hdds += node_hash['storage_devices'].select { |d| d['storage'] == 'HDD' }.length
72+
node_hash['storage_devices'].each do |i|
73+
storage_space += i['size']
74+
end
75+
flops += node_hash['performance']['node_flops']
76+
end
77+
end
5178
end
52-
h['clusters'].delete_if { |k, v| v['nodes'].empty? }
53-
54-
clusters = h['clusters'].length
55-
nodes = h['clusters'].inject(0) { |a, b| a + b[1]['nodes'].values.length }
56-
cores = h['clusters'].inject(0) { |a, b| cnodes = b[1]['nodes'].values ; a + cnodes.length * cnodes.first['architecture']['nb_cores'] }
57-
flops = h['clusters'].inject(0) { |a, b| cnodes = b[1]['nodes'].values ; a + cnodes.length * (cnodes.first['performance']['node_flops'] rescue 0) }
5879
tflops = sprintf("%.1f", flops.to_f / (10**12))
59-
return "#{clusters} cluster#{clusters > 1 ? 's' : ''}, #{nodes} node#{nodes > 1 ? 's' : ''}, #{cores} core#{cores > 1 ? 's' : ''}, #{tflops} TFLOPS"
80+
81+
summary = "= Summary =\n"
82+
summary += sites > 1 ? "* #{sites} sites\n":''
83+
summary += "* #{clusters} clusters\n"
84+
summary += "* #{nodes} nodes\n"
85+
summary += "* #{cores} CPU cores\n"
86+
summary += "* #{gpus} GPUs\n"
87+
summary += "* #{G5K.get_size(ram)} RAM"
88+
summary += pmem > 0 ? " + #{G5K.get_size(pmem)} PMEM\n":"\n"
89+
summary += "* #{ssds} SSDs and #{hdds} HDDs on nodes (total: #{G5K.get_size(storage_space, 'metric')})\n"
90+
summary += "* #{tflops} TFLOPS (excluding GPUs)\n"
91+
summary
6092
end
6193

6294
def self.generate_summary(site, with_sites)

0 commit comments

Comments
 (0)