mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
Provide an option to randomize domain name
This commit lets users enable hostname randomization from their Vagrantfile. Without this option enabled, domain creation will fail when multiple VMs are spun up from the same Vagrantfile, due to a domain name conflict.
This commit is contained in:
@@ -5,6 +5,8 @@ class EnvironmentHelper
|
||||
|
||||
attr_writer :default_prefix, :domain_name
|
||||
|
||||
attr_accessor :random_hostname, :name
|
||||
|
||||
def [](value)
|
||||
self.send(value.to_sym)
|
||||
end
|
||||
|
||||
@@ -5,10 +5,16 @@ describe VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain do
|
||||
@env = EnvironmentHelper.new
|
||||
end
|
||||
|
||||
it "builds uniqie domain name" do
|
||||
it "builds unique domain name" do
|
||||
@env.random_hostname = true
|
||||
dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
|
||||
first = dmn.build_domain_name(@env)
|
||||
second = dmn.build_domain_name(@env)
|
||||
first.should_not eq(second)
|
||||
end
|
||||
|
||||
it "builds simple domain name" do
|
||||
dmn = VagrantPlugins::ProviderLibvirt::Action::SetNameOfDomain.new(Object.new, @env)
|
||||
dmn.build_domain_name(@env).should eq("foo_")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user