Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4e3ea3fa authored by Lucas Nussbaum's avatar Lucas Nussbaum
Browse files

[dev] migrate network validator

parent 22c367b3
No related branches found
No related tags found
No related merge requests found
...@@ -79,6 +79,23 @@ namespace :valid do ...@@ -79,6 +79,23 @@ namespace :valid do
exit(ret) exit(ret)
end 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 end
namespace :gen do namespace :gen do
......
...@@ -20,10 +20,10 @@ def check_network_description(options) ...@@ -20,10 +20,10 @@ def check_network_description(options)
# get list of network equipments and nodes # get list of network equipments and nodes
neteqs = [] neteqs = []
nodes = [] 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)) neteqs << JSON::parse(IO::read(f))
end 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)) nodes << JSON::parse(IO::read(f))
end end
...@@ -286,56 +286,3 @@ def sh(cmd) ...@@ -286,56 +286,3 @@ def sh(cmd)
end end
return output return output
end 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment