2014-02-14 00:34:34 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module ProviderVirtualBox
|
|
|
|
module Cap
|
|
|
|
# Reads the forwarded ports that currently exist on the machine
|
|
|
|
# itself. This raises an exception if the machine isn't running.
|
|
|
|
#
|
|
|
|
# This also may not match up with configured forwarded ports, because
|
|
|
|
# Vagrant auto port collision fixing may have taken place.
|
|
|
|
#
|
|
|
|
# @return [Hash<Integer, Integer>] Host => Guest port mappings.
|
|
|
|
def self.forwarded_ports(machine)
|
2015-11-24 20:48:17 +00:00
|
|
|
return nil if machine.state.id != :running
|
|
|
|
|
2014-02-14 00:34:34 +00:00
|
|
|
{}.tap do |result|
|
|
|
|
machine.provider.driver.read_forwarded_ports.each do |_, _, h, g|
|
|
|
|
result[h] = g
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-03-14 18:23:07 +00:00
|
|
|
|
|
|
|
# Reads the network interface card MAC addresses and returns them.
|
|
|
|
#
|
|
|
|
# @return [Hash<String, String>] Adapter => MAC address
|
|
|
|
def self.nic_mac_addresses(machine)
|
|
|
|
machine.provider.driver.read_mac_addresses
|
|
|
|
end
|
2015-10-08 12:46:36 +00:00
|
|
|
|
|
|
|
# Returns a list of the snapshots that are taken on this machine.
|
|
|
|
#
|
|
|
|
# @return [Array<String>] Snapshot Name
|
|
|
|
def self.snapshot_list(machine)
|
2019-04-09 20:11:19 +00:00
|
|
|
return [] if machine.id.nil?
|
2015-10-08 12:46:36 +00:00
|
|
|
machine.provider.driver.list_snapshots(machine.id)
|
|
|
|
end
|
2014-02-14 00:34:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|