Get parents chain from guest plugin

This commit is contained in:
sophia 2021-08-26 15:37:41 -05:00 committed by Paul Hinze
parent 34637c616e
commit 29f14c98b7
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0

View File

@ -64,15 +64,26 @@ module VagrantPlugins
)
end
def get_parent_chain(plugin_name)
chain = [plugin_name]
plugins = Vagrant.plugin("2").manager.guests[plugin_name.to_s.to_sym].to_a
if plugins.last.nil?
return chain
else
chain + get_parent_chain(plugins.last)
end
end
def parents(req, ctx)
ServiceInfo.with_info(ctx) do |info|
plugin_name = info.plugin_name
plugin = Vagrant.plugin("2").manager.guests[plugin_name.to_s.to_sym].to_a.first
if !plugin
plugin = Vagrant.plugin("2").manager.guests[plugin_name.to_s.to_sym].to_a
if !plugin.first
raise "Failed to locate guest plugin for: #{plugin_name.inspect}"
end
guest_chain = get_parent_chain(plugin_name.to_s.to_sym)
SDK::Platform::ParentsResp.new(
parents: plugin.new.cap_host_chain
parents: guest_chain
)
end
end