Skip to content

Commit

Permalink
Drop the global vmware remote console type setting
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Jul 1, 2019
1 parent 3c01363 commit 32ea2e9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
4 changes: 0 additions & 4 deletions app/models/vm.rb
Expand Up @@ -164,8 +164,4 @@ def cockpit_support
: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
6 changes: 3 additions & 3 deletions app/models/vm/operations.rb
Expand Up @@ -12,7 +12,7 @@ module Vm::Operations
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')
unsupported_reason_add(:vnc_console, message) unless ext_management_system.present? && console_supported?('VNC')
elsif !console_supported?('VNC')
unsupported_reason_add(:vnc_console, message)
end
Expand All @@ -22,13 +22,13 @@ module Vm::Operations
message = "WebMKS Console not supported"
if vendor != 'vmware'
unsupported_reason_add(:mks_console, message)
elsif console_supported?('WEBMKS') && !console_supports_type?('WebMKS')
elsif console_supported?('WEBMKS') && !console_supported?('WebMKS')
unsupported_reason_add(:mks_console, message)
end
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
Expand Down
1 change: 0 additions & 1 deletion config/settings.yml
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
13 changes: 6 additions & 7 deletions spec/models/vm/operations_spec.rb
Expand Up @@ -63,7 +63,7 @@
context '#supports_vnc_console?' do
it 'does not support it for vmware vms if it is not the specified console type in settings' do
allow(@vm).to receive(:vendor).and_return('vmware')
allow(@vm).to receive(:console_supports_type?).with('VNC').and_return(false)
allow(@vm).to receive(:console_supported?).with('VNC').and_return(false)

expect(@vm.supports_vnc_console?).to be_falsey
expect(@vm.unsupported_reason(:vnc_console)).to include('VNC Console not supported')
Expand All @@ -80,7 +80,6 @@
it 'supports it if all conditions are met' do
server = double
allow(Settings).to receive(:server).and_return(server)
allow(server).to receive(:remote_console_type).and_return('VNC')

expect(@vm.supports_vnc_console?).to be_truthy
end
Expand All @@ -96,7 +95,7 @@

it 'supports it if all conditions are met' do
allow(@vm).to receive(:console_supported?).with('WEBMKS').and_return(true)
allow(@vm).to receive(:console_supports_type?).with('WebMKS').and_return(true)
allow(@vm).to receive(:console_supported?).with('WebMKS').and_return(true)

expect(@vm.supports_mks_console?).to be_truthy
end
Expand Down Expand Up @@ -173,29 +172,29 @@

context '#supports_vmrc_console?' do
it 'returns false if type is not supported' do
allow(@vm).to receive(:console_supports_type?).with('VMRC').and_return(false)
allow(@vm).to receive(:console_supported?).with('VMRC').and_return(false)

expect(@vm.supports_vmrc_console?).to be_falsey
expect(@vm.unsupported_reason(:vmrc_console)).to include('VMRC Console not supported')
end

it 'supports it if all conditions are met' do
allow(@vm).to receive(:console_supports_type?).with('VMRC').and_return(true)
allow(@vm).to receive(:console_supported?).with('VMRC').and_return(true)

expect(@vm.supports_vmrc_console?).to be_truthy
end
end

context '#supports_spice_console?' do
it 'returns false if type is not supported' do
allow(@vm).to receive(:console_supports_type?).with('SPICE').and_return(false)
allow(@vm).to receive(:console_supported?).with('SPICE').and_return(false)

expect(@vm.supports_spice_console?).to be_falsey
expect(@vm.unsupported_reason(:spice_console)).to include('Spice Console not supported')
end

it 'supports it if all conditions are met' do
allow(@vm).to receive(:console_supports_type?).with('SPICE').and_return(true)
allow(@vm).to receive(:console_supported?).with('SPICE').and_return(true)

expect(@vm.supports_spice_console?).to be_truthy
end
Expand Down

0 comments on commit 32ea2e9

Please sign in to comment.