Mentions légales du service

Skip to content
Snippets Groups Projects

[gen/wiki/oar] use get_api helper and raise an error when undocumented properties

Merged Teddy Valette requested to merge oar_wiki_gen_api_call into master
@@ -222,7 +222,11 @@ class OarPropertiesGenerator < WikiGenerator
}
#Existing properties that won't be documented
@@ignored_properties = ["maintenance", "state", "ip_virtual"]
@@ignored_properties = [
"maintenance", "state", "ip_virtual", "api_timestamp", "available_upto", "chunks", "desktop_computing",
"drain", "finaud_decision", "grub", "id", "last_available_upto", "last_job_date", "links", "next_finaud_decision",
"next_state", "rconsole", "scheduler_priority", "state_num", "suspended_jobs"
]
def get_value_type(prop, values)
if (@@properties[prop]["value_type"])
@@ -243,20 +247,18 @@ class OarPropertiesGenerator < WikiGenerator
refapi = load_data_hierarchy
#Properties generated from oar-properties generator
props = {}
oar_data_properties = []
oarapi_properties = []
G5K::SITES.each_with_index{ |site_uid, index|
props[site_uid] = {}
props[site_uid]["default"] = get_ref_default_properties(site_uid, refapi["sites"][site_uid])
props[site_uid]["disk"] = get_ref_disk_properties(site_uid, refapi["sites"][site_uid])
}
# Retrieve all oar fields from the first site
if index == 0
get_oar_data(site_uid, {:api => {}, :verbose => false}).each { |oar_node_data, _|
oar_node_data.each { |key, _|
oar_data_properties << key unless oar_data_properties.include? key
}
}
end
RefRepo::Utils::get_api("sites/#{G5K::SITES.first}/internal/oarapi/resources/details.json?limit=999999")['items'].each { |oarapi_details|
oarapi_details.keys.each { |property|
oarapi_properties << property unless oarapi_properties.include? property
}
}
#Compiled properties used to generate page
@@ -288,13 +290,13 @@ class OarPropertiesGenerator < WikiGenerator
@@properties[prop]["possible_values"] ||= prop_hash["values"].join(", ") unless @@properties[prop].nil?
}
# Compare properties with fields from oar db
oar_data_properties.reject!{|x| (@@properties.keys.include? x or @@ignored_properties.include? x)}
# If there are undocumented and not ignored properties, we raise an error
oarapi_properties.reject!{|x| (@@properties.keys.include? x or @@ignored_properties.include? x)}
if not oarapi_properties.empty?
raise("Following properties are not documented : #{oarapi_properties.sort.join(', ')}")
end
@generated_content = "{{Portal|User}}\nProperties on resources managed by OAR allow users to select them according to their experiment's characteristics." + MW::LINE_FEED
if not oar_data_properties.empty?
@generated_content += "{{Warning|text=Following properties are not documented : " + oar_data_properties.sort.join(', ') + "}}" + MW::LINE_FEED
end
@generated_content += MW::heading("OAR Properties", 1) + MW::LINE_FEED
@@categories.sort.to_h.each { |cat, cat_properties|
Loading