--- /dev/null
+# 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/
--- /dev/null
+// Place all the styles related to the KeepDisks controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
--- /dev/null
+class Arvados::V1::KeepDisksController < ApplicationController
+ skip_before_filter :login_required, :only => :ping
+
+ def ping
+ @object.ping({ ip: params[:local_ipv4] || request.env['REMOTE_ADDR'],
+ ping_secret: params[:ping_secret],
+ ec2_instance_id: params[:instance_id] })
+ show
+ end
+end
--- /dev/null
+module KeepDisksHelper
+end
--- /dev/null
+class KeepDisk < ArvadosModel
+ include AssignUuid
+ include KindAndEtag
+ include CommonApiTemplate
+ before_validation :ensure_ping_secret
+
+ api_accessible :superuser, :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
+ t.add :is_writable
+ t.add :last_read_at
+ t.add :last_write_at
+ t.add :last_ping_at
+ end
+
+ def ping(o)
+ raise "must have :ip and :ping_secret" unless o[:ip] and o[:ping_secret]
+
+ if o[:ping_secret] != self.ping_secret
+ logger.info "Ping: secret mismatch: received \"#{o[:ping_secret]}\" != \"#{self.info[:ping_secret]}\""
+ return nil
+ end
+ self.last_ping_at = Time.now
+
+ @bypass_arvados_authorization = true
+
+ save!
+ end
+
+ protected
+
+ def ensure_ping_secret
+ self.ping_secret ||= rand(2**256).to_s(36)
+ end
+
+ def permission_to_update
+ @bypass_arvados_authorization or super
+ end
+
+ def permission_to_create
+ current_user and current_user.is_admin
+ end
+end
Server::Application.routes.draw do
+ resources :keep_disks
resources :commit_ancestors
-
resources :commits
-
resources :job_tasks
resources :jobs
resources :api_client_authorizations
resources :users
resources :jobs
resources :job_tasks
+ resources :keep_disks
end
end
--- /dev/null
+class CreateKeepDisks < ActiveRecord::Migration
+ def change
+ create_table :keep_disks do |t|
+ t.string :uuid, :null => false
+ t.string :owner, :null => false
+ t.string :modified_by_client
+ t.string :modified_by_user
+ t.datetime :modified_at
+ t.string :ping_secret, :null => false
+ t.string :node_uuid
+ t.string :filesystem_uuid
+ t.integer :bytes_total
+ t.integer :bytes_free
+ t.boolean :is_readable, :null => false, :default => true
+ t.boolean :is_writable, :null => false, :default => true
+ t.datetime :last_read_at
+ t.datetime :last_write_at
+ t.datetime :last_ping_at
+
+ t.timestamps
+ end
+ add_index :keep_disks, :uuid, :unique => true
+ add_index :keep_disks, :filesystem_uuid
+ add_index :keep_disks, :node_uuid
+ add_index :keep_disks, :last_ping_at
+ end
+end
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130415020241) do
+ActiveRecord::Schema.define(:version => 20130425024459) do
create_table "api_client_authorizations", :force => true do |t|
t.string "api_token", :null => false
add_index "jobs", ["submit_id"], :name => "index_jobs_on_submit_id", :unique => true
add_index "jobs", ["uuid"], :name => "index_jobs_on_uuid", :unique => true
+ create_table "keep_disks", :force => true do |t|
+ t.string "uuid", :null => false
+ t.string "owner", :null => false
+ t.string "modified_by_client"
+ t.string "modified_by_user"
+ t.datetime "modified_at"
+ t.string "ping_secret", :null => false
+ t.string "node_uuid"
+ t.string "filesystem_uuid"
+ t.integer "bytes_total"
+ t.integer "bytes_free"
+ t.boolean "is_readable", :default => true, :null => false
+ t.boolean "is_writable", :default => true, :null => false
+ t.datetime "last_read_at"
+ t.datetime "last_write_at"
+ t.datetime "last_ping_at"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "keep_disks", ["filesystem_uuid"], :name => "index_keep_disks_on_filesystem_uuid"
+ add_index "keep_disks", ["last_ping_at"], :name => "index_keep_disks_on_last_ping_at"
+ add_index "keep_disks", ["node_uuid"], :name => "index_keep_disks_on_node_uuid"
+ add_index "keep_disks", ["uuid"], :name => "index_keep_disks_on_uuid", :unique => true
+
create_table "links", :force => true do |t|
t.string "uuid"
t.string "owner"
--- /dev/null
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
--- /dev/null
+require 'test_helper'
+
+class KeepDisksControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
--- /dev/null
+require 'test_helper'
+
+class KeepDisksHelperTest < ActionView::TestCase
+end
--- /dev/null
+require 'test_helper'
+
+class KeepDiskTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end