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)
|
def call(env)
|
||||||
# Get the snapshot to base the linked clone on. This defaults
|
# Get the snapshot to base the linked clone on. This defaults
|
||||||
# to "base" which is automatically setup with linked clones.
|
# to "base" which is automatically setup with linked clones.
|
||||||
snapshot = "base"
|
snapshot = nil
|
||||||
if env[:machine].provider_config.linked_clone_snapshot
|
if env[:machine].provider_config.linked_clone
|
||||||
snapshot = env[:machine].provider_config.linked_clone_snapshot
|
snapshot = "base"
|
||||||
|
if env[:machine].provider_config.linked_clone_snapshot
|
||||||
|
snapshot = env[:machine].provider_config.linked_clone_snapshot
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Do the actual clone
|
# Do the actual clone
|
||||||
env[:ui].info I18n.t(
|
env[:ui].info I18n.t("vagrant.actions.vm.clone.creating")
|
||||||
"vagrant.actions.vm.clone.creating", name: env[:machine].box.name)
|
|
||||||
env[:machine].id = env[:machine].provider.driver.clonevm(
|
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].clear_line
|
||||||
env[:ui].report_progress(progress, 100, false)
|
env[:ui].report_progress(progress, 100, false)
|
||||||
end
|
end
|
||||||
|
|
|
@ -35,13 +35,15 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def clonevm(master_id, box_name, snapshot_name)
|
def clonevm(master_id, snapshot_name)
|
||||||
@logger.debug("Creating linked clone from master vm with id #{master_id} from snapshot '#{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, *args)
|
||||||
execute("clonevm", master_id, "--snapshot", snapshot_name, "--options", "link", "--register", "--name", machine_name)
|
return get_machine_id(machine_name)
|
||||||
|
|
||||||
return get_machine_id machine_name
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_dhcp_server(network, options)
|
def create_dhcp_server(network, options)
|
||||||
|
|
|
@ -34,13 +34,15 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def clonevm(master_id, box_name, snapshot_name)
|
def clonevm(master_id, snapshot_name)
|
||||||
@logger.debug("Creating linked clone from master vm with id #{master_id} from snapshot '#{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, *args)
|
||||||
execute("clonevm", master_id, "--snapshot", snapshot_name, "--options", "link", "--register", "--name", machine_name)
|
return get_machine_id(machine_name)
|
||||||
|
|
||||||
return get_machine_id machine_name
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_dhcp_server(network, options)
|
def create_dhcp_server(network, options)
|
||||||
|
|
|
@ -1636,7 +1636,7 @@ en:
|
||||||
This is a one time operation. Once the master VM is prepared,
|
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
|
it will be used as a base for linked clones, making the creation
|
||||||
of new VMs take milliseconds on a modern system.
|
of new VMs take milliseconds on a modern system.
|
||||||
creating: Creating linked clone...
|
creating: Cloning VM...
|
||||||
failure: Creation of the linked clone failed.
|
failure: Creation of the linked clone failed.
|
||||||
create_master:
|
create_master:
|
||||||
failure: |-
|
failure: |-
|
||||||
|
|
Loading…
Reference in New Issue