Mentions légales du service

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

[dev] migrate input/schema

parent b1eef313
No related branches found
No related tags found
No related merge requests found
......@@ -58,9 +58,14 @@ namespace :valid do
exit(ret)
end
desc "Check input data schema validity"
desc "Check input data schema validity -- parameters: SITE={grenoble,..} CLUSTER={yeti,..}"
task "schema" do
invoke_script "#{VALIDATORS_DIR}/yaml-input-schema-validator.rb"
require 'refrepo/valid/input/schema'
options = {}
options[:sites] = ( ENV['SITE'] ? ENV['SITE'].split(',') : G5K_SITES )
options[:clusters] = ( ENV['CLUSTER'] ? ENV['CLUSTER'].split(',') : [] )
ret = yaml_input_schema_validator(options)
exit(ret)
end
desc "Check OAR properties -- parameters: [SITE={grenoble,...}] [CLUSTER={yeti,...}] [VERBOSE=1]"
......
#!/usr/bin/ruby
if RUBY_VERSION < "2.1"
puts "This script requires ruby >= 2.1"
exit
end
require 'fileutils'
require 'pathname'
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../../lib')))
require 'refrepo/input_loader'
require_relative "./lib/schema_validator"
......@@ -23,12 +17,15 @@ def run_validator(uid, data, schema)
return true
end
def yaml_input_schema_validator(global_hash, sites = nil, clusters = nil)
schema_global = load_yaml_schema(File.expand_path("./schema-global.yaml", File.dirname(__FILE__)))
schema_site = load_yaml_schema(File.expand_path("./schema-site.yaml", File.dirname(__FILE__)))
schema_cluster = load_yaml_schema(File.expand_path("./schema-cluster.yaml", File.dirname(__FILE__)))
schema_node = load_yaml_schema(File.expand_path("./schema-node.yaml", File.dirname(__FILE__)))
schema_network_equipments = load_yaml_schema(File.expand_path("./schema-network_equipments.yaml", File.dirname(__FILE__)))
def yaml_input_schema_validator(options)
global_hash = load_yaml_file_hierarchy
sites = options[:sites]
clusters = options[:clusters]
schema_global = load_yaml_schema(File.expand_path("./schemas/schema-global.yaml", File.dirname(__FILE__)))
schema_site = load_yaml_schema(File.expand_path("./schemas/schema-site.yaml", File.dirname(__FILE__)))
schema_cluster = load_yaml_schema(File.expand_path("./schemas/schema-cluster.yaml", File.dirname(__FILE__)))
schema_node = load_yaml_schema(File.expand_path("./schemas/schema-node.yaml", File.dirname(__FILE__)))
schema_network_equipments = load_yaml_schema(File.expand_path("./schemas/schema-network_equipments.yaml", File.dirname(__FILE__)))
r = true
......@@ -44,7 +41,7 @@ def yaml_input_schema_validator(global_hash, sites = nil, clusters = nil)
end
site["clusters"].each do |cluster_uid, cluster|
next if clusters and not clusters.include?(cluster_uid)
next if clusters and not clusters.empty? and not clusters.include?(cluster_uid)
r &= run_validator(cluster_uid, cluster, schema_cluster) #
......@@ -57,39 +54,3 @@ def yaml_input_schema_validator(global_hash, sites = nil, clusters = nil)
end
return r
end
if __FILE__ == $0
require 'optparse'
options = {}
OptionParser.new do |opts|
opts.banner = "Usage: yaml-input-schema-validator.rb [options]"
###
opts.separator ""
opts.separator "Filters:"
opts.on('-s', '--sites a,b,c', Array, 'Select site(s)',
"Default: all sites") do |s|
options[:sites] = s
end
opts.on('-c', '--clusters a,b,c', Array, 'Select clusters(s). Default: all') do |s|
options[:clusters] = s
end
# Print an options summary.
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
end.parse!
puts "Checking input data:\n\n"
global_hash = load_yaml_file_hierarchy(File.expand_path("../../input/grid5000/", File.dirname(__FILE__)))
r = yaml_input_schema_validator(global_hash, options[:sites], options[:clusters])
puts 'OK' if r
exit r
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