From 056e47d3642169e2b274a9963cd04aaa80462903 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 12 Mar 2014 10:27:30 -0300 Subject: [PATCH] core: Introduce a public_address capability so that we can use `vagrant share` --- lib/vagrant-lxc/plugin.rb | 7 +++++++ lib/vagrant-lxc/provider/cap/public_address.rb | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 lib/vagrant-lxc/provider/cap/public_address.rb diff --git a/lib/vagrant-lxc/plugin.rb b/lib/vagrant-lxc/plugin.rb index bb29817..f489773 100644 --- a/lib/vagrant-lxc/plugin.rb +++ b/lib/vagrant-lxc/plugin.rb @@ -30,6 +30,13 @@ module Vagrant SyncedFolder end end + + if Vagrant::Backports.vagrant_1_5_or_later? + provider_capability("lxc", "public_address") do + require_relative "provider/cap/public_address" + Provider::Cap::PublicAddress + end + end end end end diff --git a/lib/vagrant-lxc/provider/cap/public_address.rb b/lib/vagrant-lxc/provider/cap/public_address.rb new file mode 100644 index 0000000..1c8fc8a --- /dev/null +++ b/lib/vagrant-lxc/provider/cap/public_address.rb @@ -0,0 +1,17 @@ +module Vagrant + module LXC + class Provider + module Cap + module PublicAddress + def self.public_address(machine) + return nil if machine.state.id != :running + + ssh_info = machine.ssh_info + return nil if !ssh_info + ssh_info[:host] + end + end + end + end + end +end