[ARVADOS] updated: eb4fb5479e86795128e71ebd1bb478b50ff6d7c9

git at public.curoverse.com git at public.curoverse.com
Thu Jul 9 16:40:14 EDT 2015


Summary of changes:
 .../app/controllers/actions_controller.rb          | 23 ----------------------
 .../app/controllers/virtual_machines_controller.rb | 10 ++++++++++
 .../views/users/_manage_virtual_machines.html.erb  | 17 +++++++++-------
 .../{_webshell.html.erb => webshell.html.erb}      | 18 ++++++++---------
 apps/workbench/config/application.default.yml      |  9 ++++++++-
 apps/workbench/config/routes.rb                    |  2 +-
 apps/workbench/public/webshell/README              |  3 +++
 .../public/{ => webshell}/shell_in_a_box.js        |  0
 .../{webshell_styles.css => webshell/styles.css}   |  0
 9 files changed, 41 insertions(+), 41 deletions(-)
 rename apps/workbench/app/views/virtual_machines/{_webshell.html.erb => webshell.html.erb} (69%)
 create mode 100644 apps/workbench/public/webshell/README
 rename apps/workbench/public/{ => webshell}/shell_in_a_box.js (100%)
 rename apps/workbench/public/{webshell_styles.css => webshell/styles.css} (100%)

       via  eb4fb5479e86795128e71ebd1bb478b50ff6d7c9 (commit)
      from  f19af5689832a7b28a60f433cea850ca06841230 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit eb4fb5479e86795128e71ebd1bb478b50ff6d7c9
Author: Tom Clegg <tom at curoverse.com>
Date:   Thu Jul 9 16:38:16 2015 -0400

    6279: Move webshell action into VirtualMachinesController, tweak formatting & config.
    
    * Document config var
    
    * Accept formatting references like %{hostname} and %{uuid} in config
      var instead of always appending "/#{hostname}"
    
    * Fix favicon, js, and stylesheet paths (use asset_path helper); move
      js and css into public/webshell/
    
    * Use j() quoting helper in js.erb

diff --git a/apps/workbench/app/controllers/actions_controller.rb b/apps/workbench/app/controllers/actions_controller.rb
index 22f3a09..cbe7e37 100644
--- a/apps/workbench/app/controllers/actions_controller.rb
+++ b/apps/workbench/app/controllers/actions_controller.rb
@@ -228,29 +228,6 @@ You can try recreating the collection to get a copy with full provenance data."
     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
diff --git a/apps/workbench/app/controllers/virtual_machines_controller.rb b/apps/workbench/app/controllers/virtual_machines_controller.rb
index a62ba81..73231f8 100644
--- a/apps/workbench/app/controllers/virtual_machines_controller.rb
+++ b/apps/workbench/app/controllers/virtual_machines_controller.rb
@@ -19,4 +19,14 @@ class VirtualMachinesController < ApplicationController
     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
diff --git a/apps/workbench/app/views/users/_manage_virtual_machines.html.erb b/apps/workbench/app/views/users/_manage_virtual_machines.html.erb
index 75e7d15..2257df9 100644
--- a/apps/workbench/app/views/users/_manage_virtual_machines.html.erb
+++ b/apps/workbench/app/views/users/_manage_virtual_machines.html.erb
@@ -66,6 +66,9 @@
           <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>
@@ -84,15 +87,15 @@
                 <% 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>
diff --git a/apps/workbench/app/views/virtual_machines/_webshell.html.erb b/apps/workbench/app/views/virtual_machines/webshell.html.erb
similarity index 69%
rename from apps/workbench/app/views/virtual_machines/_webshell.html.erb
rename to apps/workbench/app/views/virtual_machines/webshell.html.erb
index 46cd03d..360606e 100644
--- a/apps/workbench/app/views/virtual_machines/_webshell.html.erb
+++ b/apps/workbench/app/views/virtual_machines/webshell.html.erb
@@ -1,6 +1,6 @@
 <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;
@@ -25,24 +25,24 @@
       })();
 
       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>
diff --git a/apps/workbench/config/application.default.yml b/apps/workbench/config/application.default.yml
index 155b9d1..744c0c3 100644
--- a/apps/workbench/config/application.default.yml
+++ b/apps/workbench/config/application.default.yml
@@ -215,5 +215,12 @@ common:
   # 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
diff --git a/apps/workbench/config/routes.rb b/apps/workbench/config/routes.rb
index 7c40d0e..f72278a 100644
--- a/apps/workbench/config/routes.rb
+++ b/apps/workbench/config/routes.rb
@@ -17,6 +17,7 @@ ArvadosWorkbench::Application.routes.draw do
   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
@@ -93,7 +94,6 @@ ArvadosWorkbench::Application.routes.draw 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'
 
diff --git a/apps/workbench/public/webshell/README b/apps/workbench/public/webshell/README
new file mode 100644
index 0000000..b8920c5
--- /dev/null
+++ b/apps/workbench/public/webshell/README
@@ -0,0 +1,3 @@
+See also
+* VirtualMachinesController#webshell
+* https://code.google.com/p/shellinabox/source/browse/#git%2Fshellinabox
diff --git a/apps/workbench/public/shell_in_a_box.js b/apps/workbench/public/webshell/shell_in_a_box.js
similarity index 100%
rename from apps/workbench/public/shell_in_a_box.js
rename to apps/workbench/public/webshell/shell_in_a_box.js
diff --git a/apps/workbench/public/webshell_styles.css b/apps/workbench/public/webshell/styles.css
similarity index 100%
rename from apps/workbench/public/webshell_styles.css
rename to apps/workbench/public/webshell/styles.css

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list