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
4e3ea3fa
Commit
4e3ea3fa
authored
Nov 16, 2018
by
Lucas Nussbaum
Browse files
[dev] migrate network validator
parent
22c367b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Rakefile
View file @
4e3ea3fa
...
...
@@ -79,6 +79,23 @@ namespace :valid do
exit
(
ret
)
end
desc
"Check network description -- parameters: [SITE={grenoble,...}] [VERBOSE=1] GENERATE_DOT=1"
task
"network"
do
require
'refrepo/valid/network'
options
=
{}
options
[
:sites
]
=
(
ENV
[
'SITE'
]
?
ENV
[
'SITE'
].
split
(
','
)
:
G5K_SITES
)
options
[
:verbose
]
=
true
if
ENV
[
'VERBOSE'
]
options
[
:dot
]
=
true
if
ENV
[
'GENERATE_DOT'
]
ret
=
2
begin
ret
=
check_network_description
(
options
)
rescue
StandardError
=>
e
puts
e
ret
=
3
ensure
exit
(
ret
)
end
end
end
namespace
:gen
do
...
...
lib/refrepo/valid/
input/check-network-description
.rb
→
lib/refrepo/valid/
network
.rb
View file @
4e3ea3fa
...
...
@@ -20,10 +20,10 @@ def check_network_description(options)
# get list of network equipments and nodes
neteqs
=
[]
nodes
=
[]
Dir
::
glob
(
"
../../
data/grid5000/sites/
#{
site
}
/network_equipments/*.json"
).
each
do
|
f
|
Dir
::
glob
(
"data/grid5000/sites/
#{
site
}
/network_equipments/*.json"
).
each
do
|
f
|
neteqs
<<
JSON
::
parse
(
IO
::
read
(
f
))
end
Dir
::
glob
(
"
../../
data/grid5000/sites/
#{
site
}
/clusters/*/nodes/*.json"
).
each
do
|
f
|
Dir
::
glob
(
"data/grid5000/sites/
#{
site
}
/clusters/*/nodes/*.json"
).
each
do
|
f
|
nodes
<<
JSON
::
parse
(
IO
::
read
(
f
))
end
...
...
@@ -286,56 +286,3 @@ def sh(cmd)
end
return
output
end
if
__FILE__
==
$0
require
'optparse'
options
=
{}
options
[
:sites
]
=
%w{grenoble lille luxembourg lyon nancy nantes rennes sophia}
OptionParser
.
new
do
|
opts
|
opts
.
banner
=
"Usage: check-network-description.rb [options]"
opts
.
separator
""
opts
.
separator
"Example: ruby check-network-description.rb -v"
###
opts
.
separator
""
opts
.
separator
"Filters:"
opts
.
on
(
'-s'
,
'--sites a,b,c'
,
Array
,
'Select site(s)'
,
"Default: "
+
options
[
:sites
].
join
(
", "
))
do
|
s
|
raise
"Wrong argument for -s option."
unless
(
s
-
options
[
:sites
]).
empty?
options
[
:sites
]
=
s
end
opts
.
separator
""
opts
.
separator
"Common options:"
opts
.
on
(
"-v"
,
"--[no-]verbose"
,
"Run verbosely"
)
do
|
v
|
options
[
:verbose
]
||=
0
options
[
:verbose
]
=
options
[
:verbose
]
+
1
end
opts
.
on
(
""
,
"--dot"
,
"Generate one dotfile per site"
)
do
options
[
:dot
]
=
true
end
# Print an options summary.
opts
.
on_tail
(
"-h"
,
"--help"
,
"Show this message"
)
do
puts
opts
exit
end
end
.
parse!
ret
=
2
begin
ret
=
check_network_description
(
options
)
rescue
StandardError
=>
e
puts
e
ret
=
3
ensure
exit
(
ret
)
end
end
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