mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
feat: add websocket graphics config (#1672)
This adds websocket functionality for VNC. The websocket attribute may be used to specify the port to listen on (with -1 meaning auto-allocation and autoport having no effect due to security reasons).
This commit is contained in:
@@ -20,7 +20,7 @@ class EnvironmentHelper
|
||||
1024
|
||||
end
|
||||
|
||||
%w(cpus cpu_mode loader nvram boot_order machine_type disk_bus disk_device nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms floppies driver).each do |name|
|
||||
%w(cpus cpu_mode loader nvram boot_order machine_type disk_bus disk_device nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_websocket graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms floppies driver).each do |name|
|
||||
define_method(name.to_sym) do
|
||||
nil
|
||||
end
|
||||
|
||||
@@ -66,13 +66,15 @@ describe VagrantPlugins::ProviderLibvirt::Action::CreateDomain do
|
||||
let(:vagrantfile_providerconfig) do
|
||||
<<-EOF
|
||||
libvirt.graphics_port = 5900
|
||||
libvirt.graphics_websocket = 5700
|
||||
EOF
|
||||
end
|
||||
|
||||
it 'should emit the graphics port' do
|
||||
it 'should emit the graphics port and websocket' do
|
||||
expect(servers).to receive(:create).and_return(machine)
|
||||
expect(volumes).to_not receive(:create) # additional disks only
|
||||
expect(ui).to receive(:info).with(' -- Graphics Port: 5900')
|
||||
expect(ui).to receive(:info).with(' -- Graphics Websocket: 5700')
|
||||
|
||||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -344,7 +344,7 @@ describe VagrantPlugins::ProviderLibvirt::Action::StartDomain do
|
||||
expect(libvirt_domain).to receive(:xml_desc).and_return(domain_xml, launched_domain_xml)
|
||||
expect(libvirt_domain).to receive(:autostart=)
|
||||
expect(domain).to receive(:start)
|
||||
expect(ui).to receive(:info).with(' -- Graphics Port: 5900')
|
||||
expect(ui).to receive(:info).with(' -- Graphics Port: 5900')
|
||||
|
||||
expect(subject.call(env)).to be_nil
|
||||
end
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<input bus='ps2' type='mouse'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'/>
|
||||
<video>
|
||||
<model heads='1' type='cirrus' vram='16384'/>
|
||||
</video>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<input bus='ps2' type='mouse'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'/>
|
||||
<video>
|
||||
<model heads='1' type='cirrus' vram='16384'/>
|
||||
</video>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<input bus='ps2' type='mouse'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'/>
|
||||
<video>
|
||||
<model heads='1' type='cirrus' vram='16384'/>
|
||||
</video>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<input bus='ps2' type='mouse'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'/>
|
||||
<video>
|
||||
<model heads='1' type='cirrus' vram='16384'/>
|
||||
</video>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<input bus='ps2' type='mouse'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'/>
|
||||
<video>
|
||||
<model heads='1' type='cirrus' vram='16384'/>
|
||||
</video>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<input bus='ps2' type='mouse'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'/>
|
||||
<video>
|
||||
<model heads='1' type='cirrus' vram='16384'/>
|
||||
</video>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
<target port='0'/>
|
||||
</console>
|
||||
<input bus='ps2' type='mouse'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'/>
|
||||
<video>
|
||||
<model heads='1' type='cirrus' vram='16384'/>
|
||||
</video>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'/>
|
||||
<input type='keyboard' bus='ps2'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us' websocket='-1'>
|
||||
<listen type='address' address='127.0.0.1'/>
|
||||
</graphics>
|
||||
<audio id='1' type='none'/>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</console>
|
||||
<input bus='ps2' type='mouse'/>
|
||||
<input bus='ps2' type='keyboard'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'>
|
||||
<listen address='127.0.0.1' type='address'/>
|
||||
</graphics>
|
||||
<audio id='1' type='none'/>
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</console>
|
||||
<input bus='ps2' type='mouse'/>
|
||||
<input bus='ps2' type='keyboard'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket="-1">
|
||||
<listen address='127.0.0.1' type='address'/>
|
||||
</graphics>
|
||||
<audio id='1' type='none'/>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
</console>
|
||||
<input bus='ps2' type='mouse'/>
|
||||
<input bus='ps2' type='keyboard'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'>
|
||||
<listen address='127.0.0.1' type='address'/>
|
||||
</graphics>
|
||||
<audio id='1' type='none'/>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
</console>
|
||||
<input bus='ps2' type='mouse'/>
|
||||
<input bus='ps2' type='keyboard'/>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc'>
|
||||
<graphics autoport='yes' keymap='en-us' listen='127.0.0.1' port='-1' type='vnc' websocket='-1'>
|
||||
<listen address='127.0.0.1' type='address'/>
|
||||
</graphics>
|
||||
<audio id='1' type='none'/>
|
||||
|
||||
@@ -660,6 +660,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
||||
|
||||
expect(subject.graphics_type).to eq('vnc')
|
||||
expect(subject.graphics_port).to eq(-1)
|
||||
expect(subject.graphics_websocket).to eq(-1)
|
||||
expect(subject.graphics_ip).to eq('127.0.0.1')
|
||||
expect(subject.graphics_autoport).to eq('yes')
|
||||
expect(subject.channels).to be_empty
|
||||
@@ -670,6 +671,7 @@ describe VagrantPlugins::ProviderLibvirt::Config do
|
||||
subject.finalize!
|
||||
|
||||
expect(subject.graphics_port).to eq(nil)
|
||||
expect(subject.graphics_websocket).to eq(nil)
|
||||
expect(subject.graphics_ip).to eq(nil)
|
||||
expect(subject.graphics_autoport).to eq(nil)
|
||||
expect(subject.channels).to match([a_hash_including({:target_name => 'com.redhat.spice.0'})])
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
</channel>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'>
|
||||
<gl enable='yes'/>
|
||||
</graphics>
|
||||
<video>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -124,7 +124,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</console>
|
||||
<input type='mouse' bus='ps2'>
|
||||
</input>
|
||||
<graphics type='vnc' port='-1' autoport='yes' listen='127.0.0.1' keymap='en-us'/>
|
||||
<graphics type='vnc' port='-1' autoport='yes' websocket='-1' listen='127.0.0.1' keymap='en-us'/>
|
||||
<video>
|
||||
<model type='cirrus' vram='16384' heads='1'/>
|
||||
</video>
|
||||
|
||||
Reference in New Issue
Block a user