providers/virtualbox: cloning can do a non-linked clone
This commit is contained in:
parent
20310dce0c
commit
9f05d22eb0
|
@ -12,16 +12,18 @@ module VagrantPlugins
|
|||
def call(env)
|
||||
# Get the snapshot to base the linked clone on. This defaults
|
||||
# to "base" which is automatically setup with linked clones.
|
||||
snapshot = "base"
|
||||
if env[:machine].provider_config.linked_clone_snapshot
|
||||
snapshot = env[:machine].provider_config.linked_clone_snapshot
|
||||
snapshot = nil
|
||||
if env[:machine].provider_config.linked_clone
|
||||
snapshot = "base"
|
||||
if env[:machine].provider_config.linked_clone_snapshot
|
||||
snapshot = env[:machine].provider_config.linked_clone_snapshot
|
||||
end
|
||||
end
|
||||
|
||||
# Do the actual clone
|
||||
env[:ui].info I18n.t(
|
||||
"vagrant.actions.vm.clone.creating", name: env[:machine].box.name)
|
||||
env[:ui].info I18n.t("vagrant.actions.vm.clone.creating")
|
||||
env[:machine].id = env[:machine].provider.driver.clonevm(
|
||||
env[:master_id], env[:machine].box.name, snapshot) do |progress|
|
||||
env[:master_id], snapshot) do |progress|
|
||||
env[:ui].clear_line
|
||||
env[:ui].report_progress(progress, 100, false)
|
||||
end
|
||||
|
|
|
@ -35,13 +35,15 @@ module VagrantPlugins
|
|||
end
|
||||
end
|
||||
|
||||
def clonevm(master_id, box_name, snapshot_name)
|
||||
@logger.debug("Creating linked clone from master vm with id #{master_id} from snapshot '#{snapshot_name}'")
|
||||
def clonevm(master_id, snapshot_name)
|
||||
machine_name = "temp_clone_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
|
||||
args = ["--register", "--name", machine_name]
|
||||
if snapshot_name
|
||||
args += ["--snapshot", snapshot_name, "--options", "link"]
|
||||
end
|
||||
|
||||
machine_name = "#{box_name}_#{snapshot_name}_clone_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
|
||||
execute("clonevm", master_id, "--snapshot", snapshot_name, "--options", "link", "--register", "--name", machine_name)
|
||||
|
||||
return get_machine_id machine_name
|
||||
execute("clonevm", master_id, *args)
|
||||
return get_machine_id(machine_name)
|
||||
end
|
||||
|
||||
def create_dhcp_server(network, options)
|
||||
|
|
|
@ -34,13 +34,15 @@ module VagrantPlugins
|
|||
end
|
||||
end
|
||||
|
||||
def clonevm(master_id, box_name, snapshot_name)
|
||||
@logger.debug("Creating linked clone from master vm with id #{master_id} from snapshot '#{snapshot_name}'")
|
||||
def clonevm(master_id, snapshot_name)
|
||||
machine_name = "temp_clone_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
|
||||
args = ["--register", "--name", machine_name]
|
||||
if snapshot_name
|
||||
args += ["--snapshot", snapshot_name, "--options", "link"]
|
||||
end
|
||||
|
||||
machine_name = "#{box_name}_#{snapshot_name}_clone_#{(Time.now.to_f * 1000.0).to_i}_#{rand(100000)}"
|
||||
execute("clonevm", master_id, "--snapshot", snapshot_name, "--options", "link", "--register", "--name", machine_name)
|
||||
|
||||
return get_machine_id machine_name
|
||||
execute("clonevm", master_id, *args)
|
||||
return get_machine_id(machine_name)
|
||||
end
|
||||
|
||||
def create_dhcp_server(network, options)
|
||||
|
|
|
@ -1636,7 +1636,7 @@ en:
|
|||
This is a one time operation. Once the master VM is prepared,
|
||||
it will be used as a base for linked clones, making the creation
|
||||
of new VMs take milliseconds on a modern system.
|
||||
creating: Creating linked clone...
|
||||
creating: Cloning VM...
|
||||
failure: Creation of the linked clone failed.
|
||||
create_master:
|
||||
failure: |-
|
||||
|
|
Loading…
Reference in New Issue