From cadcbe82f784c4e4d8654991eee971faef9ad736 Mon Sep 17 00:00:00 2001 From: sophia Date: Thu, 21 Jan 2021 16:26:15 -0600 Subject: [PATCH] Hard code less --- lib/vagrant/machine.rb | 30 +++++++++++-------- .../serve/service/provider_service.rb | 8 ----- 2 files changed, 17 insertions(+), 21 deletions(-) diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index 4faf949ef..e8df1480c 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -76,12 +76,16 @@ module Vagrant machine: machine_ref ) resp = @client.datadir(req) - Pathname.new(resp.datadir.data_dir) + resp.datadir end - # TODO def get_local_data_path(id) - nil + machine_ref = Hashicorp::Vagrant::Sdk::Ref::Machine.new(resource_id: id) + req = Hashicorp::Vagrant::Sdk::Machine::LocalDataPathRequest.new( + machine: machine_ref + ) + resp = @client.localdatapath(req) + resp.path end def get_provider(id) @@ -93,7 +97,6 @@ module Vagrant resp end - def get_vagrantfile_name(id) machine_ref = Hashicorp::Vagrant::Sdk::Ref::Machine.new(resource_id: id) req = Hashicorp::Vagrant::Sdk::Machine::VagrantfileNameRequest.new( @@ -130,13 +133,16 @@ module Vagrant provider_plugin = Vagrant.plugin("2").manager.providers[:virtualbox] provider_cls = provider_plugin[0] provider_options = provider_plugin[1] - + + datadir = get_data_dir(id) + vagrantfile_name = get_vagrantfile_name(id) + vagrantfile_path = get_vagrantfile_path(id) env = Vagrant::Environment.new( - cwd: "/Users/sophia/project/vagrant-agogo", - home_path: "/Users/sophia/.vagrant.d", + cwd: vagrantfile_path, # TODO: this is probably not ideal + home_path: datadir.root_dir, ui_class: Vagrant::UI::RemoteUI, ui_opts: [ui_client], - vagrantfile_name: "Vagrantfile", + vagrantfile_name: vagrantfile_name, ) Machine.new( @@ -276,17 +282,15 @@ module Vagrant # # @return [Pathname] def data_dir - @client.get_data_dir(@machine_id) + dd = @client.get_data_dir(@machine_id) + Pathname.new(dd.data_dir) end # The Vagrantfile that this machine is attached to. # # @return [Vagrantfile] def vagrantfile - path = @client.get_vagrantfile_path(@machine_id) - filename = @client.get_vagrantfile_name(@machine_id) - vagrantfile_path = path.join(filename) - # TODO: get vagrantfile parsed and return Vagrantfile + # TODO end # This calls an action on the provider. The provider may or may not diff --git a/plugins/commands/serve/service/provider_service.rb b/plugins/commands/serve/service/provider_service.rb index c5ac6b66f..5e9d2943b 100644 --- a/plugins/commands/serve/service/provider_service.rb +++ b/plugins/commands/serve/service/provider_service.rb @@ -38,13 +38,6 @@ module VagrantPlugins LOG.debug("Coming up") machine = machine_arg_to_machine(req) machine.ui.warn("hello from vagrant") - - # ba = Vagrant::BatchAction.new - # LOG.debug("registering action") - # ba.action(machine, :up) - # LOG.debug("running action") - # ba.run - # LOG.debug("up?!") Hashicorp::Vagrant::Sdk::Provider::ActionResp.new(success: true) end @@ -61,7 +54,6 @@ module VagrantPlugins machine = mclient.get_machine(machine_arg.resource_id, ui_client) LOG.debug("got machine: ") LOG.debug(machine.name) - LOG.debug("using provider: " + machine.provider_name) machine end