Skip to content

Commit

Permalink
[wiki] factorize disk size computation + homogenize size
Browse files Browse the repository at this point in the history
But should be GiB TiB no GB TB...
  • Loading branch information
npf committed Dec 3, 2018
1 parent 8573c4f commit 0026e36
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions lib/refrepo/gen/wiki/generators/hardware.rb
Expand Up @@ -260,14 +260,6 @@ def get_date(microarchitecture)
date
end

def storage_size_to_text(s)
if s > 1000*1000*1000*1000 # 1 TB
return sprintf("%.1f", s.to_f/(1000*1000*1000*1000)) + ' TB'
else
return sprintf("%d", s/(1000*1000*1000)) + ' GB'
end
end

def generate_storage
table_columns = ["Site", "Cluster", "Number of nodes", "Main disk", "Additional HDDs", "Additional SSDs", "[[Disk_reservation|Disk reservation]]"]
table_data = []
Expand All @@ -282,19 +274,19 @@ def generate_storage
sd = node_hash['storage_devices']
reservable_disks = sd.to_a.select{ |v| v[1]['reservation'] == true }.count > 0
maindisk = sd.to_a.select { |v| v[0] == 'sda' }.first[1]
maindisk_t = maindisk['storage'] + ' ' + storage_size_to_text(maindisk['size'])
maindisk_t = maindisk['storage'] + ' ' + G5K.get_size(maindisk['size'])
other = sd.to_a.select { |d| d[0] != 'sda' }
hdds = other.select { |d| d[1]['storage'] == 'HDD' }
if hdds.count == 0
hdd_t = "0"
else
hdd_t = hdds.count.to_s + " (" + hdds.map { |d| storage_size_to_text(d[1]['size']) }.join(', ') + ")"
hdd_t = hdds.count.to_s + " (" + hdds.map { |d| G5K.get_size(d[1]['size']) }.join(', ') + ")"
end
ssds = other.select { |d| d[1]['storage'] == 'SSD' }
if ssds.count == 0
ssd_t = "0"
else
ssd_t = ssds.count.to_s + " (" + ssds.map { |d| storage_size_to_text(d[1]['size']) }.join(', ') + ")"
ssd_t = ssds.count.to_s + " (" + ssds.map { |d| G5K.get_size(d[1]['size']) }.join(', ') + ")"
end
queues = cluster_hash['queues'] - ['admin', 'default']
queue_t = (queues.nil? || (queues.empty? ? '' : "_.28" + queues[0].gsub(' ', '_') + ' queue.29'))
Expand Down

0 comments on commit 0026e36

Please sign in to comment.