[DRE-commits] [vagrant-libvirt] 56/163: add graphics password

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:57:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag 0.0.26
in repository vagrant-libvirt.

commit 94a2c675f72934e81ca0be5b14e0a10d886ed653
Author: dima <pronix.service at gmail.com>
Date:   Mon Sep 29 08:31:23 2014 +0200

    add graphics password
---
 README.md                                    |  3 +-
 lib/vagrant-libvirt/action/create_domain.rb  | 42 ++++++++++++++++------------
 lib/vagrant-libvirt/config.rb                | 10 ++++++-
 lib/vagrant-libvirt/plugin.rb                |  6 ++--
 lib/vagrant-libvirt/templates/domain.xml.erb | 10 ++++---
 5 files changed, 44 insertions(+), 27 deletions(-)

diff --git a/README.md b/README.md
index 861aa79..83c7fac 100644
--- a/README.md
+++ b/README.md
@@ -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.
 
diff --git a/lib/vagrant-libvirt/action/create_domain.rb b/lib/vagrant-libvirt/action/create_domain.rb
index 07ba268..123cb08 100644
--- a/lib/vagrant-libvirt/action/create_domain.rb
+++ b/lib/vagrant-libvirt/action/create_domain.rb
@@ -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)}")
diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb
index 2cf5b6d..df903f1 100644
--- a/lib/vagrant-libvirt/config.rb
+++ b/lib/vagrant-libvirt/config.rb
@@ -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
diff --git a/lib/vagrant-libvirt/plugin.rb b/lib/vagrant-libvirt/plugin.rb
index 20d1655..f125e30 100644
--- a/lib/vagrant-libvirt/plugin.rb
+++ b/lib/vagrant-libvirt/plugin.rb
@@ -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
 
diff --git a/lib/vagrant-libvirt/templates/domain.xml.erb b/lib/vagrant-libvirt/templates/domain.xml.erb
index 3afbbad..d5e0486 100644
--- a/lib/vagrant-libvirt/templates/domain.xml.erb
+++ b/lib/vagrant-libvirt/templates/domain.xml.erb
@@ -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>

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git



More information about the Pkg-ruby-extras-commits mailing list