1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 class KeepDisk < ArvadosModel
8 include CommonApiTemplate
9 before_validation :ensure_ping_secret
11 api_accessible :user, extend: :common do |t|
13 t.add :filesystem_uuid
23 t.add :service_ssl_flag
24 t.add :keep_service_uuid
26 api_accessible :superuser, :extend => :user do |t|
30 def foreign_key_attributes
31 super.reject { |a| a == "filesystem_uuid" }
35 raise "must have :service_host and :ping_secret" unless o[:service_host] and o[:ping_secret]
37 if o[:ping_secret] != self.ping_secret
38 logger.info "Ping: secret mismatch: received \"#{o[:ping_secret]}\" != \"#{self.ping_secret}\""
42 @bypass_arvados_authorization = true
43 self.update_attributes!(o.select { |k,v|
50 ].collect(&:to_s).index k
51 }.merge(last_ping_at: db_current_time))
55 KeepService.find_by_uuid(self.keep_service_uuid).andand.service_host
59 KeepService.find_by_uuid(self.keep_service_uuid).andand.service_port
63 KeepService.find_by_uuid(self.keep_service_uuid).andand.service_ssl_flag
68 def ensure_ping_secret
69 self.ping_secret ||= rand(2**256).to_s(36)
72 def permission_to_update
73 @bypass_arvados_authorization or super
76 def permission_to_create
77 current_user and current_user.is_admin