Skip to content

Commit

Permalink
Create a HTML5 console type on top of VNC and WebMKS
Browse files Browse the repository at this point in the history
  • Loading branch information
skateman committed Jul 2, 2019
1 parent 85acbf7 commit 2ef93ae
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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 @@ -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
Expand Down Expand Up @@ -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
})
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

0 comments on commit 2ef93ae

Please sign in to comment.