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:
Nico Tonozzi
2014-07-31 09:31:30 -06:00
parent f818d482d7
commit 3a2335f37c
4 changed files with 18 additions and 4 deletions

View File

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

View File

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