Skip to content

Commit

Permalink
Update drivers to support reading MAC Addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
pmorton committed Jun 8, 2012
1 parent 29d24f7 commit ddabacb
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/vagrant/driver/virtualbox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def initialize(uuid=nil)
:read_guest_additions_version,
:read_host_only_interfaces,
:read_mac_address,
:read_mac_addresses,
:read_machine_folder,
:read_network_interfaces,
:read_state,
Expand Down
13 changes: 13 additions & 0 deletions lib/vagrant/driver/virtualbox_4_0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,19 @@ def read_mac_address

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|
Expand Down
13 changes: 13 additions & 0 deletions lib/vagrant/driver/virtualbox_4_1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,19 @@ def read_mac_address
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 line =~ /^Default machine folder:\s+(.+?)$/i
Expand Down

0 comments on commit ddabacb

Please sign in to comment.