I added a new attribute to vms, vnc_port that needs to be filled in by taskomatic when starting/resuming VMs. If vnc_port (and host) are set for a VM, an 'open console' link appears in the VM details pane which brings up a (currently 800x600) popup window for the VM console (using the x-gtk-vnc plugin). For this to actually work, we need the following: 1) taskomatic changes to fill in vnc_port on start (and null it out when setting state to stopped, etc) 2) x-gtk-vnc firefox plugin needs to be installed on whatever box you're using to browse Signed-off-by: Scott Seago <sseago at redhat.com> --- wui/src/app/controllers/vm_controller.rb | 7 ++++++- wui/src/app/views/vm/show.rhtml | 10 ++++++++++ wui/src/db/migrate/006_create_vms.rb | 1 + wui/src/public/stylesheets/layout.css | 8 +++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/wui/src/app/controllers/vm_controller.rb b/wui/src/app/controllers/vm_controller.rb index 1179196..bda00b6 100644 --- a/wui/src/app/controllers/vm_controller.rb +++ b/wui/src/app/controllers/vm_controller.rb @@ -22,7 +22,7 @@ class VmController < ApplicationController verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => { :controller => 'dashboard' } - before_filter :pre_vm_action, :only => [:vm_action, :cancel_queued_tasks] + before_filter :pre_vm_action, :only => [:vm_action, :cancel_queued_tasks, :console] def show set_perms(@perm_obj) @@ -171,6 +171,11 @@ class VmController < ApplicationController end end + def console + @show_vnc_error = "Console is unavailable for VM #{@vm.description}" unless @vm.host and @vm.vnc_port + render :layout => false + end + protected def pre_new # if no vm_resource_pool is passed in, find (or auto-create) it based on hardware_pool_id diff --git a/wui/src/app/views/vm/show.rhtml b/wui/src/app/views/vm/show.rhtml index 457e11a..b2f338e 100644 --- a/wui/src/app/views/vm/show.rhtml +++ b/wui/src/app/views/vm/show.rhtml @@ -3,6 +3,16 @@ <%- end -%> <%- content_for :action_links do -%> + <%if @can_control_vms and @vm.host and @vm.vnc_port -%> + <%= link_to image_tag("icon_x.png") + " Open Console", + {:controller => 'vm', :action => 'console', :id => @vm}, + :id=>"vnc_console_link" %> + <script type="text/javascript"> + $('#vnc_console_link').bind('click', function(){ + window.open($(this).attr('href'),'child','toolbar=no,height=600,width=800, resizable=yes,status=no'); + return false;}) + </script> + <% end -%> <%if @can_modify -%> <%= link_to image_tag("icon_edit.png") + " Edit", {:controller => 'vm', :action => 'edit', :id => @vm}, diff --git a/wui/src/db/migrate/006_create_vms.rb b/wui/src/db/migrate/006_create_vms.rb index 7035a3c..74794b6 100644 --- a/wui/src/db/migrate/006_create_vms.rb +++ b/wui/src/db/migrate/006_create_vms.rb @@ -32,6 +32,7 @@ class CreateVms < ActiveRecord::Migration t.integer :vm_resource_pool_id t.integer :needs_restart t.string :boot_device, :null => false + t.integer :vnc_port t.integer :lock_version, :default => 0 end execute "alter table vms add constraint fk_vms_hosts diff --git a/wui/src/public/stylesheets/layout.css b/wui/src/public/stylesheets/layout.css index ab01b5f..52151eb 100644 --- a/wui/src/public/stylesheets/layout.css +++ b/wui/src/public/stylesheets/layout.css @@ -376,7 +376,13 @@ a { color:#000000; text-decoration: none;} } .dialog_body { - overflow: scroll; + overflow: auto; + height: 350px; +} + +.popup_body { + background: #FFFFFF; + overflow: auto; height: 350px; } -- 1.5.4.1