diff --git a/lib/vagrant/plugin/v2/host.rb b/lib/vagrant/plugin/v2/host.rb index f00ddf3d1..ae02f8dde 100644 --- a/lib/vagrant/plugin/v2/host.rb +++ b/lib/vagrant/plugin/v2/host.rb @@ -13,6 +13,25 @@ module Vagrant def detect?(env) false end + + # Returns list of parents for + # this host + # + # @return [Array] + def parents + hosts = Vagrant.plugin("2").manager.hosts.to_hash + ancestors = [] + n, entry = hosts.detect { |_, v| v.first == self.class } + while n + n = nil + if entry.last + ancestors << entry.last + entry = hosts[entry.last] + n = entry.last + end + end + ancestors + end end end end