Return nil if the VM is not running when looking at forwarded ports

This commit is contained in:
Seth Vargo 2015-11-24 15:48:17 -05:00
parent beb84d3212
commit f20c08f57f
1 changed files with 2 additions and 0 deletions

View File

@ -9,6 +9,8 @@ module VagrantPlugins
# #
# @return [Hash<Integer, Integer>] Host => Guest port mappings. # @return [Hash<Integer, Integer>] Host => Guest port mappings.
def self.forwarded_ports(machine) def self.forwarded_ports(machine)
return nil if machine.state.id != :running
{}.tap do |result| {}.tap do |result|
machine.provider.driver.read_forwarded_ports.each do |_, _, h, g| machine.provider.driver.read_forwarded_ports.each do |_, _, h, g|
result[h] = g result[h] = g