From f20c08f57f94c138403a265e3c03c3748e854f2f Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Tue, 24 Nov 2015 15:48:17 -0500 Subject: [PATCH] Return nil if the VM is not running when looking at forwarded ports --- plugins/providers/virtualbox/cap.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/providers/virtualbox/cap.rb b/plugins/providers/virtualbox/cap.rb index 77f8ee1ad..1c0512407 100644 --- a/plugins/providers/virtualbox/cap.rb +++ b/plugins/providers/virtualbox/cap.rb @@ -9,6 +9,8 @@ module VagrantPlugins # # @return [Hash] Host => Guest port mappings. def self.forwarded_ports(machine) + return nil if machine.state.id != :running + {}.tap do |result| machine.provider.driver.read_forwarded_ports.each do |_, _, h, g| result[h] = g