class VirtualMachinesController < ApplicationController
+ def index
+ @objects ||= model_class.all
+ @vm_logins = {}
+ if @objects.andand.first
+ Link.where(tail_uuid: current_user.uuid,
+ head_uuid: @objects.collect(&:uuid),
+ link_class: 'permission',
+ name: 'can_login').
+ each do |perm_link|
+ if perm_link.properties.andand[:username]
+ @vm_logins[perm_link.head_uuid] ||= []
+ @vm_logins[perm_link.head_uuid] << perm_link.properties[:username]
+ end
+ end
+ @objects.each do |vm|
+ vm.current_user_logins = @vm_logins[vm.uuid].andand.compact || []
+ end
+ end
+ super
+ end
end
return attrvalue if !object.attribute_editable? attr
input_type = 'text'
- case object.class.attribute_info[attr.to_sym][:type]
+ case object.class.attribute_info[attr.to_sym].andand[:type]
when 'text'
input_type = 'textarea'
when 'datetime'
input_type = 'text'
end
- attrvalue = attrvalue.to_json if attrvalue.is_a? Hash
+ attrvalue = attrvalue.to_json if attrvalue.is_a? Hash or attrvalue.is_a? Array
link_to attrvalue.to_s, '#', {
"data-emptytext" => "none",
class VirtualMachine < ArvadosBase
+ attr_accessor :current_user_logins
def self.creatable?
current_user.andand.is_admin
end
+ def attributes_for_display
+ logger.debug super.append ['current_user_logins', @current_user_logins]
+ super.append ['current_user_logins', @current_user_logins]
+ end
+ def attribute_editable?(attr)
+ attr != 'current_user_logins' and super
+ end
+ def self.attribute_info
+ merger = ->(k,a,b) { a.merge(b, &merger) }
+ merger [nil,
+ {current_user_logins: {column_heading: "logins", type: 'array'}},
+ super]
+ end
end
--- /dev/null
+<% if @objects.empty? %>
+
+<p>
+ No <%= controller.model_class.to_s.underscore.pluralize.gsub '_', ' ' %> to display.
+</p>
+
+<% else %>
+
+<% attr_blacklist = 'created_at modified_at modified_by_user modified_by_client updated_at' %>
+
+<table class="table arv-index">
+ <thead>
+ <tr>
+ <% @objects.first.attributes_for_display.each do |attr, attrvalue| %>
+ <% next if attr_blacklist.index attr %>
+ <th class="arv-attr-<%= attr %>">
+ <%= controller.model_class.attribute_info[attr.to_sym].andand[:column_heading] or attr.sub /_uuid/, '' %>
+ </th>
+ <% end %>
+ </tr>
+ </thead>
+
+ <tbody>
+ <% @objects.each do |object| %>
+ <tr>
+ <% object.attributes_for_display.each do |attr, attrvalue| %>
+ <% next if attr_blacklist.index attr %>
+ <td class="arv-object-<%= object.class.to_s %> arv-attr-<%= attr %>">
+ <% if attr == 'uuid' %>
+ <%= link_to_if_arvados_object object %>
+ <% elsif object.attribute_editable? attr %>
+ <%= render_editable_attribute object, attr %>
+ <% else %>
+ <%= link_to_if_arvados_object attrvalue, {referring_attr: attr, referring_object: @object, with_class_name: true} %>
+ <% end %>
+ </td>
+ <% end %>
+ </tr>
+ <% end %>
+ </tbody>
+
+ <tfoot>
+ </tfoot>
+</table>
+
+<% end %>
+
+<% if controller.model_class.creatable? %>
+<%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", { action: 'create', return_to: './' }, { class: 'btn btn-primary' } %>
+<% end %>
-<% if @objects.empty? %>
-
-<p>
- No <%= controller.model_class.to_s.underscore.pluralize.gsub '_', ' ' %> to display.
-</p>
-
-<% else %>
-
-<% attr_blacklist = 'created_at modified_at modified_by_user modified_by_client updated_at' %>
-
-<table class="table arv-index">
- <thead>
- <tr>
- <% @objects.first.attributes_for_display.each do |attr, attrvalue| %>
- <% next if attr_blacklist.index attr %>
- <th class="arv-attr-<%= attr %>">
- <%= attr.sub /_uuid/, '' %>
- </th>
- <% end %>
- </tr>
- </thead>
-
- <tbody>
- <% @objects.each do |object| %>
- <tr>
- <% object.attributes_for_display.each do |attr, attrvalue| %>
- <% next if attr_blacklist.index attr %>
- <td class="arv-object-<%= object.class.to_s %> arv-attr-<%= attr %>">
- <% if attr == 'uuid' %>
- <%= link_to_if_arvados_object object %>
- <% elsif object.attribute_editable? attr %>
- <%= render_editable_attribute object, attr %>
- <% else %>
- <%= link_to_if_arvados_object attrvalue, {referring_attr: attr, referring_object: @object, with_class_name: true} %>
- <% end %>
- </td>
- <% end %>
- </tr>
- <% end %>
- </tbody>
-
- <tfoot>
- </tfoot>
-</table>
-
-<% end %>
-
-<% if controller.model_class.creatable? %>
-<%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", { action: 'create', return_to: './' }, { class: 'btn btn-primary' } %>
-<% end %>
+<%= render partial: 'index' %>
--- /dev/null
+<%= render partial: 'application/index' %>
+
+<p>
+Sample <code>~/.ssh/config</code> section:
+</p>
+
+<pre>
+Host *.arvados
+ ProxyCommand ssh -p2222 turnout@switchyard.<%= Rails.configuration.arvados_v1_base.match(/\/\/(.*?)\//).andand[1] || 'xyzzy.arvadosapi.com' %> -x -a $SSH_PROXY_FLAGS %h
+<% if @objects.first.current_user_logins.andand.first %>
+ User <%= @objects.first.current_user_logins.andand.first %>
+<% end %>
+</pre>
+
+<p>
+Sample login command:
+</p>
+
+<pre>
+ssh <%= @objects.first.andand.hostname.sub(/\..*/,'') or 'vm-hostname' %>.arvados
+</pre>
+
+<p>
+ See also:
+ <%= link_to raw('Arvados Docs → User Guide → SSH access'), 'http://doc.arvados.org/user/ssh-access.html' %>.
+</p>
+++ /dev/null
-<%= render :partial => 'application/arvados_object' %>