Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 2a39dee9 authored by Jérémie Gaidamour's avatar Jérémie Gaidamour
Browse files

[dev] List diff between the properties of the ref api and the properties of the OAR server

parent b95060f3
Branches
No related tags found
No related merge requests found
#!/usr/bin/ruby #!/usr/bin/ruby
# Generator for the OAR properties
require 'pp' require 'pp'
require 'erb' require 'erb'
require 'fileutils' require 'fileutils'
...@@ -87,46 +89,70 @@ end.parse! ...@@ -87,46 +89,70 @@ end.parse!
pp options pp options
# Option nodelist_properties = {} # ["ref"] : properties from the reference-repo
site_uid = 'nancy' # ["oar"] : properties from the OAR server
# ["diff"] : diff between "ref" and "oar"
nodelist_properties = {}
# #
# Get the OAR properties from the reference-repo # Get the OAR properties from the reference-repo (["ref"])
# #
nodelist_properties["ref"] = {}
global_hash = load_yaml_file_hierarchy('../../input/grid5000/') global_hash = load_yaml_file_hierarchy('../../input/grid5000/')
nodelist_properties["ref"] = get_nodelist_properties(site_uid, global_hash["sites"][site_uid]) options[:sites].each { |site_uid|
nodelist_properties["ref"][site_uid] = get_nodelist_properties(site_uid, global_hash["sites"][site_uid])
}
# #
# Get the current OAR properties from the OAR scheduler # Get the current OAR properties from the OAR scheduler (["oar"])
# This is only needed for the -d option
# #
nodelist_properties["oar"] = {} nodelist_properties["oar"] = {}
options[:sites].each { |site_uid|
nodelist_properties["oar"][site_uid] = {}
if options[:diff] # This is only needed for the -d option
filename = options[:diff].is_a?(String) ? options[:diff].gsub("%s", site_uid) : nil if options[:diff]
nodelist_properties["oar"] = oarcmd_get_nodelist_properties(site_uid, filename) filename = options[:diff].is_a?(String) ? options[:diff].gsub("%s", site_uid) : nil
end nodelist_properties["oar"][site_uid] = oarcmd_get_nodelist_properties(site_uid, filename)
end
}
# #
# Diff # Diff
# #
node_properties = {} nodelist_properties["to_be_updated"] = {}
node_properties["ref"] = nodelist_properties["ref"]["graphene-1"]
node_properties["oar"] = nodelist_properties["oar"]["graphene-1"]
diff = diff_node_properties(node_properties["ref"], node_properties["oar"]) nodelist_properties["ref"].each { |site_uid, site_properties|
diff_keys = diff.map{ |hashdiff_array| hashdiff_array[1] }
site_properties.sort_by { |item| item.to_s.split(/(\d+)/).map { |e| [e.to_i, e] } }.each { |node_uid, node_properties_ref|
cluster_uid = node_uid.split(/-/).first
if (! options[:clusters] || options[:clusters].include?(cluster_uid)) &&
(! options[:nodes] || options[:nodes].include?(node_uid))
node_properties_oar = nodelist_properties["oar"][site_uid][node_uid]
diff = diff_node_properties(node_properties_ref, node_properties_oar)
diff_keys = diff.map{ |hashdiff_array| hashdiff_array[1] }
nodelist_properties["to_be_updated"][node_uid] = node_properties_ref.select { |key, value| diff_keys.include?(key) }
if (options[:verbose])
#puts "#{node_uid}: #{diff}"
puts "#{node_uid}: #{diff_keys}"
end
end
}
}
node_properties["to_be_updated"] = node_properties["ref"].select { |key, value| diff_keys.include?(key) }
# #
# Example # Example
# #
puts oarcmd_set_node_properties("graphene-1", node_properties["oar"]) #puts oarcmd_set_node_properties("graphene-1", node_properties["oar"])
puts oarcmd_set_node_properties("graphene-1", node_properties["to_be_updated"]) #puts oarcmd_set_node_properties("graphene-1", node_properties["to_be_updated"])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment