diff --git a/lib/vagrant/action.rb b/lib/vagrant/action.rb index 5433ffdc9..f1374a13a 100644 --- a/lib/vagrant/action.rb +++ b/lib/vagrant/action.rb @@ -34,7 +34,6 @@ module Vagrant autoload :ClearNFSExports, 'vagrant/action/vm/clear_nfs_exports' autoload :ClearSharedFolders, 'vagrant/action/vm/clear_shared_folders' autoload :Customize, 'vagrant/action/vm/customize' - autoload :DefaultName, 'vagrant/action/vm/default_name' autoload :Destroy, 'vagrant/action/vm/destroy' autoload :DestroyUnusedNetworkInterfaces, 'vagrant/action/vm/destroy_unused_network_interfaces' autoload :DiscardState, 'vagrant/action/vm/discard_state' diff --git a/lib/vagrant/action/builtin.rb b/lib/vagrant/action/builtin.rb index 769487744..1da12a7d2 100644 --- a/lib/vagrant/action/builtin.rb +++ b/lib/vagrant/action/builtin.rb @@ -83,7 +83,6 @@ module Vagrant use VM::Import use VM::MatchMACAddress use VM::CheckGuestAdditions - use VM::DefaultName use registry.get(:start) end end diff --git a/lib/vagrant/action/vm/check_guest_additions.rb b/lib/vagrant/action/vm/check_guest_additions.rb index 7044398fd..045d91a39 100644 --- a/lib/vagrant/action/vm/check_guest_additions.rb +++ b/lib/vagrant/action/vm/check_guest_additions.rb @@ -13,7 +13,7 @@ module Vagrant # Use the raw interface for now, while the virtualbox gem # doesn't support guest properties (due to cross platform issues) version = env[:vm].driver.guest_additions_version(env[:vm].uuid) - if version.empty? + if !version env[:ui].warn I18n.t("vagrant.actions.vm.check_guest_additions.not_detected") else # Strip the -OSE/_OSE off from the guest additions and the virtual box diff --git a/lib/vagrant/action/vm/default_name.rb b/lib/vagrant/action/vm/default_name.rb deleted file mode 100644 index b430623b4..000000000 --- a/lib/vagrant/action/vm/default_name.rb +++ /dev/null @@ -1,24 +0,0 @@ -module Vagrant - module Action - module VM - # This action sets the default name of a virtual machine. The default - # name is the CWD of the environment plus a timestamp. - class DefaultName - def initialize(app, env) - @app = app - end - - def call(env) - # Create the proc to setup the default name - proc = lambda do |vm| - vm.name = File.basename(env[:vm].env.cwd) + "_#{Time.now.to_i}" - end - - env["vm.modify"].call(proc) - - @app.call(env) - end - end - end - end -end diff --git a/lib/vagrant/action/vm/import.rb b/lib/vagrant/action/vm/import.rb index 600103bbe..123c7c127 100644 --- a/lib/vagrant/action/vm/import.rb +++ b/lib/vagrant/action/vm/import.rb @@ -10,8 +10,9 @@ module Vagrant env[:ui].info I18n.t("vagrant.actions.vm.import.importing", :name => env[:vm].box.name) # Import the virtual machine + name = File.basename(env[:vm].env.cwd) + "_#{Time.now.to_i}" ovf_file = env[:vm].box.directory.join("box.ovf").to_s - env[:vm].uuid = env[:vm].driver.import(ovf_file) do |progress| + env[:vm].uuid = env[:vm].driver.import(ovf_file, name) do |progress| env[:ui].clear_line env[:ui].report_progress(progress.percent, 100, false) end diff --git a/lib/vagrant/action/vm/match_mac_address.rb b/lib/vagrant/action/vm/match_mac_address.rb index cb707fd97..ad316620a 100644 --- a/lib/vagrant/action/vm/match_mac_address.rb +++ b/lib/vagrant/action/vm/match_mac_address.rb @@ -10,13 +10,9 @@ module Vagrant raise Errors::VMBaseMacNotSpecified if !env[:vm].config.vm.base_mac # Create the proc which we want to use to modify the virtual machine - proc = lambda do |vm| - env[:ui].info I18n.t("vagrant.actions.vm.match_mac.matching") - vm.network_adapters.first.mac_address = env[:vm].config.vm.base_mac - end - - # Add the proc to the modification chain - env["vm.modify"].call(proc) + env[:ui].info I18n.t("vagrant.actions.vm.match_mac.matching") + env[:vm].driver.set_mac_address(env[:vm].uuid, + env[:vm].config.vm.base_mac) @app.call(env) end diff --git a/lib/vagrant/driver/virtualbox.rb b/lib/vagrant/driver/virtualbox.rb index 1f50bf595..71e618676 100644 --- a/lib/vagrant/driver/virtualbox.rb +++ b/lib/vagrant/driver/virtualbox.rb @@ -24,14 +24,11 @@ module Vagrant # Imports the VM with the given path to the OVF file. It returns # the UUID as a string. - def import(ovf) - output = execute("import", ovf) - if output =~ /VM name "(.+?)"/ - name = $1.to_s - output = execute("list", "vms") - if output =~ /^"#{name}" {(.+?)}$/ - return $1.to_s - end + def import(ovf, name) + execute("import", ovf, "--vsys", "0", "--vmname", name) + output = execute("list", "vms") + if output =~ /^"#{name}" {(.+?)}$/ + return $1.to_s end nil @@ -62,6 +59,11 @@ module Vagrant nil end + # This sets the MAC address for a network adapter. + def set_mac_address(uuid, mac) + execute("modifyvm", uuid, "--macaddress1", mac) + end + protected # This returns the version of VirtualBox that is running.