Attention une mise à jour du service Gitlab va être effectuée le mardi 30 novembre entre 17h30 et 18h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes. Cette mise à jour intermédiaire en version 14.0.12 nous permettra de rapidement pouvoir mettre à votre disposition une version plus récente.

Commit 8657cbda authored by Samir Noir's avatar Samir Noir 🧀
Browse files

Expose all OAR resources on status api

parent 28aa5b89
Pipeline #173456 passed with stages
in 21 minutes and 42 seconds
......@@ -48,8 +48,17 @@ class SitesController < ResourcesController
]
}
expected_rtypes = ['node']
expected_rtypes.push('disk') if params[:disks] != 'no'
rtypes = OAR::Resource.select(:type).distinct.map{ |t| t.type }
expected_rtypes = []
rtypes.each do |oar_type|
plural_type = OAR::Resource.api_type(oar_type)
if params[plural_type] != 'no'
expected_rtypes.push(oar_type)
end
end
result.merge!(OAR::Resource.status(clusters: valid_clusters, network_address: params[:network_address], job_details: params[:job_details], waiting: params[:waiting], types: expected_rtypes))
respond_to do |format|
......
......@@ -23,6 +23,8 @@ module OAR
# disable inheritance guessed by Rails because of the "type" column.
self.inheritance_column = :_type_disabled
EXCLUDED_TYPES = ['storage', 'metroflux', 'kavlan-topo']
QUERY_ASSIGNED_RESOURCES = 'SELECT moldable_job_id, resource_id FROM assigned_resources WHERE moldable_job_id IN (%MOLDABLE_IDS%)'.freeze
QUERY_GANTT_JOBS_RESOURCES = 'SELECT moldable_job_id, resource_id FROM gantt_jobs_resources WHERE moldable_job_id IN (%MOLDABLE_IDS%)'.freeze
def dead?
......@@ -45,6 +47,10 @@ module OAR
network_address
when 'disk'
[disk.split('.').first, host].join('.')
when /^(kavlan|kavlan-global|kavlan-local)$/
vlan
when 'subnet'
subnet_address + '/' + subnet_prefix.to_s
else
resource_id
end
......@@ -52,7 +58,10 @@ module OAR
class << self
def api_type(oar_type)
if oar_type == 'default'
case oar_type
when /^(kavlan|kavlan-global|kavlan-local)$/
'vlans'
when 'default'
'nodes'
else
oar_type.pluralize
......@@ -60,17 +69,7 @@ module OAR
end
def list_some(options)
# Do OAR resources have a comment column
include_comment = columns.find { |c| c.name == 'comment' }
# Do OAR resources have a disk column
include_disk = columns.find { |c| c.name == 'disk' }
# bug 5106 : we need cluster & core
# bug 9230 : we need type, disk and diskpath
resources = Resource.select(
"resource_id, type, cluster, host, network_address, #{include_disk ? 'disk, diskpath,' : ''} core, state, available_upto#{include_comment ? ', comment' : ''}"
)
resources = Resource
unless options[:network_address].blank?
resources = resources.where(
......@@ -78,14 +77,14 @@ module OAR
)
end
unless options[:clusters].blank?
if options[:clusters].present?
resources = resources.where(
cluster: options[:clusters]
)
cluster: options[:clusters], type: options[:oar_types]
).or(resources.where(type: options[:oar_types], cluster: nil))
else
resources = resources.where(type: options[:oar_types])
end
resources = resources.where(type: options[:oar_types])
resources
end
......@@ -123,6 +122,7 @@ module OAR
# No types requested implies default
# and default is returned as nodes
options[:types] = ['node'] if options[:types].nil?
options[:types].reject! { |t| EXCLUDED_TYPES.include?(t) }
options[:oar_types] = options[:types]
had_node = options[:oar_types].delete('node') == 'node'
......@@ -270,6 +270,11 @@ module OAR
when 'disk'
h[:soft] = 'free'
h[:diskpath] = resource.diskpath
when /^(kavlan|kavlan-global|kavlan-local)$/
h[:soft] = 'free'
h[:type] = resource.type
else
h[:soft] = 'free'
end
h
end
......
......@@ -141,6 +141,9 @@ describe SitesController do
parapluie
parasilo
].sort
expect(json['vlans']).to be_a(Hash)
expect(json['vlans'].length).to eq 7
expect(json['vlans']['1']['type']).to eq 'kavlan-local'
expect(json['disks']).not_to be_nil
expect(json['nodes']['parapide-5.rennes.grid5000.fr']['reservations']).not_to be_nil
expect(json['nodes']['parapide-5.rennes.grid5000.fr']['free_slots']).not_to be_nil
......
This diff is collapsed.
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