diff --git a/generators/wiki/cpu_parameters.rb b/generators/wiki/lib/generators/cpu_parameters.rb similarity index 100% rename from generators/wiki/cpu_parameters.rb rename to generators/wiki/lib/generators/cpu_parameters.rb diff --git a/generators/wiki/disk_reservation.rb b/generators/wiki/lib/generators/disk_reservation.rb similarity index 100% rename from generators/wiki/disk_reservation.rb rename to generators/wiki/lib/generators/disk_reservation.rb diff --git a/generators/wiki/hardware.rb b/generators/wiki/lib/generators/hardware.rb similarity index 100% rename from generators/wiki/hardware.rb rename to generators/wiki/lib/generators/hardware.rb diff --git a/generators/wiki/oar_properties.rb b/generators/wiki/lib/generators/oar_properties.rb similarity index 99% rename from generators/wiki/oar_properties.rb rename to generators/wiki/lib/generators/oar_properties.rb index c24a041fe01c2d5b3248e6abe502fe31322c8e0b..bb373e781ba5bcddee1e339e59db5691f895804e 100644 --- a/generators/wiki/oar_properties.rb +++ b/generators/wiki/lib/generators/oar_properties.rb @@ -2,7 +2,7 @@ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib'))) require 'wiki_generator' -require_relative '../oar-properties/lib/lib-oar-properties' +require_relative '../../../oar-properties/lib/lib-oar-properties' class OarPropertiesGenerator < WikiGenerator diff --git a/generators/wiki/site_hardware.rb b/generators/wiki/lib/generators/site_hardware.rb similarity index 100% rename from generators/wiki/site_hardware.rb rename to generators/wiki/lib/generators/site_hardware.rb diff --git a/generators/wiki/site_network.rb b/generators/wiki/lib/generators/site_network.rb similarity index 95% rename from generators/wiki/site_network.rb rename to generators/wiki/lib/generators/site_network.rb index e1ea81133fdd6dbb3ab780f5599b660e33c76518..417f87b1f8670fce857ff4a14bfd5f9ccb4161b3 100644 --- a/generators/wiki/site_network.rb +++ b/generators/wiki/lib/generators/site_network.rb @@ -2,7 +2,7 @@ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib'))) require 'wiki_generator' -require_relative '../input-validators/check-network-description' +require_relative '../../../input-validators/check-network-description' # This class generates the network description of each site, in .dot # and .png format diff --git a/generators/wiki/lib/wiki_generator.rb b/generators/wiki/lib/wiki_generator.rb index bc61abafea099a20a1a3adcd24dbb03a78fc8586..8a420e66d4cecfb65fe486bb914a97a4b8ae6a02 100644 --- a/generators/wiki/lib/wiki_generator.rb +++ b/generators/wiki/lib/wiki_generator.rb @@ -99,6 +99,7 @@ class WikiGenerator api_password = yconf['password'] options = { + :generators => [], :sites => G5K::SITES, :diff => false, :print => false, @@ -111,6 +112,10 @@ class WikiGenerator opts.banner = "Usage: <wiki_generator>.rb\n" opts.banner += "This script looks for file ~/.grid5000_api.yml containing your API username and password credentials. The script also recognize API_USER and API_PASSWORD environment variables." + opts.on('-g', '--generators=generator1,generator2', Array, 'Run those generators') do |g| + options[:generators] = g + end + opts.on('-s', '--sites=site1,site2', Array, 'Only consider these sites (when applicable)') do |sites| options[:sites] = sites.map{ |e| e.downcase } end diff --git a/generators/wiki/wikigen b/generators/wiki/wikigen new file mode 100755 index 0000000000000000000000000000000000000000..560d625d8fccbb49767f3ad2c1c5bb7e85c66ae2 --- /dev/null +++ b/generators/wiki/wikigen @@ -0,0 +1,62 @@ +#!/usr/bin/env ruby + +=begin +require 'simplecov' +SimpleCov.start +=end + +$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), 'lib'))) +require 'wiki_generator' +require 'generators/cpu_parameters' +require 'generators/disk_reservation' +require 'generators/hardware' +require 'generators/oar_properties' +require 'generators/site_hardware' +require 'generators/site_network' + +GLOBAL_GENERATORS = { + 'cpu_parameters' => { + :gen => CPUParametersGenerator, + :page => "Generated/CPUParameters" + }, + 'disk_reservation' => { + :gen => DiskReservationGenerator, + :page => 'Generated/DiskReservation' + }, + 'hardware' => { + :gen => G5KHardwareGenerator, + :page => 'Hardware' + }, + 'oar_properties' => { + :gen => OarPropertiesGenerator, + :page => 'Generated/OAR_Properties' + } +} +SITE_GENERATORS = { + 'site_hardware' => { + :gen => SiteHardwareGenerator, + :page_suffix => ':Hardware' + }, + 'site_network' => { + :gen => SiteNetworkGenerator, + :page_suffix => ':GeneratedNetwork' + } +} +GENERATORS = GLOBAL_GENERATORS.merge(SITE_GENERATORS) + +options = WikiGenerator::parse_options +p options +myopts = options.clone +options[:generators].each do |g| + myopts[:generators] = [g] + options[:sites].each do |s| + myopts[:sites] = [s] + if GLOBAL_GENERATORS.has_key?(g) and s == 'global' + GLOBAL_GENERATORS[g][:gen].new(GLOBAL_GENERATORS[g][:page]).exec(myopts) + elsif SITE_GENERATORS.has_key?(g) and s != 'global' + SITE_GENERATORS[g][:gen].new(s.capitalize + SITE_GENERATORS[g][:page_suffix], s).exec(myopts) + else + puts "Nothing to do: #{g}/#{s}" + end + end +end