diff --git a/generators/wiki/cpu_parameters.rb b/generators/wiki/cpu_parameters.rb index 16997679c298b61a167c1eca6b808034f65d5308..88f18d7944be628bea0b2f6d58626a9984c71482 100644 --- a/generators/wiki/cpu_parameters.rb +++ b/generators/wiki/cpu_parameters.rb @@ -12,7 +12,7 @@ class CPUParametersGenerator < WikiGenerator table_columns = ["Installation date", "Site", "Cluster", "CPU Family", "CPU Version", "Microarchitecture", "Frequency", "Server type", "HT enabled", "Turboboost enabled", "P-State driver", "C-State driver"] table_data = [] - global_hash = load_yaml_file_hierarchy(File.expand_path("../../input/grid5000/", File.dirname(__FILE__))) + global_hash = get_global_hash # Loop over Grid'5000 sites global_hash["sites"].sort.to_h.each { |site_uid, site_hash| diff --git a/generators/wiki/disk_reservation.rb b/generators/wiki/disk_reservation.rb index 65137b1a91cde563041e3d0cef9d03475e821d93..1b781d9445f080bdbf8ea1fd52a3ad7fac92485f 100644 --- a/generators/wiki/disk_reservation.rb +++ b/generators/wiki/disk_reservation.rb @@ -12,7 +12,7 @@ class DiskReservationGenerator < WikiGenerator def generate_content table_columns = ["Site", "Cluster", "Number of nodes", "Number of reservable disks per node"] table_data = [] - global_hash = load_yaml_file_hierarchy(File.expand_path("../../input/grid5000/", File.dirname(__FILE__))) + global_hash = get_global_hash # Loop over Grid'5000 sites global_hash["sites"].sort.to_h.each { |site_uid, site_hash| diff --git a/generators/wiki/hardware.rb b/generators/wiki/hardware.rb index 5e02a9e1c1bf0126a2f9976e14cf9036095c0d2c..2d43ecc6c6a75f630fdf291e35b1733fa50b1045 100644 --- a/generators/wiki/hardware.rb +++ b/generators/wiki/hardware.rb @@ -12,7 +12,7 @@ class G5KHardwareGenerator < WikiGenerator end def generate_content - @global_hash = load_yaml_file_hierarchy(File.expand_path('../../input/grid5000/', File.dirname(__FILE__))) + @global_hash = get_global_hash @site_uids = G5K::SITES @generated_content = "__NOEDITSECTION__\n" diff --git a/generators/wiki/mw_utils.rb b/generators/wiki/mw_utils.rb index 8b7e61a13e46f7ac712100b9f56a5b15bd9a487c..c4743d015d0cdb1c258a0ca21d6da0f1707c943b 100644 --- a/generators/wiki/mw_utils.rb +++ b/generators/wiki/mw_utils.rb @@ -59,8 +59,6 @@ end #Defines global Grid5000 helpers (TODO move to its own file once it is big enough) module G5K - SITES = load_yaml_file_hierarchy(File.expand_path("../../input/grid5000/", File.dirname(__FILE__)))['sites'].keys.sort - # This method compacts an array of integers as follows # nodeset([2,3,4,7,9,10,12]) returns the string '[2-4,<wbr>7,<wbr>9-10,<wbr>12]' # where <wbr> is a hidden tag that enables carriage return in wikimedia @@ -108,6 +106,16 @@ module G5K return (count == 1 || word[-1] == 's') ? word : word + 's' end + @@global_hash = nil + def self.get_global_hash + if @@global_hash.nil? + @@global_hash = load_yaml_file_hierarchy(File.expand_path("../../input/grid5000/", File.dirname(__FILE__))) + end + # return a deep copy of global_hash + return Marshal.load(Marshal.dump(@@global_hash)) + end + + SITES = get_global_hash['sites'].keys.sort end #Defines MediaWiki helpers diff --git a/generators/wiki/oar_properties.rb b/generators/wiki/oar_properties.rb index 8b158b1a18e15203e58d01ebe2bf3ddd8ed47309..e99a8704cf64d84abb47b1050a3c1efacac79aa9 100644 --- a/generators/wiki/oar_properties.rb +++ b/generators/wiki/oar_properties.rb @@ -173,7 +173,7 @@ class OarPropertiesGenerator < WikiGenerator end def generate_content - refapi = load_yaml_file_hierarchy(File.expand_path("../../input/grid5000/", File.dirname(__FILE__))) + refapi = get_global_hash #Properties generated from oar-properties generator props = {} G5K::SITES.each{ |site_uid| diff --git a/generators/wiki/site_hardware.rb b/generators/wiki/site_hardware.rb index 8363a1f3514c6cba45fe96e58f4d6282ba0942ac..459422293e2810b395b6a67a063c52506eceb2df 100644 --- a/generators/wiki/site_hardware.rb +++ b/generators/wiki/site_hardware.rb @@ -160,7 +160,7 @@ def sort_data(data, key) end def get_hardware(sites) - global_hash = load_yaml_file_hierarchy(File.expand_path("../../input/grid5000/", File.dirname(__FILE__))) + global_hash = G5K::get_global_hash # Loop over each cluster of the site hardware = {} diff --git a/generators/wiki/wiki_generator.rb b/generators/wiki/wiki_generator.rb index 9e81ec374fad51684af4952ab7aa1902c4292772..c3fb47e2669f6c7018783bbdc8c8ffb8e0ea46d8 100644 --- a/generators/wiki/wiki_generator.rb +++ b/generators/wiki/wiki_generator.rb @@ -11,6 +11,10 @@ class WikiGenerator @page_name = page_name end + def get_global_hash + return G5K::get_global_hash + end + def login(options) if (options[:user] && options[:pwd]) @mw_client.log_in(options[:user], options[:pwd])