Merge branch '15496-wb1-group-membership-admin'
[arvados.git] / apps / workbench / app / controllers / virtual_machines_controller.rb
index 73231f8cc09023ef13006fa6ad3e910d8881e874..764571c4c5b635352439fa7d0e09f2d2431e39e9 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 class VirtualMachinesController < ApplicationController
   def index
     @objects ||= model_class.all
@@ -21,11 +25,14 @@ class VirtualMachinesController < ApplicationController
   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,
-    }
+    return render_not_found if Rails.configuration.Workbench.ShellInABoxURL == URI("")
+    webshell_url = URI(Rails.configuration.Workbench.ShellInABoxURL)
+    if webshell_url.host.index("*") != nil
+      webshell_url.host = webshell_url.host.sub("*", @object.hostname)
+    else
+      webshell_url.path = "/#{@object.hostname}"
+    end
+    @webshell_url = webshell_url.to_s
     render layout: false
   end