Make more things VBoxManage compatible
This commit is contained in:
parent
96868e5d29
commit
a8e4e62264
|
@ -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'
|
||||
|
|
|
@ -83,7 +83,6 @@ module Vagrant
|
|||
use VM::Import
|
||||
use VM::MatchMACAddress
|
||||
use VM::CheckGuestAdditions
|
||||
use VM::DefaultName
|
||||
use registry.get(:start)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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[:vm].driver.set_mac_address(env[:vm].uuid,
|
||||
env[:vm].config.vm.base_mac)
|
||||
|
||||
@app.call(env)
|
||||
end
|
||||
|
|
|
@ -24,15 +24,12 @@ 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
|
||||
def import(ovf, name)
|
||||
execute("import", ovf, "--vsys", "0", "--vmname", name)
|
||||
output = execute("list", "vms")
|
||||
if output =~ /^"#{name}" {(.+?)}$/
|
||||
return $1.to_s
|
||||
end
|
||||
end
|
||||
|
||||
nil
|
||||
end
|
||||
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue