diff --git a/generators/grid5000.rb b/generators/grid5000.rb index f8bd49eb3f3aff49db4886e9ce33c19643880c5a..825f4868cdbfa8af4d29f2a84b0ad53ba94d2819 100755 --- a/generators/grid5000.rb +++ b/generators/grid5000.rb @@ -10,10 +10,12 @@ usage = %{ A tool to generate the Grid5000 reference data. Usage: - ruby grid5000.rb [input files] [options] + ruby grid5000.rb [input files] [config files] [options] Options: -s : simulation mode - + Notes: + input files must be RUBY files and end with a .rb extension. + config files mst be YAML files and end with a .yaml extension. } # true if we want to simulate: @@ -21,10 +23,10 @@ simulation_mode = !$*.delete("-s").nil? if $*.empty? puts usage - exit -1 -elsif ($*.map{|file| File.exists?(file) && (File.extname(file) == ".rb" || File.extname(file) == ".yaml")}.include? false) - puts "Error: your input files do not exist or are not ruby files (.rb extension) or config files (.yaml extension)." - exit -1 + exit 1 +elsif ($*.map{|file| File.exists?(file)}.include? false) + puts "Error: one of your input file do not exist." + exit 2 else description_files = $* input = {} diff --git a/generators/lib/g5k_generator.rb b/generators/lib/g5k_generator.rb index 2c4ea28652b8cf1e3f9b58c41f407506a5837c40..fbd8519abbee709182cbb299a70b952eeeeec269 100755 --- a/generators/lib/g5k_generator.rb +++ b/generators/lib/g5k_generator.rb @@ -65,8 +65,9 @@ class ReferenceGenerator Resolv.getaddress(network_address) end + # Lookup a key in one of the configuration files passed to the generator # - # usage: + # Usage: # lookup('nancy', 'nodes', 'paramount-1', 'property_name') # or # lookup('nancy', 'nodes') { |result| result['paramount-1']['property_name'] } @@ -158,7 +159,8 @@ class ReferenceGenerator # Initializes a new generator that will generate data files in a hierachical way. # The root of the tree will be named with the value of <tt>data_description[:uid]</tt>. def initialize(data_description = {:uid => ""}, options = {:input => {}, :config => {}}) - @input = options[:input] || raise(ArgumentError, "INPUT cannot be null.") + @input = options[:input] + raise(ArgumentError, "INPUT cannot be null or empty.") if input.nil? || input.empty? @config = options[:config] || {} @data = G5K::Tree.new.replace(data_description) @context = @data