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

Create a HTML5 console type on top of VNC and WebMKS #409

Merged
merged 2 commits into from
Jul 2, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions app/models/manageiq/providers/vmware/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {})
Expand Down Expand Up @@ -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
#
Expand Down Expand Up @@ -90,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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -29,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
Expand All @@ -41,15 +41,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)

Expand All @@ -76,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
Expand Down