Commit 6dbcde47 authored by Lucas Nussbaum's avatar Lucas Nussbaum
Browse files

[dev/wiki] Improve code organization

parent 2aea2258
......@@ -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
......
......@@ -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
......
......@@ -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
......
#!/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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment