From 55abd327eb878a1f44e38c9170f6eb74b7116352 Mon Sep 17 00:00:00 2001 From: "Zak B. Elep" Date: Fri, 16 Aug 2019 17:55:02 +0800 Subject: [PATCH] Add public_address provider capability Used by vagrant-share plugin to determine local guest address for forwarding via ngrok. --- lib/vagrant-libvirt/cap/public_address.rb | 16 ++++++++++++++++ lib/vagrant-libvirt/plugin.rb | 5 +++++ 2 files changed, 21 insertions(+) create mode 100644 lib/vagrant-libvirt/cap/public_address.rb diff --git a/lib/vagrant-libvirt/cap/public_address.rb b/lib/vagrant-libvirt/cap/public_address.rb new file mode 100644 index 0000000..57352e4 --- /dev/null +++ b/lib/vagrant-libvirt/cap/public_address.rb @@ -0,0 +1,16 @@ +module VagrantPlugins + module ProviderLibvirt + module Cap + class PublicAddress + def self.public_address(machine) + # This does not need to be a globally routable address, it + # only needs to be accessible from the machine running + # Vagrant. + ssh_info = machine.ssh_info + return nil if !ssh_info + ssh_info[:host] + end + end + end + end +end diff --git a/lib/vagrant-libvirt/plugin.rb b/lib/vagrant-libvirt/plugin.rb index 8f7e85d..5d14445 100644 --- a/lib/vagrant-libvirt/plugin.rb +++ b/lib/vagrant-libvirt/plugin.rb @@ -39,6 +39,11 @@ module VagrantPlugins Cap::NicMacAddresses end + provider_capability(:libvirt, :public_address) do + require_relative 'cap/public_address' + Cap::PublicAddress + end + # lower priority than nfs or rsync # https://github.com/vagrant-libvirt/vagrant-libvirt/pull/170 synced_folder('9p', 4) do