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

Fix supports_launch_vnc_console? for VMWare VMs #16905

Merged
merged 1 commit into from
Jan 29, 2018
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
2 changes: 1 addition & 1 deletion app/models/vm/operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module Vm::Operations
end

supports :launch_vnc_console do
if vendor == 'vmware' && ext_management_system.api_version.to_f >= 6.5
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'))
Expand Down
8 changes: 8 additions & 0 deletions spec/models/vm/operations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@
allow(@vm).to receive(:ext_management_system).and_return(@ems_double)
end

it 'returns the correct error message if the vm vendor is vmware and it does not have an ext_management_system' do
allow(@vm).to receive(:ext_management_system).and_return(nil)
allow(@vm).to receive(:power_state).and_return('off')

expect(@vm.supports_launch_vnc_console?).to be_falsey
expect(@vm.unsupported_reason(:launch_vnc_console)).to include('the VM is not powered on')
end

it 'does not support if vendor is vmware and api version is >= 6.5' do
allow(@ems_double).to receive(:api_version).and_return('6.5')
allow(@vm).to receive(:vendor).and_return('vmware')
Expand Down