Add parents method to host plugin

This commit is contained in:
Chris Roberts 2021-07-20 15:51:27 -07:00 committed by Paul Hinze
parent 9379f1beb3
commit 8771e6078f
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -13,6 +13,25 @@ module Vagrant
def detect?(env)
false
end
# Returns list of parents for
# this host
#
# @return [Array<Symbol>]
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