From a64c9be71b0feb9dcd9204cfcee260c67a21e910 Mon Sep 17 00:00:00 2001 From: Brian McLaughlin Date: Fri, 10 Feb 2017 13:14:32 -0500 Subject: [PATCH] Disable VNC Console button for VMs on VC 6.5 or greater https://github.com/ManageIQ/manageiq/issues/13798 --- .../application_helper/toolbar_builder.rb | 4 ++++ .../toolbar_builder_spec.rb | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/helpers/application_helper/toolbar_builder.rb b/app/helpers/application_helper/toolbar_builder.rb index ef2e0665a0b..0ce1509feb1 100644 --- a/app/helpers/application_helper/toolbar_builder.rb +++ b/app/helpers/application_helper/toolbar_builder.rb @@ -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) diff --git a/spec/helpers/application_helper/toolbar_builder_spec.rb b/spec/helpers/application_helper/toolbar_builder_spec.rb index 8d13c61ab8f..ceec9ef5410 100644 --- a/spec/helpers/application_helper/toolbar_builder_spec.rb +++ b/spec/helpers/application_helper/toolbar_builder_spec.rb @@ -651,6 +651,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