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:
@@ -66,6 +66,7 @@ module VagrantPlugins
|
||||
@graphics_type = config.graphics_type
|
||||
@graphics_autoport = config.graphics_autoport
|
||||
@graphics_port = config.graphics_port
|
||||
@graphics_websocket = config.graphics_websocket
|
||||
@graphics_ip = config.graphics_ip
|
||||
@graphics_passwd = config.graphics_passwd
|
||||
@graphics_gl = config.graphics_gl
|
||||
@@ -271,6 +272,7 @@ module VagrantPlugins
|
||||
end
|
||||
|
||||
env[:ui].info(" -- Graphics Type: #{@graphics_type}")
|
||||
env[:ui].info(" -- Graphics Websocket: #{@graphics_websocket}") if @graphics_websocket != -1
|
||||
if !@graphics_autoport
|
||||
env[:ui].info(" -- Graphics Port: #{@graphics_port}")
|
||||
env[:ui].info(" -- Graphics IP: #{@graphics_ip}")
|
||||
|
||||
@@ -280,6 +280,10 @@ module VagrantPlugins
|
||||
graphics.attributes['port'] = config.graphics_port
|
||||
end
|
||||
end
|
||||
if graphics.attributes['websocket'] != config.graphics_websocket.to_s
|
||||
descr_changed = true
|
||||
graphics.attributes['websocket'] = config.graphics_websocket
|
||||
end
|
||||
if graphics.attributes['keymap'] != config.keymap
|
||||
descr_changed = true
|
||||
graphics.attributes['keymap'] = config.keymap
|
||||
@@ -544,14 +548,21 @@ module VagrantPlugins
|
||||
raise Errors::DomainStartError, error_message: e.message
|
||||
end
|
||||
|
||||
if config.graphics_autoport
|
||||
#libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
|
||||
xmldoc = REXML::Document.new(libvirt_domain.xml_desc)
|
||||
graphics = REXML::XPath.first(xmldoc, '/domain/devices/graphics')
|
||||
env[:ui].info(I18n.t('vagrant_libvirt.starting_domain_with_graphics'))
|
||||
env[:ui].info(" -- Graphics Port: #{graphics.attributes['port']}")
|
||||
env[:ui].info(" -- Graphics IP: #{graphics.attributes['listen']}")
|
||||
env[:ui].info(" -- Graphics Password: #{config.graphics_passwd.nil? ? 'Not defined' : 'Defined'}")
|
||||
#libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
|
||||
xmldoc = REXML::Document.new(libvirt_domain.xml_desc)
|
||||
graphics = REXML::XPath.first(xmldoc, '/domain/devices/graphics')
|
||||
|
||||
if !graphics.nil?
|
||||
if config.graphics_autoport
|
||||
env[:ui].info(I18n.t('vagrant_libvirt.starting_domain_with_graphics'))
|
||||
env[:ui].info(" -- Graphics Port: #{graphics.attributes['port']}")
|
||||
env[:ui].info(" -- Graphics IP: #{graphics.attributes['listen']}")
|
||||
env[:ui].info(" -- Graphics Password: #{config.graphics_passwd.nil? ? 'Not defined' : 'Defined'}")
|
||||
end
|
||||
|
||||
if config.graphics_websocket == -1
|
||||
env[:ui].info(" -- Graphics Websocket: #{graphics.attributes['websocket']}")
|
||||
end
|
||||
end
|
||||
|
||||
@app.call(env)
|
||||
|
||||
@@ -121,6 +121,7 @@ module VagrantPlugins
|
||||
attr_accessor :graphics_type
|
||||
attr_accessor :graphics_autoport
|
||||
attr_accessor :graphics_port
|
||||
attr_accessor :graphics_websocket
|
||||
attr_accessor :graphics_passwd
|
||||
attr_accessor :graphics_ip
|
||||
attr_accessor :graphics_gl
|
||||
@@ -296,6 +297,7 @@ module VagrantPlugins
|
||||
@graphics_type = UNSET_VALUE
|
||||
@graphics_autoport = UNSET_VALUE
|
||||
@graphics_port = UNSET_VALUE
|
||||
@graphics_websocket = UNSET_VALUE
|
||||
@graphics_ip = UNSET_VALUE
|
||||
@graphics_passwd = UNSET_VALUE
|
||||
@graphics_gl = UNSET_VALUE
|
||||
@@ -1025,6 +1027,7 @@ module VagrantPlugins
|
||||
@graphics_passwd = nil
|
||||
end
|
||||
@graphics_port = @graphics_type == 'spice' ? nil : -1 if @graphics_port == UNSET_VALUE
|
||||
@graphics_websocket = @graphics_type == 'spice' ? nil : -1 if @graphics_websocket == UNSET_VALUE
|
||||
@graphics_ip = @graphics_type == 'spice' ? nil : '127.0.0.1' if @graphics_ip == UNSET_VALUE
|
||||
@video_accel3d = false if @video_accel3d == UNSET_VALUE
|
||||
@graphics_gl = @video_accel3d if @graphics_gl == UNSET_VALUE
|
||||
|
||||
@@ -259,6 +259,7 @@
|
||||
'type' => @graphics_type,
|
||||
'port' => @graphics_port,
|
||||
'autoport' => @graphics_autoport,
|
||||
'websocket' => @graphics_websocket,
|
||||
'listen' => @graphics_ip,
|
||||
'keymap' => @keymap,
|
||||
'passwd' => @graphics_passwd,
|
||||
|
||||
Reference in New Issue
Block a user