diff --git a/plugins/providers/virtualbox/action/create_clone.rb b/plugins/providers/virtualbox/action/create_clone.rb index eae9eda5e..ac3ca519e 100644 --- a/plugins/providers/virtualbox/action/create_clone.rb +++ b/plugins/providers/virtualbox/action/create_clone.rb @@ -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 diff --git a/plugins/providers/virtualbox/driver/version_4_3.rb b/plugins/providers/virtualbox/driver/version_4_3.rb index b51eec37a..f895739d3 100644 --- a/plugins/providers/virtualbox/driver/version_4_3.rb +++ b/plugins/providers/virtualbox/driver/version_4_3.rb @@ -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) diff --git a/plugins/providers/virtualbox/driver/version_5_0.rb b/plugins/providers/virtualbox/driver/version_5_0.rb index 9762eda42..d13330c00 100644 --- a/plugins/providers/virtualbox/driver/version_5_0.rb +++ b/plugins/providers/virtualbox/driver/version_5_0.rb @@ -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) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index ff2f1fac1..d5fa23d2c 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -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: |-