add jobs#log_tail_follow
[arvados.git] / services / api / app / controllers / arvados / v1 / keep_disks_controller.rb
1 class Arvados::V1::KeepDisksController < ApplicationController
2   skip_before_filter :login_required, :only => :ping
3
4   def self._ping_requires_parameters
5     {
6       uuid: false,
7       ping_secret: true,
8       ec2_instance_id: false,
9       local_ipv4: false,
10       filesystem_uuid: false,
11       service_port: true,
12       service_ssl_flag: true
13     }
14   end
15   def ping
16     if !@object and params[:filesystem_uuid] and current_user and current_user.is_admin
17       if KeepDisk.where('filesystem_uuid=?', params[:filesystem_uuid]).empty?
18         @object = KeepDisk.new filesystem_uuid: params[:filesystem_uuid]
19         @object.save!
20         params[:ping_secret] = @object.ping_secret
21       else
22         raise "ping from keep_disk with existing filesystem_uuid #{params[:filesystem_uuid]} but wrong uuid #{params[:uuid]}"
23       end
24     end
25
26     if !@object
27       return render_not_found "object not found"
28     end
29
30     params.merge!(service_host:
31                   params[:local_ipv4] || request.env['REMOTE_ADDR'])
32     @object.ping params
33     show
34   end
35 end