add attributes to job_task api response
[arvados.git] / services / api / app / models / keep_disk.rb
index 6ff64004bf0a8943d146859c9118ac2645f4dea3..b705f0b411f9094261af037320cada133f49c87c 100644 (file)
@@ -18,17 +18,26 @@ class KeepDisk < ArvadosModel
   end
 
   def ping(o)
-    raise "must have :ip and :ping_secret" unless o[:ip] and o[:ping_secret]
+    raise "must have :service_host and :ping_secret" unless o[:service_host] and o[:ping_secret]
 
     if o[:ping_secret] != self.ping_secret
-      logger.info "Ping: secret mismatch: received \"#{o[:ping_secret]}\" != \"#{self.info[:ping_secret]}\""
+      logger.info "Ping: secret mismatch: received \"#{o[:ping_secret]}\" != \"#{self.ping_secret}\""
       return nil
     end
-    self.last_ping_at = Time.now
 
     @bypass_arvados_authorization = true
-
-    save!
+    self.update_attributes(o.select { |k,v|
+                             [:service_host,
+                              :service_port,
+                              :service_ssl_flag,
+                              :bytes_total,
+                              :bytes_free,
+                              :is_readable,
+                              :is_writable,
+                              :last_read_at,
+                              :last_write_at
+                             ].collect(&:to_s).index k
+                           }.merge(last_ping_at: Time.now))
   end
 
   protected