diff --git a/lib/vSphere/cap/public_address.rb b/lib/vSphere/cap/public_address.rb new file mode 100644 index 00000000..ec143ad8 --- /dev/null +++ b/lib/vSphere/cap/public_address.rb @@ -0,0 +1,15 @@ +module VagrantPlugins + module VSphere + module Cap + module PublicAddress + def self.public_address(machine) + return nil if machine.state.id != :running + + ssh_info = machine.ssh_info + return nil unless ssh_info + ssh_info[:host] + end + end + end + end +end diff --git a/lib/vSphere/plugin.rb b/lib/vSphere/plugin.rb index cbd447bd..fb0b188d 100644 --- a/lib/vSphere/plugin.rb +++ b/lib/vSphere/plugin.rb @@ -30,6 +30,11 @@ class Plugin < Vagrant.plugin('2') Provider end + provider_capability('vsphere', 'public_address') do + require_relative 'cap/public_address' + Cap::PublicAddress + end + def self.setup_i18n I18n.load_path << File.expand_path('locales/en.yml', VSphere.source_root) I18n.reload!