[DRE-commits] [vagrant-libvirt] 50/67: Add provider specific default_prefix option.

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


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

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

commit 0ac7498f4d73d4100462ac34b5cd89c308622fc5
Author: James Shubin <james at shubin.ca>
Date:   Sat Jan 11 22:31:53 2014 -0500

    Add provider specific default_prefix option.
    
    This patch adds support for a provider specific default_prefix option.
    When set, this value is used instead of the project's dir name as the
    prefix for the machines being created.
---
 README.md                                        | 1 +
 example_box/Vagrantfile                          | 3 +++
 lib/vagrant-libvirt/action/set_name_of_domain.rb | 7 ++++++-
 lib/vagrant-libvirt/config.rb                    | 5 +++++
 4 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index b8dfdd1..2dd154e 100644
--- a/README.md
+++ b/README.md
@@ -100,6 +100,7 @@ This provider exposes quite a few provider-specific configuration options:
 * `id_ssh_key_file` - The id ssh key file name to access Libvirt (eg: id_dsa or id_rsa or ... in the user .ssh directory)
 * `storage_pool_name` - Libvirt storage pool name, where box image and instance snapshots will be stored.
 * `default_network` - Libvirt default network name. If not specified default network name is 'default'.
+* `default_prefix` - Set a prefix for the machines that's different than the project dir name.
 
 ### Domain Specific Options
 
diff --git a/example_box/Vagrantfile b/example_box/Vagrantfile
index 4cbb796..f3026ad 100644
--- a/example_box/Vagrantfile
+++ b/example_box/Vagrantfile
@@ -52,6 +52,9 @@ Vagrant.configure("2") do |config|
     # Libvirt storage pool name, where box image and instance snapshots will
     # be stored.
     libvirt.storage_pool_name = "default"
+
+    # Set a prefix for the machines that's different than the project dir name.
+    #libvirt.default_prefix = ''
   end
 end
 
diff --git a/lib/vagrant-libvirt/action/set_name_of_domain.rb b/lib/vagrant-libvirt/action/set_name_of_domain.rb
index a778e9f..a42e1eb 100644
--- a/lib/vagrant-libvirt/action/set_name_of_domain.rb
+++ b/lib/vagrant-libvirt/action/set_name_of_domain.rb
@@ -11,7 +11,12 @@ module VagrantPlugins
 
         def call(env)
           require 'securerandom'
-          env[:domain_name] = env[:root_path].basename.to_s.dup
+          config = env[:machine].provider_config
+          if config.default_prefix.nil?
+            env[:domain_name] = env[:root_path].basename.to_s.dup
+          else
+            env[:domain_name] = config.default_prefix.to_s
+          end
           env[:domain_name].gsub!(/[^-a-z0-9_]/i, '')
           env[:domain_name] << '_'
           env[:domain_name] << env[:machine].name.to_s
diff --git a/lib/vagrant-libvirt/config.rb b/lib/vagrant-libvirt/config.rb
index bd5bbc2..9eeb4c7 100644
--- a/lib/vagrant-libvirt/config.rb
+++ b/lib/vagrant-libvirt/config.rb
@@ -28,6 +28,9 @@ module VagrantPlugins
       # Libvirt default network
       attr_accessor :default_network
 
+      # Default host prefix (alternative to use project folder name)
+      attr_accessor :default_prefix
+
       # Domain specific settings used while creating new domain.
       attr_accessor :memory
       attr_accessor :cpus
@@ -45,6 +48,7 @@ module VagrantPlugins
         @id_ssh_key_file   = UNSET_VALUE
         @storage_pool_name = UNSET_VALUE
         @default_network   = UNSET_VALUE
+        @default_prefix    = UNSET_VALUE
 
         # Domain specific settings.
         @memory            = UNSET_VALUE
@@ -64,6 +68,7 @@ module VagrantPlugins
         @id_ssh_key_file = 'id_rsa' if @id_ssh_key_file == UNSET_VALUE
         @storage_pool_name = 'default' if @storage_pool_name == UNSET_VALUE
         @default_network = 'default' if @default_network == UNSET_VALUE
+        @default_prefix = nil if @default_prefix == UNSET_VALUE
 
         # Domain specific settings.
         @memory = 512 if @memory == UNSET_VALUE

-- 
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