providers/virtualbox: make prepare clone a core thing
This commit is contained in:
parent
be58cc0589
commit
36cfc77167
|
@ -24,6 +24,7 @@ module Vagrant
|
|||
autoload :IsState, "vagrant/action/builtin/is_state"
|
||||
autoload :Lock, "vagrant/action/builtin/lock"
|
||||
autoload :Message, "vagrant/action/builtin/message"
|
||||
autoload :PrepareClone, "vagrant/action/builtin/prepare_clone"
|
||||
autoload :Provision, "vagrant/action/builtin/provision"
|
||||
autoload :ProvisionerCleanup, "vagrant/action/builtin/provisioner_cleanup"
|
||||
autoload :SetHostname, "vagrant/action/builtin/set_hostname"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
require "log4r"
|
||||
|
||||
module VagrantPlugins
|
||||
module ProviderVirtualBox
|
||||
module Action
|
||||
module Vagrant
|
||||
module Action
|
||||
module Builtin
|
||||
class PrepareClone
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
|
@ -10,15 +10,20 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def call(env)
|
||||
# If we aren't cloning, then do nothing
|
||||
if !env[:machine].config.vm.clone
|
||||
return @app.call(env)
|
||||
end
|
||||
|
||||
# We need to get the machine ID from this Vagrant environment
|
||||
clone_env = env[:machine].env.environment(
|
||||
env[:machine].config.vm.clone)
|
||||
raise Vagrant::Errors::CloneNotFound if !clone_env.root_path
|
||||
raise Errors::CloneNotFound if !clone_env.root_path
|
||||
|
||||
# Get the machine itself
|
||||
clone_machine = clone_env.machine(
|
||||
clone_env.primary_machine_name, env[:machine].provider_name)
|
||||
raise Vagrant::Errors::CloneMachineNotFound if !clone_machine.id
|
||||
raise Errors::CloneMachineNotFound if !clone_machine.id
|
||||
|
||||
# Set the ID of the master so we know what to clone from
|
||||
env[:clone_id] = clone_machine.id
|
|
@ -34,7 +34,6 @@ module VagrantPlugins
|
|||
autoload :NetworkFixIPv6, File.expand_path("../action/network_fix_ipv6", __FILE__)
|
||||
autoload :Package, File.expand_path("../action/package", __FILE__)
|
||||
autoload :PackageVagrantfile, File.expand_path("../action/package_vagrantfile", __FILE__)
|
||||
autoload :PrepareClone, File.expand_path("../action/prepare_clone", __FILE__)
|
||||
autoload :PrepareCloneSnapshot, File.expand_path("../action/prepare_clone_snapshot", __FILE__)
|
||||
autoload :PrepareNFSSettings, File.expand_path("../action/prepare_nfs_settings", __FILE__)
|
||||
autoload :PrepareNFSValidIds, File.expand_path("../action/prepare_nfs_valid_ids", __FILE__)
|
||||
|
@ -385,14 +384,12 @@ module VagrantPlugins
|
|||
b2.use CheckAccessible
|
||||
b2.use Customize, "pre-import"
|
||||
|
||||
if env[:machine].config.vm.clone
|
||||
# We are cloning from another Vagrant environment
|
||||
b2.use PrepareClone
|
||||
elsif env[:machine].provider_config.linked_clone
|
||||
if env[:machine].provider_config.linked_clone
|
||||
# We are cloning from the box
|
||||
b2.use ImportMaster
|
||||
end
|
||||
|
||||
b2.use PrepareClone
|
||||
b2.use PrepareCloneSnapshot
|
||||
b2.use Import
|
||||
b2.use DiscardState
|
||||
|
|
Loading…
Reference in New Issue