1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 class Arvados::V1::KeepDisksController < ApplicationController
6 skip_before_filter :require_auth_scope, only: :ping
7 skip_before_filter :render_404_if_no_object, only: :ping
9 def self._ping_requires_parameters
11 uuid: {required: false},
12 ping_secret: {required: true},
13 node_uuid: {required: false},
14 filesystem_uuid: {required: false},
15 service_host: {required: false},
16 service_port: {required: true},
17 service_ssl_flag: {required: true}
22 params[:service_host] ||= request.env['REMOTE_ADDR']
23 if !params[:uuid] && current_user.andand.is_admin
24 # Create a new KeepDisk and ping it.
25 @object = KeepDisk.new(filesystem_uuid: params[:filesystem_uuid])
28 # In the first ping from this new filesystem_uuid, we can't
29 # expect the keep node to know the ping_secret so we made sure
30 # we got an admin token. Here we add ping_secret to params so
31 # the ping call below is properly authenticated.
32 params[:ping_secret] = @object.ping_secret
35 if !@object.andand.ping(params)
36 return render_not_found "object not found"
38 # Render the :superuser view (i.e., include the ping_secret) even
39 # if !current_user.is_admin. This is safe because @object.ping's
40 # success implies the ping_secret was already known by the client.
41 send_json @object.as_api_response(:superuser)
45 def find_objects_for_index
46 # all users can list all keep disks
47 @objects = model_class.where('1=1')