diff --git a/lib/vagrant/driver/virtualbox.rb b/lib/vagrant/driver/virtualbox.rb index 1cd0d7953..baf462b87 100644 --- a/lib/vagrant/driver/virtualbox.rb +++ b/lib/vagrant/driver/virtualbox.rb @@ -88,6 +88,7 @@ module Vagrant :read_guest_additions_version, :read_host_only_interfaces, :read_mac_address, + :read_mac_addresses, :read_machine_folder, :read_network_interfaces, :read_state, diff --git a/lib/vagrant/driver/virtualbox_4_0.rb b/lib/vagrant/driver/virtualbox_4_0.rb index d68d323e8..23546e2f0 100644 --- a/lib/vagrant/driver/virtualbox_4_0.rb +++ b/lib/vagrant/driver/virtualbox_4_0.rb @@ -317,6 +317,19 @@ module Vagrant nil end + + def read_mac_addresses + macs = {} + info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true) + info.split("\n").each do |line| + if matcher = /^macaddress(\d+)="(.+?)"$/.match(line) + adapter = matcher[1].to_i + mac = matcher[2].to_s + macs[adapter] = mac + end + end + macs + end def read_machine_folder execute("list", "systemproperties", :retryable => true).split("\n").each do |line| diff --git a/lib/vagrant/driver/virtualbox_4_1.rb b/lib/vagrant/driver/virtualbox_4_1.rb index 3cfc4688a..3983a1112 100644 --- a/lib/vagrant/driver/virtualbox_4_1.rb +++ b/lib/vagrant/driver/virtualbox_4_1.rb @@ -318,6 +318,19 @@ module Vagrant nil end + def read_mac_addresses + macs = {} + info = execute("showvminfo", @uuid, "--machinereadable", :retryable => true) + info.split("\n").each do |line| + if matcher = /^macaddress(\d+)="(.+?)"$/.match(line) + adapter = matcher[1].to_i + mac = matcher[2].to_s + macs[adapter] = mac + end + end + macs + end + def read_machine_folder execute("list", "systemproperties", :retryable => true).split("\n").each do |line| if folder = line[/^Default machine folder:\s+(.+?)$/i, 1]