add graphics password

This commit is contained in:
dima 2014-09-29 08:31:23 +02:00
parent fea98293c2
commit 94a2c675f7
5 changed files with 44 additions and 27 deletions

View File

@ -152,8 +152,9 @@ end
* `random_hostname` - To create a domain name with extra information on the end to prevent hostname conflicts.
* `cmd_line` - Arguments passed on to the guest kernel initramfs or initrd to use. Equivalent to qemu `-append`.
* `graphics_type` - Sets the protocol used to expose the guest display. Defaults to `vnc`. Possible values are "sdl", "curses", "none", "gtk", or "vnc".
* `graphics_port` - Sets the port for the display protocol to bind to. Defaults to 5900.
* `graphics_port` - Sets the port for the display protocol to bind to. Defaults to 5900.
* `graphics_ip` - Sets the IP for the display protocol to bind to. Defaults to "127.0.0.0.1".
* `graphics_passwd` - Sets the password for the display protocol. Working for vnc and spice. by default working without passsword.
* `video_type` - Sets the graphics card type exposed to the guest. Defaults to "cirrus". Possible values are "cirrus", "std", "vmware", "qxl", "tcx", "cg3", or "none".
* `video_vram` - Used by some graphics card types to vary the amount of RAM dedicated to video. Defaults to 9216.

View File

@ -8,7 +8,7 @@ module VagrantPlugins
include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
def initialize(app, env)
@logger = Log4r::Logger.new("vagrant_libvirt::action::create_domain")
@logger = Log4r::Logger.new('vagrant_libvirt::action::create_domain')
@app = app
end
@ -39,6 +39,11 @@ module VagrantPlugins
@graphics_autoport = config.graphics_autoport
@graphics_port = config.graphics_port
@graphics_ip = config.graphics_ip
@graphics_passwd = if config.graphics_passwd.to_s.empty?
''
else
"passwd='#{config.graphics_passwd.to_s}'"
end
@video_type = config.video_type
@video_vram = config.video_vram
@ -54,7 +59,7 @@ module VagrantPlugins
# Get path to domain image.
domain_volume = ProviderLibvirt::Util::Collection.find_matching(
env[:libvirt_compute].volumes.all, "#{@name}.img")
raise Errors::DomainVolumeExists if domain_volume == nil
raise Errors::DomainVolumeExists if domain_volume.nil?
@domain_volume_path = domain_volume.path
# the default storage prefix is typically: /var/lib/libvirt/images/
@ -84,22 +89,23 @@ module VagrantPlugins
end
# Output the settings we're going to use to the user
env[:ui].info(I18n.t("vagrant_libvirt.creating_domain"))
env[:ui].info(" -- Name: #{@name}")
env[:ui].info(" -- Domain type: #{@domain_type}")
env[:ui].info(" -- Cpus: #{@cpus}")
env[:ui].info(" -- Memory: #{@memory_size/1024}M")
env[:ui].info(" -- Base box: #{env[:machine].box.name}")
env[:ui].info(" -- Storage pool: #{@storage_pool_name}")
env[:ui].info(" -- Image: #{@domain_volume_path}")
env[:ui].info(" -- Volume Cache: #{@domain_volume_cache}")
env[:ui].info(" -- Kernel: #{@kernel}")
env[:ui].info(" -- Initrd: #{@initrd}")
env[:ui].info(" -- Graphics Type: #{@graphics_type}")
env[:ui].info(" -- Graphics Port: #{@graphics_port}")
env[:ui].info(" -- Graphics IP: #{@graphics_ip}")
env[:ui].info(" -- Video Type: #{@video_type}")
env[:ui].info(" -- Video VRAM: #{@video_vram}")
env[:ui].info(I18n.t('vagrant_libvirt.creating_domain'))
env[:ui].info(" -- Name: #{@name}")
env[:ui].info(" -- Domain type: #{@domain_type}")
env[:ui].info(" -- Cpus: #{@cpus}")
env[:ui].info(" -- Memory: #{@memory_size/1024}M")
env[:ui].info(" -- Base box: #{env[:machine].box.name}")
env[:ui].info(" -- Storage pool: #{@storage_pool_name}")
env[:ui].info(" -- Image: #{@domain_volume_path}")
env[:ui].info(" -- Volume Cache: #{@domain_volume_cache}")
env[:ui].info(" -- Kernel: #{@kernel}")
env[:ui].info(" -- Initrd: #{@initrd}")
env[:ui].info(" -- Graphics Type: #{@graphics_type}")
env[:ui].info(" -- Graphics Port: #{@graphics_port}")
env[:ui].info(" -- Graphics IP: #{@graphics_ip}")
env[:ui].info(" -- Graphics Password: #{@graphics_passwd.empty? ? 'Not defined': 'Defined'}")
env[:ui].info(" -- Video Type: #{@video_type}")
env[:ui].info(" -- Video VRAM: #{@video_vram}")
if @disks.length > 0
env[:ui].info(" -- Disks: #{_disks_print(@disks)}")

View File

@ -23,7 +23,7 @@ module VagrantPlugins
attr_accessor :host
# If use ssh tunnel to connect to Libvirt.
attr_accessor :connect_via_ssh
attr_accessor :connect_via_ssh
# Path towards the libvirt socket
attr_accessor :socket
@ -65,6 +65,7 @@ module VagrantPlugins
attr_accessor :graphics_type
attr_accessor :graphics_autoport
attr_accessor :graphics_port
attr_accessor :graphics_passwd
attr_accessor :graphics_ip
attr_accessor :video_type
attr_accessor :video_vram
@ -101,6 +102,7 @@ module VagrantPlugins
@graphics_autoport = UNSET_VALUE
@graphics_port = UNSET_VALUE
@graphics_ip = UNSET_VALUE
@graphics_passwd = UNSET_VALUE
@video_type = UNSET_VALUE
@video_vram = UNSET_VALUE
@ -132,6 +134,8 @@ module VagrantPlugins
}.merge(options)
#puts "storage(#{storage_type} --- #{options.to_s})"
require 'pry'
binding.pry
@disks = [] if @disks == UNSET_VALUE
disk = {
@ -224,6 +228,10 @@ module VagrantPlugins
@graphics_type = 'vnc' if @graphics_type == UNSET_VALUE
@graphics_autoport = 'yes' if @graphics_port == UNSET_VALUE
@graphics_autoport = 'no' if @graphics_port != UNSET_VALUE
if (@graphics_type != 'vnc' && @graphics_port != 'spice') ||
@graphics_passwd == UNSET_VALUE
@graphics_passwd = nil
end
@graphics_port = 5900 if @graphics_port == UNSET_VALUE
@graphics_ip = '127.0.0.1' if @graphics_ip == UNSET_VALUE
@video_type = 'cirrus' if @video_type == UNSET_VALUE

View File

@ -31,9 +31,9 @@ module VagrantPlugins
require_relative 'provider'
Provider
end
guest_capability("linux", "mount_p9_shared_folder") do
require_relative "cap/mount_p9"
guest_capability('linux', 'mount_p9_shared_folder') do
require_relative 'cap/mount_p9'
Cap::MountP9
end

View File

@ -51,9 +51,11 @@
<target port='0'/>
</console>
<input type='mouse' bus='ps2'/>
<graphics type='<%= @graphics_type %>' port='<%= @graphics_port %>' autoport='<%= @graphics_autoport %>' listen='<%= @graphics_ip %>' keymap='en-us'/>
<video>
<model type='<%= @video_type %>' vram='<%= @video_vram %>' heads='1'/>
</video>
<%# Video device -%>
<graphics type='<%= @graphics_type %>' port='<%= @graphics_port %>' autoport='<%= @graphics_autoport %>' listen='<%= @graphics_ip %>' keymap='en-us' <%= @graphics_passwd%> />
<video>
<model type='<%= @video_type %>' vram='<%= @video_vram %>' heads='1'/>
</video>
<%#End Video -%>
</devices>
</domain>