From 02a06bca45c315dd04d27385b4ed96f768f62696 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Mon, 16 May 2022 16:50:19 -0500 Subject: [PATCH] Fixes for provider capability invocations It looks like I might have been the first to hit provider cabability invocation in testing these changes, and so I found these few missing methods on the client. They're just copied over from the other capability hosts. Calling capabilities on a provider also revealed that the wrong Machine type was being pulled out of the funcspec args, so we had to correct that too in order to get the capability calls working. --- lib/vagrant/plugin/remote/provider.rb | 19 +++++++++++++++++++ .../serve/service/provider_service.rb | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/plugin/remote/provider.rb b/lib/vagrant/plugin/remote/provider.rb index d889e6aa8..6eb8c7f85 100644 --- a/lib/vagrant/plugin/remote/provider.rb +++ b/lib/vagrant/plugin/remote/provider.rb @@ -31,6 +31,25 @@ module Vagrant client.action(@machine.to_proto, name) end + # Executes the capability with the given name, optionally passing more + # arguments onwards to the capability. If the capability returns a value, + # it will be returned. + # + # @param [Symbol] cap_name Name of the capability + def capability(cap_name, *args) + @logger.debug("running remote provider capability #{cap_name} with args #{args}") + client.capability(cap_name, *args) + end + + # Tests whether the given capability is possible. + # + # @param [Symbol] cap_name Capability name + # @return [Boolean] + def capability?(cap_name) + @logger.debug("checking for remote provider capability #{cap_name}") + client.has_capability?(cap_name) + end + def machine_id_changed client.machine_id_changed(@machine.to_proto) end diff --git a/plugins/commands/serve/service/provider_service.rb b/plugins/commands/serve/service/provider_service.rb index d65661afc..c05d8c34f 100644 --- a/plugins/commands/serve/service/provider_service.rb +++ b/plugins/commands/serve/service/provider_service.rb @@ -9,7 +9,7 @@ module VagrantPlugins super caps = Vagrant.plugin("2").local_manager.provider_capabilities default_args = { - Client::Target::Machine => SDK::Args::Target::Machine + Vagrant::Machine => SDK::Args::Target::Machine } initialize_capability_platform!(caps, default_args) end