Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
grid5000
reference-repository
Commits
14d8372d
Commit
14d8372d
authored
Jun 09, 2009
by
Cyril Rohr
Browse files
better doc and error handling
parent
c5b004df
Changes
2
Hide whitespace changes
Inline
Side-by-side
generators/grid5000.rb
View file @
14d8372d
...
...
@@ -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 file
s
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
=
{}
...
...
generators/lib/g5k_generator.rb
View file @
14d8372d
...
...
@@ -65,8 +65,9 @@ class ReferenceGenerator
Resolv
.
getaddress
(
network_address
)
end
# Lookup a key in one of the configuration files passed to the generator
#
#
u
sage:
#
U
sage:
# 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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment