Skip to content

Commit

Permalink
drop supports_console and instead use supports
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrock committed Jun 28, 2022
1 parent 2fccacb commit b74d988
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
22 changes: 14 additions & 8 deletions app/models/vm/operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ module Vm::Operations
include_concern 'Lifecycle'

included do
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
# TODO: convert to supports_not :spice_console
supports(:spice_console) { unsupported_reason_add(:spice_console, N_("Console not supported")) unless console_supported?('spice') }
supports(:vnc_console) { unsupported_reason_add(:vnc_console, N_("Console not supported")) unless console_supported?('vnc') }
supports(:native_console) { unsupported_reason_add(:native_console, _("VM NATIVE Console not supported")) unless console_supported?('NATIVE') }
supports(:vmrc_console) { unsupported_reason_add(:vmrc_console, _("VMRC Console not supported")) unless console_supported?('VMRC') }
supports(:webmks_console) { unsupported_reason_add(:webmks_console, N_("Console not supported")) unless console_supported?('webmks') }

supports :vmrc_console do
unsupported_reason_add(:vmrc_console, _("VMRC Console not supported")) unless console_supported?('VMRC')
supports :console do
unless supports?(:spice_console) || supports?(:vnc_console)
unsupported_reason_add(:console, N_("Console not supported"))
end
end

supports :native_console do
unsupported_reason_add(:native_console, _("VM NATIVE Console not supported")) unless console_supported?('NATIVE')
supports :html5_console do
unless %w[vnc_console webmks_console spice_console].any? { |type| supports?(type) }
unsupported_reason_add(:html5_console, _("The web-based HTML5 Console is not supported"))
end
end

supports :launch_html5_console do
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 @@ -1675,12 +1675,6 @@ def tenant_identity
user
end

supports :console do
unless console_supported?('spice') || console_supported?('vnc')
unsupported_reason_add(:console, N_("Console not supported"))
end
end

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

# TODO going away from console_supported
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)
Expand Down

0 comments on commit b74d988

Please sign in to comment.