allow setting the container name in the vagrantfile

This commit is contained in:
Cam Cope 2014-01-01 16:54:27 -05:00 committed by Fabio Rehm
parent 1083f100ad
commit ffb573a7f1
2 changed files with 12 additions and 3 deletions

View file

@ -7,9 +7,13 @@ module Vagrant
end
def call(env)
container_name = "#{env[:root_path].basename}_#{env[:machine].name}"
container_name.gsub!(/[^-a-z0-9_]/i, "")
container_name << "-#{Time.now.to_i}"
if env[:machine].provider_config.static_name
container_name = env[:machine].name.to_s
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(
container_name,

View file

@ -12,9 +12,13 @@ module Vagrant
# on /etc/sudoers
attr_accessor :sudo_wrapper
# A String that sets a static name
attr_accessor :static_name
def initialize
@customizations = []
@sudo_wrapper = UNSET_VALUE
@static_name = UNSET_VALUE
end
# Customize the container by calling `lxc-start` with the given
@ -34,6 +38,7 @@ module Vagrant
def finalize!
@sudo_wrapper = nil if @sudo_wrapper == UNSET_VALUE
@static_name = nil if @static_name == UNSET_VALUE
end
def validate(machine)