From 66084c63a31f1477d272728a55b9cf5dc82ee69e Mon Sep 17 00:00:00 2001 From: Alexandre MERLIN <alexandre.merlin@inria.fr> Date: Mon, 16 Nov 2020 10:46:28 +0100 Subject: [PATCH] Add group storage wiki generator --- lib/refrepo/gen/wiki.rb | 5 +++ .../gen/wiki/generators/group_storage.rb | 39 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 lib/refrepo/gen/wiki/generators/group_storage.rb diff --git a/lib/refrepo/gen/wiki.rb b/lib/refrepo/gen/wiki.rb index 1ecb98f306..d6a39f5ee1 100644 --- a/lib/refrepo/gen/wiki.rb +++ b/lib/refrepo/gen/wiki.rb @@ -7,6 +7,7 @@ require 'refrepo/gen/wiki/generators/oar_properties' require 'refrepo/gen/wiki/generators/site_hardware' require 'refrepo/gen/wiki/generators/site_network' require 'refrepo/gen/wiki/generators/status' +require 'refrepo/gen/wiki/generators/group_storage' module RefRepo::Gen::Wiki @@ -30,6 +31,10 @@ module RefRepo::Gen::Wiki 'oar_properties' => { :gen => OarPropertiesGenerator, :page => 'OAR_Properties' + }, + 'group_storage' => { + :gen => GroupStorageGenerator, + :page => 'Group_Storage' } } SITE_GENERATORS = { diff --git a/lib/refrepo/gen/wiki/generators/group_storage.rb b/lib/refrepo/gen/wiki/generators/group_storage.rb new file mode 100644 index 0000000000..9e6f9d6422 --- /dev/null +++ b/lib/refrepo/gen/wiki/generators/group_storage.rb @@ -0,0 +1,39 @@ +# coding: utf-8 + +class GroupStorageGenerator < WikiGenerator + + def initialize(page_name) + super(page_name) + end + + def generate_content + table_columns = ["Site", "Server Name", "Size", "Link Speed", "Notes"] + table_data = [] + global_hash = get_global_hash + + # Loop over Grid'5000 sites + global_hash["sites"].sort.to_h.each { |site_uid, site_hash| + site_hash.fetch("servers").sort.to_h.each_value { |server_hash| + next unless server_hash['group_storage'] + group_storage = server_hash['group_storage'] + table_data << [ + "[[#{site_uid.capitalize}:Hardware|#{site_uid.capitalize}]]", + "#{group_storage['name']}.#{site_uid}.grid5000.fr", + G5K.get_size(group_storage['size'], 'metric'), + G5K.get_rate(group_storage['rate']), + group_storage["comment"] || "" + ] + } + } + # Sort by site and server name + table_data.sort_by! { |row| + [row[0], row[1]] + } + + # Table construction + table_options = 'class="wikitable sortable" style="text-align: center;"' + @generated_content = MW.generate_table(table_options, table_columns, table_data) + @generated_content += MW.italic(MW.small(generated_date_string)) + @generated_content += MW::LINE_FEED + end +end -- GitLab