Change `vm` attribute to be `runner` on action base to reflect what it now is.
This commit is contained in:
parent
35762a4308
commit
6b705cbe42
|
@ -5,7 +5,7 @@ module Vagrant
|
|||
# action should define any callbacks that it will call, or
|
||||
# attach itself to some callbacks on the VM object.
|
||||
class Base
|
||||
attr_reader :vm
|
||||
attr_reader :runner
|
||||
|
||||
# Included so subclasses don't need to include it themselves.
|
||||
include Vagrant::Util
|
||||
|
@ -17,8 +17,8 @@ module Vagrant
|
|||
# would be instance_evaling the vm instance to include a module so
|
||||
# additionally functionality could be defined on the vm which other
|
||||
# action `prepare` methods may rely on.
|
||||
def initialize(vm, *args)
|
||||
@vm = vm
|
||||
def initialize(runner, *args)
|
||||
@runner = runner
|
||||
end
|
||||
|
||||
# This method is called once per action, allowing the action
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
module Vagrant
|
||||
module Actions
|
||||
module Box
|
||||
# An action which acts on a box by downloading the box file from
|
||||
# the given URI into a temporary location.
|
||||
class Download < Base
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -9,7 +9,7 @@ module Vagrant
|
|||
ovf_path = File.join(folder, "#{name}.ovf")
|
||||
|
||||
logger.info "Exporting required VM files to directory: #{folder} ..."
|
||||
@vm.export(ovf_path)
|
||||
@runner.export(ovf_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,7 @@ module Vagrant
|
|||
|
||||
def clear
|
||||
logger.info "Deleting any previously set forwarded ports..."
|
||||
@vm.vm.forwarded_ports.collect { |p| p.destroy(true) }
|
||||
@runner.vm.forwarded_ports.collect { |p| p.destroy(true) }
|
||||
end
|
||||
|
||||
def forward_ports
|
||||
|
@ -21,10 +21,10 @@ module Vagrant
|
|||
port.name = name
|
||||
port.hostport = options[:hostport]
|
||||
port.guestport = options[:guestport]
|
||||
@vm.vm.forwarded_ports << port
|
||||
@runner.vm.forwarded_ports << port
|
||||
end
|
||||
|
||||
@vm.vm.save(true)
|
||||
@runner.vm.save(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,11 +10,11 @@ module Vagrant
|
|||
end
|
||||
|
||||
def execute!
|
||||
@vm.invoke_around_callback(:import) do
|
||||
@runner.invoke_around_callback(:import) do
|
||||
Busy.busy do
|
||||
logger.info "Importing base VM (#{@ovf_file})..."
|
||||
# Use the first argument passed to the action
|
||||
@vm.vm = VirtualBox::VM.import(@ovf_file)
|
||||
@runner.vm = VirtualBox::VM.import(@ovf_file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ module Vagrant
|
|||
module VM
|
||||
class MoveHardDrive < Base
|
||||
def execute!
|
||||
unless @vm.powered_off?
|
||||
unless @runner.powered_off?
|
||||
error_and_exit(<<-error)
|
||||
The virtual machine must be powered off to move its disk.
|
||||
error
|
||||
|
@ -19,7 +19,7 @@ error
|
|||
|
||||
# TODO won't work if the first disk is not the boot disk or even if there are multiple disks
|
||||
def find_hard_drive
|
||||
@vm.storage_controllers.each do |sc|
|
||||
@runner.storage_controllers.each do |sc|
|
||||
sc.devices.each do |d|
|
||||
return d if d.image.is_a?(VirtualBox::HardDrive)
|
||||
end
|
||||
|
@ -31,7 +31,7 @@ error
|
|||
hard_drive.image = hard_drive.image.clone(new_image_path, Vagrant.config.vm.disk_image_format, true)
|
||||
|
||||
logger.info "Attaching new disk to VM ..."
|
||||
@vm.vm.save
|
||||
@runner.vm.save
|
||||
end
|
||||
|
||||
def destroy_drive_after
|
||||
|
|
|
@ -7,7 +7,7 @@ module Vagrant
|
|||
steps << Provision if Vagrant.config.chef.enabled
|
||||
|
||||
steps.each do |action_klass|
|
||||
@vm.add_action(action_klass)
|
||||
@runner.add_action(action_klass)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ module Vagrant
|
|||
module VM
|
||||
class SharedFolders < Base
|
||||
def shared_folders
|
||||
shared_folders = @vm.invoke_callback(:collect_shared_folders)
|
||||
shared_folders = @runner.invoke_callback(:collect_shared_folders)
|
||||
|
||||
# Basic filtering of shared folders. Basically only verifies that
|
||||
# the result is an array of 3 elements. In the future this should
|
||||
|
@ -25,10 +25,10 @@ module Vagrant
|
|||
folder = VirtualBox::SharedFolder.new
|
||||
folder.name = name
|
||||
folder.hostpath = hostpath
|
||||
@vm.vm.shared_folders << folder
|
||||
@runner.vm.shared_folders << folder
|
||||
end
|
||||
|
||||
@vm.vm.save(true)
|
||||
@runner.vm.save(true)
|
||||
end
|
||||
|
||||
def after_boot
|
||||
|
|
|
@ -3,7 +3,7 @@ module Vagrant
|
|||
module VM
|
||||
class Start < Base
|
||||
def execute!
|
||||
@vm.invoke_around_callback(:boot) do
|
||||
@runner.invoke_around_callback(:boot) do
|
||||
# Startup the VM
|
||||
boot
|
||||
|
||||
|
@ -19,7 +19,7 @@ error
|
|||
|
||||
def boot
|
||||
logger.info "Booting VM..."
|
||||
@vm.vm.start(:headless, true)
|
||||
@runner.vm.start(:headless, true)
|
||||
end
|
||||
|
||||
def wait_for_boot(sleeptime=5)
|
||||
|
|
|
@ -4,7 +4,7 @@ module Vagrant
|
|||
class Stop < Base
|
||||
def execute!
|
||||
logger.info "Forcing shutdown of VM..."
|
||||
@vm.vm.stop(true)
|
||||
@runner.vm.stop(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,14 +11,14 @@ module Vagrant
|
|||
def prepare
|
||||
# Up is a "meta-action" so it really just queues up a bunch
|
||||
# of other actions in its place:
|
||||
@vm.add_action(Import, @ovf_file)
|
||||
@runner.add_action(Import, @ovf_file)
|
||||
|
||||
steps = [ForwardPorts, SharedFolders, Start]
|
||||
steps << Provision if Vagrant.config.chef.enabled
|
||||
steps.insert(0, MoveHardDrive) if Vagrant.config.vm.hd_location
|
||||
|
||||
steps.each do |action_klass|
|
||||
@vm.add_action(action_klass)
|
||||
@runner.add_action(action_klass)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -33,14 +33,14 @@ module Vagrant
|
|||
end
|
||||
|
||||
def persist
|
||||
logger.info "Persisting the VM UUID (#{@vm.vm.uuid})..."
|
||||
Env.persist_vm(@vm.vm)
|
||||
logger.info "Persisting the VM UUID (#{@runner.vm.uuid})..."
|
||||
Env.persist_vm(@runner.vm)
|
||||
end
|
||||
|
||||
def setup_mac_address
|
||||
logger.info "Matching MAC addresses..."
|
||||
@vm.vm.nics.first.macaddress = Vagrant.config[:vm][:base_mac]
|
||||
@vm.vm.save(true)
|
||||
@runner.vm.nics.first.macaddress = Vagrant.config[:vm][:base_mac]
|
||||
@runner.vm.save(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,8 +11,8 @@ class BaseActionTest < Test::Unit::TestCase
|
|||
@base = Vagrant::Actions::Base.new(@mock_vm)
|
||||
end
|
||||
|
||||
should "allow read-only access to the VM" do
|
||||
assert_equal @mock_vm, @base.vm
|
||||
should "allow read-only access to the runner" do
|
||||
assert_equal @mock_vm, @base.runner
|
||||
end
|
||||
|
||||
should "implement prepare which does nothing" do
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
require File.join(File.dirname(__FILE__), '..', '..', '..', 'test_helper')
|
||||
|
||||
class DownloadBoxActionTest < Test::Unit::TestCase
|
||||
setup do
|
||||
@wrapper_vm, @vm, @action = mock_action(Vagrant::Actions::Box::Download)
|
||||
mock_config
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue