From 85acbf7ea22c5b1c91863fa3abc1903be1481caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Hal=C3=A1sz?= Date: Thu, 27 Jun 2019 11:34:40 +0200 Subject: [PATCH 1/2] Delete code related to the no longer supported MKS remote consoles https://bugzilla.redhat.com/show_bug.cgi?id=1532720 --- .../manageiq/providers/vmware/infra_manager.rb | 5 ----- .../vmware/infra_manager/vm/remote_console.rb | 11 +---------- .../vmware/infra_manager/vm/remote_console_spec.rb | 14 -------------- 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/app/models/manageiq/providers/vmware/infra_manager.rb b/app/models/manageiq/providers/vmware/infra_manager.rb index 98f722546..552f4d5d5 100644 --- a/app/models/manageiq/providers/vmware/infra_manager.rb +++ b/app/models/manageiq/providers/vmware/infra_manager.rb @@ -418,11 +418,6 @@ def vm_remove_disk_by_file(vm, options = {}) end alias vm_remove_disk vm_remove_disk_by_file - def vm_acquire_mks_ticket(vm, options = {}) - invoke_vim_ws(:acquireMksTicket, vm, options[:user_event]) - end - alias_method :vm_remote_console_mks_acquire_ticket, :vm_acquire_mks_ticket - def vm_acquire_ticket(vm, options = {}) invoke_vim_ws(:acquireTicket, vm, options[:user_event], options[:ticket_type]) end diff --git a/app/models/manageiq/providers/vmware/infra_manager/vm/remote_console.rb b/app/models/manageiq/providers/vmware/infra_manager/vm/remote_console.rb index e439cd16e..4f889cda7 100644 --- a/app/models/manageiq/providers/vmware/infra_manager/vm/remote_console.rb +++ b/app/models/manageiq/providers/vmware/infra_manager/vm/remote_console.rb @@ -2,7 +2,7 @@ module ManageIQ::Providers::Vmware::InfraManager::Vm::RemoteConsole require_dependency 'securerandom' def console_supported?(type) - %w(VMRC VNC MKS WEBMKS).include?(type.upcase) + %w(VMRC VNC WEBMKS).include?(type.upcase) end def validate_remote_console_acquire_ticket(protocol, options = {}) @@ -37,15 +37,6 @@ def remote_console_acquire_ticket_queue(protocol, userid) MiqTask.generic_action_with_callback(task_opts, queue_opts) end - # - # MKS - # - - def remote_console_mks_acquire_ticket(_userid = nil, _originating_server = nil) - validate_remote_console_acquire_ticket("mks", :check_if_running => false) - ext_management_system.vm_remote_console_mks_acquire_ticket(self) - end - # # VMRC # diff --git a/spec/models/manageiq/providers/vmware/infra_manager/vm/remote_console_spec.rb b/spec/models/manageiq/providers/vmware/infra_manager/vm/remote_console_spec.rb index 226c0db7e..5d971ad31 100644 --- a/spec/models/manageiq/providers/vmware/infra_manager/vm/remote_console_spec.rb +++ b/spec/models/manageiq/providers/vmware/infra_manager/vm/remote_console_spec.rb @@ -10,11 +10,6 @@ let(:vm) { FactoryBot.create(:vm_with_ref, :ext_management_system => ems) } context '#remote_console_acquire_ticket' do - it 'with :mks' do - expect(vm).to receive(:remote_console_mks_acquire_ticket).with(user.userid, 1) - vm.remote_console_acquire_ticket(user.userid, 1, :mks) - end - it 'with :webmks' do expect(vm).to receive(:remote_console_webmks_acquire_ticket).with(user.userid, 1) vm.remote_console_acquire_ticket(user.userid, 1, :webmks) @@ -41,15 +36,6 @@ allow(MiqServer).to receive_messages(:my_server => server) end - it 'with :mks' do - vm.remote_console_acquire_ticket_queue(:mks, user.userid) - - q_all = MiqQueue.all - expect(q_all.length).to eq(1) - expect(q_all[0].method_name).to eq('remote_console_acquire_ticket') - expect(q_all[0].args).to eq([user.userid, 1, :mks]) - end - it 'with :webmks' do vm.remote_console_acquire_ticket_queue(:webmks, user.userid) From f2c87c23117eb8d50d8ace52b11641630e12e693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Hal=C3=A1sz?= Date: Mon, 1 Jul 2019 13:38:39 +0200 Subject: [PATCH 2/2] Create a HTML5 console type on top of VNC and WebMKS https://bugzilla.redhat.com/show_bug.cgi?id=1532720 --- .../vmware/cloud_manager/vm/remote_console.rb | 5 +++ .../vmware/infra_manager/vm/remote_console.rb | 10 +++-- .../infra_manager/vm/remote_console_spec.rb | 42 +++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/app/models/manageiq/providers/vmware/cloud_manager/vm/remote_console.rb b/app/models/manageiq/providers/vmware/cloud_manager/vm/remote_console.rb index 0efd90617..909eff28c 100644 --- a/app/models/manageiq/providers/vmware/cloud_manager/vm/remote_console.rb +++ b/app/models/manageiq/providers/vmware/cloud_manager/vm/remote_console.rb @@ -65,6 +65,11 @@ def remote_console_webmks_acquire_ticket(userid, originating_server = nil) ) end + # + # HTML5 + # + alias_method :remote_console_html5_acquire_ticket, :remote_console_webmks_acquire_ticket + def validate_remote_console_webmks_support validate_remote_console_acquire_ticket('webmks') if (api_version = ext_management_system.api_version.to_f) && api_version < 5.5 diff --git a/app/models/manageiq/providers/vmware/infra_manager/vm/remote_console.rb b/app/models/manageiq/providers/vmware/infra_manager/vm/remote_console.rb index 4f889cda7..13046762a 100644 --- a/app/models/manageiq/providers/vmware/infra_manager/vm/remote_console.rb +++ b/app/models/manageiq/providers/vmware/infra_manager/vm/remote_console.rb @@ -81,12 +81,16 @@ def validate_remote_console_webmks_support end # - # VNC + # HTML5 selects the best available console type (VNC or WebMKS) # - def remote_console_html5_acquire_ticket(userid, originating_server) - remote_console_vnc_acquire_ticket(userid, originating_server) + def remote_console_html5_acquire_ticket(userid, originating_server = nil) + protocol = with_provider_object { |v| v.extraConfig["RemoteDisplay.vnc.enabled"] == "true" } ? 'vnc' : 'webmks' + send("remote_console_#{protocol}_acquire_ticket", userid, originating_server) end + # + # VNC + # def remote_console_vnc_acquire_ticket(userid, originating_server) validate_remote_console_acquire_ticket("vnc") diff --git a/spec/models/manageiq/providers/vmware/infra_manager/vm/remote_console_spec.rb b/spec/models/manageiq/providers/vmware/infra_manager/vm/remote_console_spec.rb index 5d971ad31..096f25674 100644 --- a/spec/models/manageiq/providers/vmware/infra_manager/vm/remote_console_spec.rb +++ b/spec/models/manageiq/providers/vmware/infra_manager/vm/remote_console_spec.rb @@ -24,6 +24,11 @@ expect(vm).to receive(:remote_console_vnc_acquire_ticket).with(user.userid, 1) vm.remote_console_acquire_ticket(user.userid, 1, :vnc) end + + it 'with :html5' do + expect(vm).to receive(:remote_console_html5_acquire_ticket).with(user.userid, 1) + vm.remote_console_acquire_ticket(user.userid, 1, :html5) + end end context '#remote_console_acquire_ticket_queue' do @@ -62,6 +67,43 @@ expect(q_all[0].method_name).to eq('remote_console_acquire_ticket') expect(q_all[0].args).to eq([user.userid, 1, :vnc]) end + + it 'with :html5' do + vm.remote_console_acquire_ticket_queue(:html5, user.userid) + + q_all = MiqQueue.all + expect(q_all.length).to eq(1) + expect(q_all[0].method_name).to eq('remote_console_acquire_ticket') + expect(q_all[0].args).to eq([user.userid, 1, :html5]) + end + end + + context '#remote_console_html5_acquire_ticket' do + before do + vim_vm = double('MiqVimVm') + allow(vm).to receive(:with_provider_object).and_yield(vim_vm) + allow(vim_vm).to receive(:extraConfig).and_return({ + "RemoteDisplay.vnc.enabled" => vnc.to_s + }) + end + + context 'with VNC' do + let(:vnc) { true } + + it 'calls remote_console_vnc_acquire_ticket' do + expect(vm).to receive(:remote_console_vnc_acquire_ticket) + vm.remote_console_html5_acquire_ticket(user.userid) + end + end + + context 'with WebMKS' do + let(:vnc) { false } + + it 'calls remote_console_webmks_acquire_ticket' do + expect(vm).to receive(:remote_console_webmks_acquire_ticket) + vm.remote_console_html5_acquire_ticket(user.userid) + end + end end context '#remote_console_webmks_acquire_ticket' do