diff --git a/generators/wiki/clusters_data.yml b/generators/wiki/clusters_data.yml new file mode 100644 index 0000000000000000000000000000000000000000..7d7dc0886d86c3bba2faaf177a1090024389b85b --- /dev/null +++ b/generators/wiki/clusters_data.yml @@ -0,0 +1,98 @@ +sagittaire: + cpu_codename: N/A + +sol: + cpu_codename: N/A + +granduc: + cpu_codename: Merom + +chinqchint: + cpu_codename: Penryn + +genepi: + cpu_codename: Penryn + +griffon: + cpu_codename: Penryn + +talc: + cpu_codename: Penryn + +parapide: + cpu_codename: Nehalem + +edel: + cpu_codename: Nehalem + +suno: + cpu_codename: Nehalem + +parapluie: + cpu_codename: N/A + +chirloute: + cpu_codename: Westmere + +graphene: + cpu_codename: Nehalem + +chimint: + cpu_codename: Westmere + +hercule: + cpu_codename: Sandy Bridge + +orion: + cpu_codename: Sandy Bridge + +taurus: + cpu_codename: Sandy Bridge + +econome: + cpu_codename: Sandy Bridge + +petitprince: + cpu_codename: Sandy Bridge + +graphite: + cpu_codename: Sandy Bridge + +paranoia: + cpu_codename: Sandy Bridge + +graphique: + cpu_codename: Haswell + +parasilo: + cpu_codename: Haswell + +paravance: + cpu_codename: Haswell + +graoully: + cpu_codename: Haswell + +grimoire: + cpu_codename: Haswell + +grisou: + cpu_codename: Haswell + +nova: + cpu_codename: Broadwell + +grimani: + cpu_codename: Haswell + +uva: + cpu_codename: Westmere + +uvb: + cpu_codename: Dunnington + +chetemi: + cpu_codename: Broadwell + +chifflet: + cpu_codename: Broadwell diff --git a/generators/wiki/cpuParameters.rb b/generators/wiki/cpuParameters.rb new file mode 100644 index 0000000000000000000000000000000000000000..95f416136a493ca2e0130a3186842432176c1f67 --- /dev/null +++ b/generators/wiki/cpuParameters.rb @@ -0,0 +1,92 @@ +require "optparse" +require "mediawiki_api" + +require_relative '../lib/input_loader' +require_relative './mw_utils' + +options = {} + +opt_parse = OptionParser.new do |opts| + opts.banner = "Usage: cpuParameters.rb --api-user user --api-password password" + + opts.on('-u=user', '--api-user=user', String, 'User for HTTP authentication ') do |user| + options[:user] = user + end + + opts.on('-p=pwd', '--api-password=pwd', String, 'Password for HTTP authentication') do |pwd| + options[:pwd] = pwd + end +end + +opt_parse.parse! + +if (options[:user].nil? || options[:pwd].nil?) + puts opt_parse.to_s + exit +end + +target_page = "Template:CPUParameters" + +table_columns = ["Installation date", "Site", "Cluster", "CPU Family", "CPU Version", "Core Codename", "Frequency", "Server type", "HT enabled", "Turboboost enabled", "P-State driver", "C-State driver"] + +table_data = [] + +#Static cluster information not present in the ref-repo +cluster_data = YAML::load_file(File.join(File.dirname(File.expand_path(__FILE__)), 'clusters_data.yml')) + +global_hash = load_yaml_file_hierarchy(File.expand_path("../../input/grid5000/", File.dirname(__FILE__))) + +# Loop over Grid'5000 sites +global_hash["sites"].each { |site_uid, site_hash| + + site_hash.fetch("clusters").each { |cluster_uid, cluster_hash| + + node_hash = cluster_hash.fetch('nodes').first[1] + + cpu_family = node_hash["processor"]["model"] rescue "" + cpu_version = node_hash["processor"]["version"] rescue "" + cpu_freq = node_hash["processor"]["clock_speed"] / 1000000000.0 rescue 0.0 #GHz + + ht_enabled = node_hash["bios"]["configuration"]["ht_enabled"] rescue false + turboboost_enabled = node_hash["bios"]["configuration"]["turboboost_enabled"] rescue false + pstate_driver = node_hash["operating_system"]["pstate_driver"] rescue "" + cstate_driver = node_hash["operating_system"]["cstate_driver"] rescue "" + + cpu_codename = cluster_data[cluster_uid]["cpu_codename"] rescue "" + + #One line per cluster + table_data << [ + DateTime.new(*cluster_hash["created_at"].to_s.scan(/\d+/).map {|i| i.to_i}).strftime("%Y-%m-%d"), + site_uid, + cluster_uid, + cpu_family, + cpu_version, + cpu_codename, + cpu_freq.to_s + " GHz", + cluster_hash["model"], + ht_enabled ? "{{Yes}}" : "{{No}}", + turboboost_enabled ? "{{Yes}}" : "{{No}}", + pstate_driver, + cstate_driver + ] + + } +} + +#Sort by cluster date +table_data.sort_by! { |row| + DateTime.parse(row[0]) +} + +#Table construction + +table_options = 'class="G5KDataTable" border="1" style="text-align: center;"' + +page_text = MW.generate_table(table_options, table_columns, table_data) + +page_text += MW.italic(MW.small("Generated from the Grid5000 APIs on " + Time.now.strftime("%Y-%m-%d"))) + +#Finally Create/modify the page on mediawiki +client = MediawikiApi::Client.new(MW::BASE_URL) +client.log_in(options[:user], options[:pwd]) +client.edit({"title" => target_page, "text" => page_text }) diff --git a/generators/wiki/mw_utils.rb b/generators/wiki/mw_utils.rb new file mode 100644 index 0000000000000000000000000000000000000000..cba7652365d3953ea89fdb8160e4ce00ebc915de --- /dev/null +++ b/generators/wiki/mw_utils.rb @@ -0,0 +1,65 @@ + +#Defines MediaWiki helpers + +module MW + + BASE_URL = "https://www.grid5000.fr/mediawiki/api.php" + + TABLE_START = "{|" + + TABLE_END = "|}" + + TABLE_ROW = "|-" + + TABLE_HEADER = "!" + + INLINE_CELL = "||" + + TABLE_CELL = "|" + + LINE_FEED = "\n" + + HTML_LINE_FEED = "<br />" + + def self.generate_table(table_options, columns, rows) + table_text = MW::TABLE_START + table_options + + table_text += MW::LINE_FEED + MW::TABLE_ROW + MW::LINE_FEED + + columns.each { |col| + table_text += MW::TABLE_HEADER + MW::TABLE_CELL + col + MW::LINE_FEED + } + + rows.each { |row| + table_text += MW::TABLE_ROW + MW::LINE_FEED + row.each_with_index{ |cell, i| + if (i == 0) + table_text += MW::TABLE_CELL + else + table_text += MW::INLINE_CELL + end + table_text += cell.to_s + } + table_text += MW::LINE_FEED + } + table_text += MW::LINE_FEED + MW::TABLE_END + return table_text + end + + def self.small(text) + "<small>" + text + "</small>" + end + + def self.big(text) + "<big>" + text + "</big>" + end + + def self.italic(text) + "''" + text + "''" + end + + def self.bold(text) + "'''" + text + "'''" + end + +end