add /nodes status page
authorTom Clegg <tom@clinicalfuture.com>
Fri, 11 Jan 2013 18:27:04 +0000 (10:27 -0800)
committerTom Clegg <tom@clinicalfuture.com>
Fri, 11 Jan 2013 18:27:04 +0000 (10:27 -0800)
app/assets/javascripts/nodes.js.coffee [new file with mode: 0644]
app/assets/stylesheets/application.css
app/assets/stylesheets/nodes.css
app/assets/stylesheets/nodes.css.scss [new file with mode: 0644]
app/controllers/nodes_controller.rb [new file with mode: 0644]
app/models/node.rb
app/views/nodes/index.html.erb [new file with mode: 0644]
config/routes.rb

diff --git a/app/assets/javascripts/nodes.js.coffee b/app/assets/javascripts/nodes.js.coffee
new file mode 100644 (file)
index 0000000..7615679
--- /dev/null
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
index fc25b5723fa8a20542577549b357721d68c61990..8d93556acf0137d7bd5e04dfc29e8f78feba8395 100644 (file)
@@ -4,4 +4,8 @@
  * the top of the compiled file, but it's generally better to create a new file per style scope.
  *= require_self
  *= require_tree . 
-*/
\ No newline at end of file
+*/
+
+.contain-align-left {
+    text-align: left;
+}
index afad32db02d37ceee7791f6bb1af74351a46cdcd..ba901922f108cc540393a89c2f1e4ee009efd337 100644 (file)
@@ -2,3 +2,16 @@
   Place all the styles related to the matching controller here.
   They will automatically be included in application.css.
 */
+.node-status {
+    /* unknown status - might be bad */
+    background: #ff8888;
+}
+.node-status-running {
+    background: #88ff88;
+}
+.node-status-missing {
+    background: #ff8888;
+}
+.node-status-terminated {
+    background: #ffffff;
+}
diff --git a/app/assets/stylesheets/nodes.css.scss b/app/assets/stylesheets/nodes.css.scss
new file mode 100644 (file)
index 0000000..7210602
--- /dev/null
@@ -0,0 +1,3 @@
+// Place all the styles related to the Nodes controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb
new file mode 100644 (file)
index 0000000..5dce1b1
--- /dev/null
@@ -0,0 +1,5 @@
+class NodesController < ApplicationController
+  def index
+    @objects = model_class.order("created_at desc")
+  end
+end
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]
 
diff --git a/app/views/nodes/index.html.erb b/app/views/nodes/index.html.erb
new file mode 100644 (file)
index 0000000..6f49e92
--- /dev/null
@@ -0,0 +1,57 @@
+<table>
+  <tr class="contain-align-left">
+    <th>
+      status
+    </th><th>
+      uuid
+    </th><th>
+      hostname
+    </th><th>
+      domain
+    </th><th>
+      ip address
+    </th><th>
+      created
+    </th><th>
+      startup delay
+    </th><th>
+      last ping
+    </th>
+  </tr>
+
+  <% @objects.each do |o| %>
+
+  <tr class="node-status node-status-<%= o.status %>">
+    <td>
+      <%= o.status %>
+    </td><td>
+      <%= o.uuid %>
+    </td><td>
+      <%= o.hostname %>
+    </td><td>
+      <%= o.domain %>
+    </td><td>
+      <%= o.ip_address %>
+    </td><td>
+      <%= o.created_at %>
+    </td><td>
+      <%= distance_of_time_in_words(o.first_ping_at, o.created_at, true) if o.first_ping_at %>
+    </td><td>
+      <%= distance_of_time_in_words(o.last_ping_at, Time.now, true) + ' ago' if o.last_ping_at %>
+    </td><td>
+      <%= o.info[:ec2_instance_id] %>
+    </td>
+  </tr>
+
+  <% if o.info[:ec2_start_command] and (!o.first_ping_at or !o.info[:ec2_start_result].match /\bi-[0-9a-f]{8}\b/ rescue nil) %>
+  <tr>
+    <td colspan="8">
+      <%= o.info[:ec2_start_command] %>
+      <br />
+      <%= o.info[:ec2_start_result] %>
+    </td>
+  </tr>
+
+  <% end %>
+  <% end %>
+</table>
index d71b74db145fc71e0938fe032eb8433685096a8e..7e1dbe90c3fd63685f9bb12b9da271f3276fbde6 100644 (file)
@@ -1,4 +1,10 @@
 Server::Application.routes.draw do
+  resources :collections
+  resources :metadata
+  resources :nodes
+  resources :pipelines
+  resources :pipeline_invocations
+
   # The priority is based upon order of creation:
   # first created -> highest priority.