providers/virtualbox: copy SSH key
This commit is contained in:
parent
e9922d1754
commit
4908cd9cd9
|
@ -12,7 +12,7 @@ module VagrantPlugins
|
||||||
autoload :CleanMachineFolder, File.expand_path("../action/clean_machine_folder", __FILE__)
|
autoload :CleanMachineFolder, File.expand_path("../action/clean_machine_folder", __FILE__)
|
||||||
autoload :ClearForwardedPorts, File.expand_path("../action/clear_forwarded_ports", __FILE__)
|
autoload :ClearForwardedPorts, File.expand_path("../action/clear_forwarded_ports", __FILE__)
|
||||||
autoload :ClearNetworkInterfaces, File.expand_path("../action/clear_network_interfaces", __FILE__)
|
autoload :ClearNetworkInterfaces, File.expand_path("../action/clear_network_interfaces", __FILE__)
|
||||||
autoload :CreateClone, File.expand_path("../action/create_clone", __FILE__)
|
autoload :Clone, File.expand_path("../action/clone", __FILE__)
|
||||||
autoload :Created, File.expand_path("../action/created", __FILE__)
|
autoload :Created, File.expand_path("../action/created", __FILE__)
|
||||||
autoload :Customize, File.expand_path("../action/customize", __FILE__)
|
autoload :Customize, File.expand_path("../action/customize", __FILE__)
|
||||||
autoload :Destroy, File.expand_path("../action/destroy", __FILE__)
|
autoload :Destroy, File.expand_path("../action/destroy", __FILE__)
|
||||||
|
@ -390,13 +390,13 @@ module VagrantPlugins
|
||||||
# We are cloning from another Vagrant environment
|
# We are cloning from another Vagrant environment
|
||||||
b2.use PrepareClone
|
b2.use PrepareClone
|
||||||
b2.use PrepareCloneSnapshot
|
b2.use PrepareCloneSnapshot
|
||||||
b2.use CreateClone
|
b2.use Clone
|
||||||
b2.use DiscardState
|
b2.use DiscardState
|
||||||
elsif env[:machine].provider_config.linked_clone
|
elsif env[:machine].provider_config.linked_clone
|
||||||
# We are cloning from the box
|
# We are cloning from the box
|
||||||
b2.use ImportMaster
|
b2.use ImportMaster
|
||||||
b2.use PrepareCloneSnapshot
|
b2.use PrepareCloneSnapshot
|
||||||
b2.use CreateClone
|
b2.use Clone
|
||||||
b2.use DiscardState
|
b2.use DiscardState
|
||||||
else
|
else
|
||||||
# We are just doing a normal import from a box
|
# We are just doing a normal import from a box
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
require "log4r"
|
require "log4r"
|
||||||
|
|
||||||
|
require "fileutils"
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module ProviderVirtualBox
|
module ProviderVirtualBox
|
||||||
module Action
|
module Action
|
||||||
class CreateClone
|
class Clone
|
||||||
def initialize(app, env)
|
def initialize(app, env)
|
||||||
@app = app
|
@app = app
|
||||||
@logger = Log4r::Logger.new("vagrant::action::vm::clone")
|
@logger = Log4r::Logger.new("vagrant::action::vm::clone")
|
||||||
|
@ -25,6 +27,16 @@ module VagrantPlugins
|
||||||
# Flag as erroneous and return if clone failed
|
# Flag as erroneous and return if clone failed
|
||||||
raise Vagrant::Errors::VMCloneFailure if !env[:machine].id
|
raise Vagrant::Errors::VMCloneFailure if !env[:machine].id
|
||||||
|
|
||||||
|
# Copy the SSH key from the clone machine if we can
|
||||||
|
if env[:clone_machine]
|
||||||
|
key_path = env[:clone_machine].data_dir.join("private_key")
|
||||||
|
if key_path.file?
|
||||||
|
FileUtils.cp(
|
||||||
|
key_path,
|
||||||
|
env[:machine].data_dir.join("private_key"))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Continue
|
# Continue
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
end
|
end
|
|
@ -22,6 +22,7 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Set the ID of the master so we know what to clone from
|
# Set the ID of the master so we know what to clone from
|
||||||
env[:clone_id] = clone_machine.id
|
env[:clone_id] = clone_machine.id
|
||||||
|
env[:clone_machine] = clone_machine
|
||||||
|
|
||||||
# Continue
|
# Continue
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
|
|
Loading…
Reference in New Issue