Remove environment "vm_name" property since it was redundant
This commit is contained in:
parent
1be3f972ae
commit
ed48170b24
|
@ -11,7 +11,6 @@ module Vagrant
|
||||||
DEFAULT_VM = :default
|
DEFAULT_VM = :default
|
||||||
|
|
||||||
attr_reader :parent # Parent environment (in the case of multi-VMs)
|
attr_reader :parent # Parent environment (in the case of multi-VMs)
|
||||||
attr_reader :vm_name # The name of the VM (internal name) which this environment represents
|
|
||||||
|
|
||||||
attr_reader :cwd
|
attr_reader :cwd
|
||||||
attr_reader :box
|
attr_reader :box
|
||||||
|
@ -35,7 +34,6 @@ module Vagrant
|
||||||
def initialize(opts=nil)
|
def initialize(opts=nil)
|
||||||
opts = {
|
opts = {
|
||||||
:parent => nil,
|
:parent => nil,
|
||||||
:vm_name => nil,
|
|
||||||
:vm => nil,
|
:vm => nil,
|
||||||
:cwd => nil,
|
:cwd => nil,
|
||||||
}.merge(opts || {})
|
}.merge(opts || {})
|
||||||
|
@ -78,7 +76,7 @@ module Vagrant
|
||||||
# The resource is the VM name if there is a VM it represents, otherwise
|
# The resource is the VM name if there is a VM it represents, otherwise
|
||||||
# it defaults to "vagrant"
|
# it defaults to "vagrant"
|
||||||
def resource
|
def resource
|
||||||
vm_name || "vagrant"
|
vm.name rescue "vagrant"
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the VMs associated with this environment.
|
# Returns the VMs associated with this environment.
|
||||||
|
@ -158,14 +156,6 @@ module Vagrant
|
||||||
@local_data ||= DataStore.new(dotfile_path)
|
@local_data ||= DataStore.new(dotfile_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
# The configuration object represented by this environment. This
|
|
||||||
# will trigger the environment to load if it hasn't loaded yet (see
|
|
||||||
# {#load!}).
|
|
||||||
def config
|
|
||||||
load! if !loaded?
|
|
||||||
@config
|
|
||||||
end
|
|
||||||
|
|
||||||
# Accesses the logger for Vagrant. This logger is a _detailed_
|
# Accesses the logger for Vagrant. This logger is a _detailed_
|
||||||
# logger which should be used to log internals only. For outward
|
# logger which should be used to log internals only. For outward
|
||||||
# facing information, use {#ui}.
|
# facing information, use {#ui}.
|
||||||
|
@ -189,6 +179,18 @@ module Vagrant
|
||||||
@root_path = root_finder.call(Pathname.new(cwd))
|
@root_path = root_finder.call(Pathname.new(cwd))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#---------------------------------------------------------------
|
||||||
|
# Config Methods
|
||||||
|
#---------------------------------------------------------------
|
||||||
|
|
||||||
|
# The configuration object represented by this environment. This
|
||||||
|
# will trigger the environment to load if it hasn't loaded yet (see
|
||||||
|
# {#load!}).
|
||||||
|
def config
|
||||||
|
load! if !loaded?
|
||||||
|
@config
|
||||||
|
end
|
||||||
|
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
# Load Methods
|
# Load Methods
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
|
@ -226,8 +228,8 @@ module Vagrant
|
||||||
|
|
||||||
# If this environment is representing a sub-VM, then we push that
|
# If this environment is representing a sub-VM, then we push that
|
||||||
# proc on as the last configuration.
|
# proc on as the last configuration.
|
||||||
if !first_run && vm_name
|
if !first_run && vm
|
||||||
subvm = parent.config.vm.defined_vms[vm_name]
|
subvm = parent.config.vm.defined_vms[vm.name]
|
||||||
loader.queue << subvm.proc_stack if subvm
|
loader.queue << subvm.proc_stack if subvm
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -273,7 +275,7 @@ module Vagrant
|
||||||
# This environment represents a single sub VM. The VM is then
|
# This environment represents a single sub VM. The VM is then
|
||||||
# probably (read: should be) set on the VM attribute, so we do
|
# probably (read: should be) set on the VM attribute, so we do
|
||||||
# nothing.
|
# nothing.
|
||||||
return if vm_name
|
return if vm
|
||||||
|
|
||||||
# First load the defaults (blank, noncreated VMs)
|
# First load the defaults (blank, noncreated VMs)
|
||||||
load_blank_vms!
|
load_blank_vms!
|
||||||
|
@ -294,7 +296,7 @@ module Vagrant
|
||||||
defined_vms = [DEFAULT_VM] if defined_vms.empty?
|
defined_vms = [DEFAULT_VM] if defined_vms.empty?
|
||||||
|
|
||||||
defined_vms.each do |name|
|
defined_vms.each do |name|
|
||||||
vms[name] = Vagrant::VM.new(:vm_name => name, :env => self)
|
vms[name] = Vagrant::VM.new(:name => name, :env => self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,9 +10,9 @@ module Vagrant
|
||||||
class << self
|
class << self
|
||||||
# Finds a virtual machine by a given UUID and either returns
|
# Finds a virtual machine by a given UUID and either returns
|
||||||
# a Vagrant::VM object or returns nil.
|
# a Vagrant::VM object or returns nil.
|
||||||
def find(uuid, env=nil, vm_name=nil)
|
def find(uuid, env=nil, name=nil)
|
||||||
vm = VirtualBox::VM.find(uuid)
|
vm = VirtualBox::VM.find(uuid)
|
||||||
new(:vm => vm, :env => env, :vm_name => vm_name)
|
new(:vm => vm, :env => env, :name => name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -20,13 +20,13 @@ module Vagrant
|
||||||
defaults = {
|
defaults = {
|
||||||
:vm => nil,
|
:vm => nil,
|
||||||
:env => nil,
|
:env => nil,
|
||||||
:vm_name => nil
|
:name => nil
|
||||||
}
|
}
|
||||||
|
|
||||||
opts = defaults.merge(opts || {})
|
opts = defaults.merge(opts || {})
|
||||||
|
|
||||||
@vm = opts[:vm]
|
@vm = opts[:vm]
|
||||||
@name = opts[:vm_name]
|
@name = opts[:name]
|
||||||
|
|
||||||
if !opts[:env].nil?
|
if !opts[:env].nil?
|
||||||
# We have an environment, so we create a new child environment
|
# We have an environment, so we create a new child environment
|
||||||
|
@ -35,7 +35,6 @@ module Vagrant
|
||||||
@env = Vagrant::Environment.new({
|
@env = Vagrant::Environment.new({
|
||||||
:cwd => opts[:env].cwd,
|
:cwd => opts[:env].cwd,
|
||||||
:parent => opts[:env],
|
:parent => opts[:env],
|
||||||
:vm_name => opts[:vm_name],
|
|
||||||
:vm => self
|
:vm => self
|
||||||
}).load!
|
}).load!
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ class ImportVMActionTest < Test::Unit::TestCase
|
||||||
@box.stubs(:ovf_file).returns(ovf_file)
|
@box.stubs(:ovf_file).returns(ovf_file)
|
||||||
@env.env.stubs(:box).returns(@box)
|
@env.env.stubs(:box).returns(@box)
|
||||||
|
|
||||||
@env.env.vm = Vagrant::VM.new(:env => @env.env, :vm_name => "foobar")
|
@env.env.vm = Vagrant::VM.new(:env => @env.env, :name => "foobar")
|
||||||
|
|
||||||
VirtualBox::VM.stubs(:import)
|
VirtualBox::VM.stubs(:import)
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return the VM name if it is specified" do
|
should "return the VM name if it is specified" do
|
||||||
@env.stubs(:vm_name).returns("foo")
|
@env.stubs(:vm).returns(mock("vm", :name => "foo"))
|
||||||
assert_equal "foo", @env.resource
|
assert_equal "foo", @env.resource
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -381,7 +381,7 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
parent_env = mock_environment
|
parent_env = mock_environment
|
||||||
parent_env.config.vm.define(vm_name, &proc)
|
parent_env.config.vm.define(vm_name, &proc)
|
||||||
@env.stubs(:parent).returns(parent_env)
|
@env.stubs(:parent).returns(parent_env)
|
||||||
@env.stubs(:vm_name).returns(vm_name)
|
@env.stubs(:vm).returns(mock("vm", :name => vm_name))
|
||||||
|
|
||||||
@env.load_config!
|
@env.load_config!
|
||||||
assert @loader.queue.flatten.include?(proc)
|
assert @loader.queue.flatten.include?(proc)
|
||||||
|
@ -484,8 +484,8 @@ class EnvironmentTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "do nothing if the vm_name is set" do
|
should "do nothing if the vm is set" do
|
||||||
@env.stubs(:vm_name).returns(:foo)
|
@env.stubs(:vm).returns(mock("vm"))
|
||||||
File.expects(:open).never
|
File.expects(:open).never
|
||||||
@env.load_vm!
|
@env.load_vm!
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,7 +27,7 @@ class VMTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@vm_name = "foo"
|
@vm_name = "foo"
|
||||||
@mock_vm = mock("vm")
|
@mock_vm = mock("vm")
|
||||||
@vm = Vagrant::VM.new(:env => @env, :vm => @mock_vm, :vm_name => @vm_name)
|
@vm = Vagrant::VM.new(:env => @env, :vm => @mock_vm, :name => @vm_name)
|
||||||
@mock_vm.stubs(:uuid).returns("foo")
|
@mock_vm.stubs(:uuid).returns("foo")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue