Commit 6353540f authored by Florent Didier's avatar Florent Didier

[dev] oar-properties: compute property keys on each site individually

The property keys were generated globaly (for all sites), which
caused errors when different sites had different properties (one site
can have reservable disks with key 'disk', but not the other).
In this commit I compute properties on each site individually.
parent 0b499727
......@@ -200,7 +200,7 @@ def get_ref_disk_properties_internal(site_uid, cluster_uid, node_uid, node)
node['storage_devices'].to_a.each_with_index do |v, index|
device_uid, device = v
disk = [device_uid, node_uid].join('.')
if index > 0 && device['reservation']
if index > 0 && device['reservation'] # index > 0 is used to exclude sda
key = [node_uid, disk]
h = {}
node_address = [node_uid, site_uid, 'grid5000.fr'].join('.')
......@@ -293,10 +293,8 @@ end
# We detect the type of the property (Fixnum/String) by looking at the existing values
def get_property_keys(properties)
properties_keys = {}
properties.each do |_site_uid, site_properties|
site_properties.each do |type, type_properties|
properties_keys.merge!(get_property_keys_internal(type, type_properties))
end
properties.each do |type, type_properties|
properties_keys.merge!(get_property_keys_internal(type, type_properties))
end
return properties_keys
end
......
......@@ -213,16 +213,11 @@ global_hash = load_yaml_file_hierarchy(File.expand_path('../../input/grid5000/',
properties = {}
properties['ref'] = get_oar_properties_from_the_ref_repo(global_hash, options)
# Get the list of property keys from the reference-repo (['ref'])
properties_keys = {}
properties_keys['ref'] = get_property_keys(properties['ref'])
properties['oar'] = get_oar_properties_from_oar(options)
ignore_default_keys = ignore_default_keys()
# Diff
if options[:diff]
properties['oar'] = get_oar_properties_from_oar(options)
# Build the list of nodes that are listed in properties['oar'],
# but does not exist in properties['ref']
# We distinguish 'Dead' nodes and 'Alive'/'Absent'/etc. nodes
......@@ -250,7 +245,6 @@ Those nodes should be marked as 'retired' in the reference-repo.\n"
skipped_nodes = []
prev_diff = {}
properties['diff'] = {}
properties_keys['oar'] = Set.new []
header = false
properties['ref'].each do |site_uid, site_properties|
......@@ -306,29 +300,6 @@ Those nodes should be marked as 'retired' in the reference-repo.\n"
end
end
# Get the list of property keys from the OAR scheduler (['oar'])
properties_keys['oar'] = get_property_keys(properties['oar'])
# Build the list of properties that must be created in the OAR server
properties_keys['diff'] = {}
properties_keys['ref'].each do |k, v_ref|
v_oar = properties_keys['oar'][k]
properties_keys['diff'][k] = v_ref unless v_oar
if v_oar && v_oar != v_ref && v_ref != NilClass && v_oar != NilClass
# Detect inconsistency between the type (String/Fixnum) of properties generated by this script and the existing values on the server.
puts "Error: the OAR property '#{k}' is a '#{v_oar}' on the server and this script uses '#{v_ref}' for this property."
ret = false unless options[:exec] || options[:output]
end
end
puts "Properties that need to be created on the server: #{properties_keys['diff'].keys.to_a.delete_if { |e| ignore_default_keys.include?(e) }.join(', ')}" if options[:verbose] && properties_keys['diff'].keys.to_a.delete_if { |e| ignore_default_keys.include?(e) }.size > 0
# Detect unknown properties
unknown_properties = properties_keys['oar'].keys.to_set - properties_keys['ref'].keys.to_set
ignore_default_keys.each do |key|
unknown_properties.delete(key)
end
if options[:verbose] && unknown_properties.size > 0
puts "Properties existing on the server but not managed/known by the generator: #{unknown_properties.to_a.join(', ')}."
puts "Hint: you can delete properties with 'oarproperty -d <property>' or add them to the ignore list in lib/lib-oar-properties.rb."
......@@ -350,8 +321,35 @@ if options[:output] || options[:exec]
cmd << oarcmd_script_header
cmd << oarcmd_separator
# Get the list of property keys from the reference-repo (['ref'])
properties_keys = {}
properties_keys['ref'] = get_property_keys(properties['ref'][site_uid])
# Create properties keys
properties_keys[opt].delete_if { |k, _v| ignore_default_keys.include?(k) }
# Get the list of property keys from the OAR scheduler (['oar'])
properties_keys['oar'] = get_property_keys(properties['oar'][site_uid])
# Build the list of properties that must be created in the OAR server
properties_keys['diff'] = {}
properties_keys['ref'].each do |k, v_ref|
v_oar = properties_keys['oar'][k]
properties_keys['diff'][k] = v_ref unless v_oar
if v_oar && v_oar != v_ref && v_ref != NilClass && v_oar != NilClass
# Detect inconsistency between the type (String/Fixnum) of properties generated by this script and the existing values on the server.
puts "Error: the OAR property '#{k}' is a '#{v_oar}' on the #{site_uid} server and this script uses '#{v_ref}' for this property."
ret = false unless options[:exec] || options[:output]
end
end
puts "Properties that need to be created on the #{site_uid} server: #{properties_keys['diff'].keys.to_a.delete_if { |e| ignore_default_keys.include?(e) }.join(', ')}" if options[:verbose] && properties_keys['diff'].keys.to_a.delete_if { |e| ignore_default_keys.include?(e) }.size > 0
# Detect unknown properties
unknown_properties = properties_keys['oar'].keys.to_set - properties_keys['ref'].keys.to_set
ignore_default_keys.each do |key|
unknown_properties.delete(key)
properties_keys[opt].delete(key)
end
unless properties_keys[opt].empty?
cmd << oarcmd_create_properties(properties_keys[opt]) + "\n"
cmd << oarcmd_separator
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment