Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify the HTML5 canvas-based remote consoles under a single endpoint #18927

Merged
merged 3 commits into from
Jul 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions app/models/mixins/supports_feature_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,11 @@ module SupportsFeatureMixin
:discovery => 'Discovery of Managers for a Provider',
:evacuate => 'Evacuation',
:cockpit_console => 'Cockpit Console',
:vnc_console => 'VNC Console',
:mks_console => 'MKS Console',
:html5_console => 'HTML5 Console',
:vmrc_console => 'VMRC Console',
:spice_console => 'Spice Console',
:launch_cockpit => 'Launch Cockpit UI',
:launch_vnc_console => 'Launch VNC Console',
:launch_html5_console => 'Launch HTML5 Console',
:launch_vmrc_console => 'Launch VMRC Console',
:launch_mks_console => 'Launch WebMKS Console',
:launch_spice_console => 'Launch Spice Console',
:admin_ui => 'Open Admin UI for a Provider',
:live_migrate => 'Live Migration',
:migrate => 'Migration',
Expand Down
34 changes: 6 additions & 28 deletions app/models/vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,8 @@ def remote_console_url=(url, user_id)

def supported_consoles
{
:spice => spice_support,
:vnc => vnc_support,
:html5 => html5_support,
:vmrc => vmrc_support,
:webmks => webmks_support,
:cockpit => cockpit_support
}
end
Expand All @@ -125,47 +123,27 @@ def self.display_name(number = 1)

private

def vnc_support
def html5_support
{
:visible => supports_vnc_console?,
:enabled => supports_launch_vnc_console?,
:message => unsupported_reason(:launch_vnc_console)
}
end

def webmks_support
{
:visible => supports_mks_console?,
:enabled => supports_launch_mks_console?,
:message => unsupported_reason(:launch_mks_console)
:visible => supports_html5_console?,
:enabled => supports_launch_html5_console?,
:message => unsupported_reason(:launch_html5_console)
}
end

def vmrc_support
{
:visible => supports_vnc_console?,
:visible => supports_vmrc_console?,
:enabled => supports_launch_vmrc_console?,
:message => unsupported_reason(:launch_vmrc_console)
}
end

def spice_support
{
:visible => supports_spice_console?,
:enabled => supports_launch_spice_console?,
:message => unsupported_reason(:launch_spice_console)
}
end

def cockpit_support
{
:visible => supports_cockpit_console?,
:enabled => supports_launch_cockpit?,
:message => unsupported_reason(:launch_cockpit)
}
end

def console_supports_type?(console_type)
Settings.server.remote_console_type.upcase == console_type.upcase ? console_supported?(console_type) : false
end
end
47 changes: 6 additions & 41 deletions app/models/vm/operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,17 @@ module Vm::Operations
include_concern 'Lifecycle'

included do
supports :vnc_console do
message = "VNC Console not supported"
if vendor == 'vmware'
unsupported_reason_add(:vnc_console, message) unless ext_management_system.present? && console_supports_type?('VNC')
elsif !console_supported?('VNC')
unsupported_reason_add(:vnc_console, message)
end
end

supports :mks_console do
message = "WebMKS Console not supported"
if vendor != 'vmware'
unsupported_reason_add(:mks_console, message)
elsif console_supported?('WEBMKS') && !console_supports_type?('WebMKS')
unsupported_reason_add(:mks_console, message)
end
supports :html5_console do
consup = %w[vnc webmks spice].any? { |type| send(:console_supported?, type) }
unsupported_reason_add(:html5_console, _("The web-based HTML5 Console is not supported")) unless consup
end

supports :vmrc_console do
unsupported_reason_add(:vmrc_console, "VMRC Console not supported") unless console_supports_type?('VMRC')
unsupported_reason_add(:vmrc_console, _("VMRC Console not supported")) unless console_supported?('VMRC')
end

supports :spice_console do
unsupported_reason_add(:spice_console, "Spice Console not supported") unless console_supports_type?('SPICE')
end

supports :launch_vnc_console do
if vendor == 'vmware' && ext_management_system.try(:api_version).to_f >= 6.5
unsupported_reason_add(:launch_vnc_console, _('VNC consoles are unsupported on VMware ESXi 6.5 and later.'))
elsif power_state != 'on'
unsupported_reason_add(:launch_vnc_console, _('The web-based VNC console is not available because the VM is not powered on'))
end
supports :launch_html5_console do
unsupported_reason_add(:launch_html5_console, _("The web-based HTML5 Console is not available because the VM is not powered on")) unless power_state == 'on'
end

supports :launch_vmrc_console do
Expand All @@ -50,20 +29,6 @@ module Vm::Operations
unsupported_reason_add(:launch_vmrc_console, _('VM VMRC Console error: %{error}') % {:error => err})
end
end

supports :launch_mks_console do
if power_state != 'on'
unsupported_reason_add(:launch_mks_console, _('The web-based WebMKS console is not available because the VM is not powered on'))
elsif !Rails.root.join('public', 'webmks').exist?
unsupported_reason_add(:launch_mks_console, _("The web-based WebMKS console is not available because the required libraries aren't installed"))
end
end

supports :launch_spice_console do
if power_state != 'on'
unsupported_reason_add(:launch_spice_console, _('The web-based spice console is not available because the VM is not powered on'))
end
end
end

def cockpit_url
Expand Down
1 change: 0 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,6 @@
:prefetch_min_per_worker_dequeue: 10
:prefetch_stale_threshold: 30.seconds
:rails_server: puma
:remote_console_type: VMRC
:role: database_operations,event,reporting,scheduler,smartstate,ems_operations,ems_inventory,user_interface,remote_console,web_services,automate
:server_dequeue_frequency: 5.seconds
:server_log_frequency: 5.minutes
Expand Down
16 changes: 4 additions & 12 deletions db/fixtures/miq_product_features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5475,20 +5475,12 @@
:description: Restart the Guest OS on VMs
:feature_type: control
:identifier: vm_guest_restart
- :name: Console using MKS
- :name: Console using HTML5
:description: Open a web-based console for VMs
:feature_type: control
:identifier: vm_console
- :name: Console using WebMKS
:description: Open a web-based console for VMs
:feature_type: control
:identifier: vm_webmks_console
skateman marked this conversation as resolved.
Show resolved Hide resolved
- :name: Console using VNC
:description: Open a web-based VNC console for VMs
:feature_type: control
:identifier: vm_vnc_console
:identifier: vm_html5_console
kbrock marked this conversation as resolved.
Show resolved Hide resolved
- :name: Console using VMRC
:description: Open a web-based VMRC console for VMs
:description: Open a VMRC console for VMs
:feature_type: control
:identifier: vm_vmrc_console
- :name: Cockpit Console
Expand Down Expand Up @@ -6527,7 +6519,7 @@
- :name: Open Remote Console
:description: Open Remote Console
:feature_type: control
:identifier: sui_vm_console
:identifier: sui_vm_html5_console
- :name: Open Web Console
:description: Open Web Console
:feature_type: control
Expand Down
Loading