X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/54d881132042e01bb87d2409382da091e3d3aff7..651638a28db20a2016dff02e3baa106ab27ff945:/services/api/app/models/keep_disk.rb diff --git a/services/api/app/models/keep_disk.rb b/services/api/app/models/keep_disk.rb index b705f0b411..da421ebb4c 100644 --- a/services/api/app/models/keep_disk.rb +++ b/services/api/app/models/keep_disk.rb @@ -1,13 +1,12 @@ class KeepDisk < ArvadosModel - include AssignUuid + include HasUuid include KindAndEtag include CommonApiTemplate before_validation :ensure_ping_secret - api_accessible :superuser, :extend => :common do |t| + api_accessible :user, extend: :common do |t| t.add :node_uuid t.add :filesystem_uuid - t.add :ping_secret t.add :bytes_total t.add :bytes_free t.add :is_readable @@ -15,6 +14,17 @@ class KeepDisk < ArvadosModel t.add :last_read_at t.add :last_write_at t.add :last_ping_at + t.add :service_host + t.add :service_port + t.add :service_ssl_flag + t.add :keep_service_uuid + end + api_accessible :superuser, :extend => :user do |t| + t.add :ping_secret + end + + def foreign_key_attributes + super.reject { |a| a == "filesystem_uuid" } end def ping(o) @@ -26,11 +36,8 @@ class KeepDisk < ArvadosModel end @bypass_arvados_authorization = true - self.update_attributes(o.select { |k,v| - [:service_host, - :service_port, - :service_ssl_flag, - :bytes_total, + self.update_attributes!(o.select { |k,v| + [:bytes_total, :bytes_free, :is_readable, :is_writable, @@ -40,6 +47,18 @@ class KeepDisk < ArvadosModel }.merge(last_ping_at: Time.now)) end + def service_host + KeepService.find_by_uuid(self.keep_service_uuid).andand.service_host + end + + def service_port + KeepService.find_by_uuid(self.keep_service_uuid).andand.service_port + end + + def service_ssl_flag + KeepService.find_by_uuid(self.keep_service_uuid).andand.service_ssl_flag + end + protected def ensure_ping_secret