From f1e2a73bfa3d722e2a908c133ce6a966027dc60b Mon Sep 17 00:00:00 2001 From: sophia Date: Tue, 24 Aug 2021 16:10:31 -0500 Subject: [PATCH] Don't use just a client to instantiate a machine --- lib/vagrant/machine.rb | 2 +- lib/vagrant/machine/remote.rb | 65 ++++++++++++++++------------------- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index f4bc65639..3c17b4e00 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -97,7 +97,7 @@ module Vagrant # @param [Box] box The box that is backing this virtual machine. # @param [Environment] env The environment that this machine is a # part of. - def initialize(name, provider_name, provider_cls, provider_config, provider_options, config, data_dir, box, env, vagrantfile, base=false, client=nil) + def initialize(name, provider_name, provider_cls, provider_config, provider_options, config, data_dir, box, env, vagrantfile, base=false) @logger = Log4r::Logger.new("vagrant::machine") @logger.info("Initializing machine: #{name}") @logger.info(" - Provider: #{provider_cls}") diff --git a/lib/vagrant/machine/remote.rb b/lib/vagrant/machine/remote.rb index 536d54994..3273e4780 100644 --- a/lib/vagrant/machine/remote.rb +++ b/lib/vagrant/machine/remote.rb @@ -26,47 +26,42 @@ module Vagrant # @param [Box] box The box that is backing this virtual machine. # @param [Environment] env The environment that this machine is a # part of. - def initialize(name, provider_name, provider_cls, provider_config, provider_options, config, data_dir, box, env, vagrantfile, base=false, client=nil) + def initialize(name, provider_name, provider_cls, provider_config, provider_options, config, data_dir, box, env, vagrantfile, base=false) @logger = Log4r::Logger.new("vagrant::machine") - @logger.debug("building machine (remote) with client #{client}") - if !client.nil? - @client = client - else - @client = env.get_target(name) - @env = env - @ui = Vagrant::UI::Prefixed.new(@env.ui, name) + @client = env.get_target(name) + @env = env + @ui = Vagrant::UI::Prefixed.new(@env.ui, name) - # TODO: Get provider info from client - @provider_name = provider_name - @provider = provider_cls.new(self) - @provider._initialize(provider_name, self) - @provider_options = provider_options - @provider_config = provider_config + # TODO: Get provider info from client + @provider_name = provider_name + @provider = provider_cls.new(self) + @provider._initialize(provider_name, self) + @provider_options = provider_options + @provider_config = provider_config - #TODO: get box from @client.get_box() - @box = box - @config = config - @data_dir = @client.data_dir - @vagrantfile = vagrantfile - @name = name - @ui_mutex = Mutex.new - @state_mutex = Mutex.new - @triggers = Vagrant::Plugin::V2::Trigger.new(@env, @config.trigger, self, @ui) + #TODO: get box from @client.get_box() + @box = box + @config = config + @data_dir = @client.data_dir + @vagrantfile = vagrantfile + @name = name + @ui_mutex = Mutex.new + @state_mutex = Mutex.new + @triggers = Vagrant::Plugin::V2::Trigger.new(@env, @config.trigger, self, @ui) - # Keep track of where our UUID should be placed - @index_uuid_file = nil - @index_uuid_file = @data_dir.join("index_uuid") if @data_dir + # Keep track of where our UUID should be placed + @index_uuid_file = nil + @index_uuid_file = @data_dir.join("index_uuid") if @data_dir - # If the ID is the special not created ID, then set our ID to - # nil so that we destroy all our data. - # if state.id == MachineState::NOT_CREATED_ID - # self.id = nil - # end + # If the ID is the special not created ID, then set our ID to + # nil so that we destroy all our data. + # if state.id == MachineState::NOT_CREATED_ID + # self.id = nil + # end - # Output a bunch of information about this machine in - # machine-readable format in case someone is listening. - @ui.machine("metadata", "provider", provider_name) - end + # Output a bunch of information about this machine in + # machine-readable format in case someone is listening. + @ui.machine("metadata", "provider", provider_name) end # @return [Box]