From a25381b03a7e6eac6acaa01010fac1c008f17a67 Mon Sep 17 00:00:00 2001 From: sophia Date: Thu, 7 Jan 2021 17:14:36 -0600 Subject: [PATCH] Get the associated requested provider --- lib/vagrant/machine.rb | 13 +++++++++---- plugins/commands/serve/service/provider_service.rb | 4 +--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 4180882d8..34aea8c3d 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -31,9 +31,14 @@ module Vagrant ) resp_machine = @client.get_machine(req) m = resp_machine.machine + + provider_plugin = Vagrant.plugin("2").manager.providers[m.provider_name.to_sym] + provider_cls = provider_plugin[0] + provider_options = provider_plugin[1] + Machine.new( - m.name, m.provider_name, m.provider, - m.provider_config, m.provider_options, m.config, + m.name, m.provider_name, provider_cls, + m.provider_config, provider_options, m.config, m.data_dir, m.box, m.env, m.vagrantfile, base=false, client=@client ) @@ -186,8 +191,8 @@ module Vagrant # Initializes the provider last so that it has access to all the # state we setup on this machine. # TODO: renable provider - # @provider = provider_cls.new(self) - # @provider._initialize(@provider_name, self) + @provider = provider_cls.new(self) + @provider._initialize(@provider_name, self) # If we're using WinRM, we eager load the plugin because of # GH-3390 diff --git a/plugins/commands/serve/service/provider_service.rb b/plugins/commands/serve/service/provider_service.rb index e38095cbf..5e3027e8e 100644 --- a/plugins/commands/serve/service/provider_service.rb +++ b/plugins/commands/serve/service/provider_service.rb @@ -35,14 +35,12 @@ module VagrantPlugins end def action_up(req, _unused_call) - LOG.debug("action up") machine = machine_arg_to_machine(req) LOG.debug(machine) end def machine_arg_to_machine(req) raw_machine_arg = req.args[0].value.value - LOG.debug("decoding") machine_arg = Hashicorp::Vagrant::Sdk::Args::Machine.decode(raw_machine_arg) LOG.debug("machine id: " + machine_arg.machineId) LOG.debug("server addr: " + machine_arg.serverAddr) @@ -50,11 +48,11 @@ module VagrantPlugins mclient = Vagrant::MachineClient.new(machine_arg.serverAddr) machine = mclient.get_machine(machine_arg.machineId) LOG.debug("got machine: " + machine.name) + LOG.debug("using provider: " + machine.provider_name) machine end def action_up_spec(req, _unused_call) - LOG.debug("action up spec") args = [ Hashicorp::Vagrant::Sdk::FuncSpec::Value.new( type: "hashicorp.vagrant.sdk.Args.Machine",