Skip to content

Commit

Permalink
Merge pull request #355 from bmclaughlin/disable-vnc-button-for-vc65
Browse files Browse the repository at this point in the history
Disable VNC Console for VMs hosted on ESXi 6.5 or greater
  • Loading branch information
mzazrivec authored Feb 14, 2017
2 parents 92d2a99 + a64c9be commit f6021af
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/helpers/application_helper/toolbar_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ def disable_button(id)
return true if @gtl_type && id.starts_with?("view_") && id.ends_with?(@gtl_type) # GTL view buttons
return true if id == "view_dashboard" && (@showtype == "dashboard")
return true if id == "view_summary" && (@showtype != "dashboard")
if id == 'vm_vnc_console' && @record.vendor == 'vmware' &&
ExtManagementSystem.find_by(:id => @record.ems_id).api_version.to_f >= 6.5
return N_("VNC consoles are unsupported on VMware ESXi 6.5 and later.")
end

# need to add this here, since this button is on list view screen
if disable_new_iso_datastore?(id)
Expand Down
21 changes: 21 additions & 0 deletions spec/helpers/application_helper/toolbar_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,27 @@ def setup_firefox_with_linux
expect(subject).to include('cannot be performed on selected')
end
end

context "and id = vm_vnc_console" do
before :each do
@id = 'vm_vnc_console'
@record = FactoryGirl.create(:vm_vmware)
end

it "should not be available for vmware hosts with an api version greater or equal to 6.5" do
@ems = FactoryGirl.create(:ems_vmware, :api_version => '6.5')
allow(@record).to receive(:ems_id).and_return(@ems.id)
expect(subject).to include('VNC consoles are unsupported on VMware ESXi 6.5 and later.')
end

%w(5.1 5.5 6.0).each do |version|
it "should be available for vmware hosts with an api version #{version}" do
@ems = FactoryGirl.create(:ems_vmware, :api_version => version)
allow(@record).to receive(:ems_id).and_return(@ems.id)
expect(subject).to be(false)
end
end
end
end # end of Vm class

end # end of disable button
Expand Down

0 comments on commit f6021af

Please sign in to comment.