add /nodes status page
[arvados.git] / app / models / node.rb
index 026865e9575cff26b229ff8c5cfcc5917774b7fd..8d15472fbe4e419b42018ac70507b015709706a2 100644 (file)
@@ -19,6 +19,20 @@ class Node < ActiveRecord::Base
     super
   end
 
+  def status
+    if !self.last_ping_at
+      if Time.now - self.created_at > 5.minutes
+        'startup-fail'
+      else
+        'pending'
+      end
+    elsif Time.now - self.last_ping_at > 1.hours
+      'missing'
+    else
+      'alive'
+    end
+  end
+
   def ping(o)
     raise "must have :ip and :ping_secret" unless o[:ip] and o[:ping_secret]