1 class Arvados::V1::NodesController < ApplicationController
2 skip_before_filter :require_auth_scope, :only => :ping
3 skip_before_filter :find_object_by_uuid, :only => :ping
4 skip_before_filter :render_404_if_no_object, :only => :ping
9 @object.start!(lambda { |h| ping_arvados_v1_node_url(h) })
14 if resource_attrs[:job_uuid]
15 @object.job_readable = readable_job_uuids(resource_attrs[:job_uuid]).any?
20 def self._ping_requires_parameters
26 @object = Node.where(uuid: (params[:id] || params[:uuid])).first
28 return render_not_found
31 ip: params[:local_ipv4] || request.env['REMOTE_ADDR'],
32 ec2_instance_id: params[:instance_id]
34 [:ping_secret, :total_cpu_cores, :total_ram_mb, :total_scratch_mb]
36 ping_data[key] = params[key] if params[key]
38 @object.ping(ping_data)
39 if @object.info['ping_secret'] == params[:ping_secret]
40 render json: @object.as_api_response(:superuser)
42 raise "Invalid ping_secret after ping"
47 def find_objects_for_index
48 if current_user.andand.is_admin || !current_user.andand.is_active
51 # active non-admin users can list nodes that are (or were
53 @objects = model_class.where('last_ping_at >= ?', Time.now - 1.hours)
55 assigned_nodes = @objects.select(&:job_uuid)
56 assoc_jobs = readable_job_uuids(*assigned_nodes.map(&:job_uuid))
57 assigned_nodes.each do |node|
58 node.job_readable = assoc_jobs.include?(node.job_uuid)
64 def readable_job_uuids(*uuids)
65 Job.readable_by(*@read_users).select(:uuid).where(uuid: uuids).map(&:uuid)