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

[WIP] Convert console_supported? to supports? #21990

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 7 additions & 12 deletions app/models/vm/operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ module Vm::Operations
include_concern 'Lifecycle'

included do
supports :html5_console do
consup = %w[vnc webmks spice].any? { |type| send(:console_supported?, type) }
_("The web-based HTML5 Console is not supported") unless consup
end

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

supports :native_console do
_("VM NATIVE Console not supported") unless console_supported?('NATIVE')
end
supports_not :console
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw a comment about ovirt, but what exactly is this one? @agrare?

supports_not :html5_console
supports_not :native_console
supports_not :spice_console
supports_not :vmrc_console
supports_not :vnc_console
supports_not :webmks_console

supports :launch_html5_console do
_("The web-based HTML5 Console is not available because the VM is not powered on") unless power_state == 'on'
Expand Down
6 changes: 0 additions & 6 deletions app/models/vm_or_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1608,10 +1608,6 @@ def add_ems_event(event_type, event_message, event_timestamp)
EmsEvent.add(ems_id, event)
end

def console_supported?(_type)
false
end

# Stop certain charts from showing unless the subclass allows
def non_generic_charts_available?
false
Expand Down Expand Up @@ -1670,8 +1666,6 @@ def tenant_identity
user
end

supports(:console) { N_("Console not supported") unless console_supported?('spice') || console_supported?('vnc') }

def child_resources
children
end
Expand Down
43 changes: 0 additions & 43 deletions spec/models/vm/operations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,49 +53,6 @@
end
end

describe '#supports?(:vmrc_console)' do
it 'returns false if type is not supported' do
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_supported?).with('VMRC').and_return(true)

expect(@vm.supports?(:vmrc_console)).to be_truthy
end
end

describe '#supports?(:html5_console)' do
it 'supports it if all conditions are met' do
allow(@vm).to receive(:console_supported?).and_return(true)
expect(@vm.supports?(:html5_console)).to be_truthy
end

it 'returns false if type is not supported' do
allow(@vm).to receive(:console_supported?).and_return(false)
expect(@vm.supports?(:html5_console)).to be_falsey
expect(@vm.unsupported_reason(:html5_console)).to include('HTML5 Console is not supported')
end
end

describe '#supports?(:native_console)' do
it 'returns false if type is not supported' do
allow(@vm).to receive(:console_supported?).with('NATIVE').and_return(false)

expect(@vm.supports?(:native_console)).to be_falsey
expect(@vm.unsupported_reason(:native_console)).to include('NATIVE Console not supported')
end

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

expect(@vm.supports?(:native_console)).to be_truthy
end
end

describe '#supports?(:launch_vmrc_console)' do
it 'does not support it if validate_remote_console_vmrc_support raises an error' do
allow(@vm).to receive(:validate_remote_console_vmrc_support).and_raise(StandardError)
Expand Down