X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/3e3df723e221dadf2512ac4935c1f6f0fe8f7834..2935de4fbccf43b7daedb9412f2ada1bf65c52ab:/services/api/app/models/node.rb diff --git a/services/api/app/models/node.rb b/services/api/app/models/node.rb index 119a0edeff..c791f8e255 100644 --- a/services/api/app/models/node.rb +++ b/services/api/app/models/node.rb @@ -7,6 +7,12 @@ class Node < ArvadosModel before_validation :ensure_ping_secret after_update :dnsmasq_update + # Only a controller can figure out whether or not the current API tokens + # have access to the associated Job. They're expected to set + # job_readable=true if the Job UUID can be included in the API response. + belongs_to(:job, foreign_key: :job_uuid, primary_key: :uuid) + attr_accessor :job_readable + MAX_SLOTS = 64 @@confdir = Rails.configuration.dnsmasq_conf_dir @@ -20,6 +26,7 @@ class Node < ArvadosModel t.add :last_ping_at t.add :slot_number t.add :status + t.add :api_job_uuid, as: :job_uuid t.add :crunch_worker_state t.add :properties end @@ -33,6 +40,10 @@ class Node < ArvadosModel super || @@domain end + def api_job_uuid + job_readable ? job_uuid : nil + end + def crunch_worker_state return 'down' if slot_number.nil? case self.info.andand['slurm_state']