diff --git a/app/models/vm/operations.rb b/app/models/vm/operations.rb index 0b6ad1aa29ff..c3029cdd2d7c 100644 --- a/app/models/vm/operations.rb +++ b/app/models/vm/operations.rb @@ -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 diff --git a/app/models/vm_or_template.rb b/app/models/vm_or_template.rb index 35c75df21362..c6e042760065 100644 --- a/app/models/vm_or_template.rb +++ b/app/models/vm_or_template.rb @@ -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 diff --git a/spec/models/vm/operations_spec.rb b/spec/models/vm/operations_spec.rb index cc9e9561ce91..94a3879d7b14 100644 --- a/spec/models/vm/operations_spec.rb +++ b/spec/models/vm/operations_spec.rb @@ -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)