end
end
- # webshell action is used to login to an arvados shell using workbench
- # https://code.google.com/p/shellinabox/source/browse/#git%2Fshellinabox
- expose_action :webshell do
- shell_in_a_box_url_config = Rails.configuration.shell_in_a_box_url
-
- return render_not_found if not shell_in_a_box_url_config
-
- return unprocessable "Missing parameters" if not params['login'] or not params['hostname']
-
- @webshell_login = params['login']
- @webshell_hostname = params['hostname'].chomp('.shell')
-
- if not shell_in_a_box_url_config.end_with?('/')
- shell_in_a_box_url_config += '/'
- end
- @webshell_url = shell_in_a_box_url_config + @webshell_hostname
-
- respond_to do |format|
- render partial: 'virtual_machines/webshell'
- return
- end
- end
-
protected
def derive_unique_filename filename, manifest_files
end
super
end
+
+ def webshell
+ return render_not_found if not Rails.configuration.shell_in_a_box_url
+ @webshell_url = Rails.configuration.shell_in_a_box_url % {
+ uuid: @object.uuid,
+ hostname: @object.hostname,
+ }
+ render layout: false
+ end
+
end
<th> Host name </th>
<th> Login name </th>
<th> Command line </th>
+ <% if Rails.configuration.shell_in_a_box_url %>
+ <th> Web shell <span class="label label-info">beta</span></th>
+ <% end %>
</tr>
</thead>
<tbody>
<% end %>
<% end %>
</td>
- <td>
- <% if Rails.configuration.shell_in_a_box_url %>
- <% if @my_vm_logins[vm[:uuid]] %>
- <% @my_vm_logins[vm[:uuid]].each do |login| %>
- <%= link_to 'Login', webshell_path(login: login, hostname: vm[:hostname]) %>
+ <% if Rails.configuration.shell_in_a_box_url %>
+ <td>
+ <% @my_vm_logins[vm[:uuid]].andand.each do |login| %>
+ <%= link_to webshell_virtual_machine_path(vm, login: login), title: "Open a terminal session in your browser", class: 'btn btn-xs btn-default' do %>
+ Log in as <%= login %><br />
<% end %>
<% end %>
- <% end %>
- </td>
+ </td>
+ <% end %>
</tr>
<% end %>
</tbody>
<html>
- <title>Shell login into <%= @webshell_hostname %> </title>
- <link rel="stylesheet" href="/webshell_styles.css" type="text/css">
+ <title><%= @object.hostname %> / <%= Rails.configuration.site_name %></title>
+ <link rel="stylesheet" href="<%= asset_path 'webshell/styles.css' %>" type="text/css">
<style type="text/css">
body {
margin: 0px;
})();
function login(username, token) {
- var sh = new ShellInABox("<%= @webshell_url %>");
+ var sh = new ShellInABox("<%= j @webshell_url %>");
setTimeout(function() {
- sh.keysPressed("<%= @webshell_login %>\n");
+ sh.keysPressed("<%= j params[:login] %>\n");
setTimeout(function() {
- sh.keysPressed("<%= Thread.current[:arvados_api_token] %>\n");
+ sh.keysPressed("<%= j Thread.current[:arvados_api_token] %>\n");
}, 1000);
}, 1000);
}
- -->
+ // -->
</script>
- <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
- <script type="text/javascript" src="/shell_in_a_box.js"></script>
+ <link rel="icon" href="<%= asset_path 'favicon.ico' %>" type="image/x-icon">
+ <script type="text/javascript" src="<%= asset_path 'webshell/shell_in_a_box.js' %>"></script>
</head>
<!-- Load ShellInABox from a timer as Konqueror sometimes fails to
correctly deal with the enclosing frameset (if any), if we do not
do this
-->
-<body onload="setTimeout('login()', 1000)"
+<body onload="setTimeout(login, 1000)"
scroll="no"><noscript>JavaScript must be enabled for ShellInABox</noscript>
</body>
</html>
# Ask Arvados API server to compress its response payloads.
api_response_compression: true
- # ShellInABox URL
+ # ShellInABox service endpoint URL for a given VM. If false, do not
+ # offer web shell logins.
+ #
+ # E.g., using a path-based proxy server to forward connections to shell hosts:
+ # https://webshell.uuid_prefix.arvadosapi.com/%{hostname}
+ #
+ # E.g., using a name-based proxy server to forward connections to shell hosts:
+ # https://%{hostname}.webshell.uuid_prefix.arvadosapi.com/
shell_in_a_box_url: false
resources :traits
resources :api_client_authorizations
resources :virtual_machines
+ get '/virtual_machines/:id/webshell/:login' => 'virtual_machines#webshell', :as => :webshell_virtual_machine
resources :authorized_keys
resources :job_tasks
resources :jobs do
get 'actions' => 'actions#show'
get 'websockets' => 'websocket#index'
post "combine_selected" => 'actions#combine_selected_files_into_collection'
- get "webshell" => 'actions#webshell'
root :to => 'projects#index'
--- /dev/null
+See also
+* VirtualMachinesController#webshell
+* https://code.google.com/p/shellinabox/source/browse/#git%2Fshellinabox