allow setting the container name in the vagrantfile
This commit is contained in:
parent
1083f100ad
commit
ffb573a7f1
2 changed files with 12 additions and 3 deletions
|
@ -7,9 +7,13 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
container_name = "#{env[:root_path].basename}_#{env[:machine].name}"
|
if env[:machine].provider_config.static_name
|
||||||
container_name.gsub!(/[^-a-z0-9_]/i, "")
|
container_name = env[:machine].name.to_s
|
||||||
container_name << "-#{Time.now.to_i}"
|
else
|
||||||
|
container_name = "#{env[:root_path].basename}_#{env[:machine].name}"
|
||||||
|
container_name.gsub!(/[^-a-z0-9_]/i, "")
|
||||||
|
container_name << "-#{Time.now.to_i}"
|
||||||
|
end
|
||||||
|
|
||||||
env[:machine].provider.driver.create(
|
env[:machine].provider.driver.create(
|
||||||
container_name,
|
container_name,
|
||||||
|
|
|
@ -12,9 +12,13 @@ module Vagrant
|
||||||
# on /etc/sudoers
|
# on /etc/sudoers
|
||||||
attr_accessor :sudo_wrapper
|
attr_accessor :sudo_wrapper
|
||||||
|
|
||||||
|
# A String that sets a static name
|
||||||
|
attr_accessor :static_name
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@customizations = []
|
@customizations = []
|
||||||
@sudo_wrapper = UNSET_VALUE
|
@sudo_wrapper = UNSET_VALUE
|
||||||
|
@static_name = UNSET_VALUE
|
||||||
end
|
end
|
||||||
|
|
||||||
# Customize the container by calling `lxc-start` with the given
|
# Customize the container by calling `lxc-start` with the given
|
||||||
|
@ -34,6 +38,7 @@ module Vagrant
|
||||||
|
|
||||||
def finalize!
|
def finalize!
|
||||||
@sudo_wrapper = nil if @sudo_wrapper == UNSET_VALUE
|
@sudo_wrapper = nil if @sudo_wrapper == UNSET_VALUE
|
||||||
|
@static_name = nil if @static_name == UNSET_VALUE
|
||||||
end
|
end
|
||||||
|
|
||||||
def validate(machine)
|
def validate(machine)
|
||||||
|
|
Loading…
Reference in a new issue