No more logger usage for outputting to the shell
This commit is contained in:
parent
b21fae99c5
commit
a699122260
|
@ -55,11 +55,11 @@ module Vagrant
|
||||||
# chain has been run.
|
# chain has been run.
|
||||||
int_callback = lambda do
|
int_callback = lambda do
|
||||||
if action_environment.interrupted?
|
if action_environment.interrupted?
|
||||||
env.logger.info "Exiting immediately!"
|
env.ui.info "Exiting immediately!"
|
||||||
abort
|
abort
|
||||||
end
|
end
|
||||||
|
|
||||||
env.logger.info "Waiting for cleanup before exiting..."
|
env.ui.info "Waiting for cleanup before exiting..."
|
||||||
action_environment.error!(:interrupt)
|
action_environment.error!(:interrupt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ module Vagrant
|
||||||
# Progress reporting is limited to every 25 segments just so
|
# Progress reporting is limited to every 25 segments just so
|
||||||
# we're not constantly updating
|
# we're not constantly updating
|
||||||
if segment_count % 25 == 0
|
if segment_count % 25 == 0
|
||||||
env.logger.report_progress(progress, total)
|
env.ui.report_progress(progress, total)
|
||||||
segment_count = 0
|
segment_count = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,8 +45,6 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
env.logger.clear_progress
|
|
||||||
rescue SocketError
|
rescue SocketError
|
||||||
env.error!(:box_download_http_socket_error, :box_url => source_url)
|
env.error!(:box_download_http_socket_error, :box_url => source_url)
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,7 +25,7 @@ module Vagrant
|
||||||
|
|
||||||
# The sleep ensures that the output is truly flushed before any `sudo`
|
# The sleep ensures that the output is truly flushed before any `sudo`
|
||||||
# commands are issued.
|
# commands are issued.
|
||||||
env.logger.info "Preparing to edit /etc/exports. Administrator priveleges will be required..."
|
env.ui.info "Preparing to edit /etc/exports. Administrator priveleges will be required..."
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
|
|
||||||
output.split("\n").each do |line|
|
output.split("\n").each do |line|
|
||||||
|
|
|
@ -24,7 +24,7 @@ module Vagrant
|
||||||
:ip => ip,
|
:ip => ip,
|
||||||
:folders => folders)
|
:folders => folders)
|
||||||
|
|
||||||
env.logger.info "Preparing to edit /etc/exports. Administrator priveleges will be required..."
|
env.ui.info "Preparing to edit /etc/exports. Administrator priveleges will be required..."
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
|
|
||||||
output.split("\n").each do |line|
|
output.split("\n").each do |line|
|
||||||
|
|
|
@ -30,12 +30,6 @@ module Vagrant
|
||||||
env.vm
|
env.vm
|
||||||
end
|
end
|
||||||
|
|
||||||
# This method returns the environment's logger as a convenience
|
|
||||||
# method.
|
|
||||||
def logger
|
|
||||||
env.logger
|
|
||||||
end
|
|
||||||
|
|
||||||
# This is the method called to "prepare" the provisioner. This is called
|
# This is the method called to "prepare" the provisioner. This is called
|
||||||
# before any actions are run by the action runner (see {Vagrant::Actions::Runner}).
|
# before any actions are run by the action runner (see {Vagrant::Actions::Runner}).
|
||||||
# This can be used to setup shared folders, forward ports, etc. Whatever is
|
# This can be used to setup shared folders, forward ports, etc. Whatever is
|
||||||
|
|
|
@ -85,7 +85,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def chown_provisioning_folder
|
def chown_provisioning_folder
|
||||||
logger.info "Setting permissions on chef provisioning folder..."
|
env.ui.info "Setting permissions on chef provisioning folder..."
|
||||||
vm.ssh.execute do |ssh|
|
vm.ssh.execute do |ssh|
|
||||||
ssh.exec!("sudo mkdir -p #{env.config.chef.provisioning_path}")
|
ssh.exec!("sudo mkdir -p #{env.config.chef.provisioning_path}")
|
||||||
ssh.exec!("sudo chown #{env.config.ssh.username} #{env.config.chef.provisioning_path}")
|
ssh.exec!("sudo chown #{env.config.ssh.username} #{env.config.chef.provisioning_path}")
|
||||||
|
@ -97,12 +97,12 @@ module Vagrant
|
||||||
:log_level => env.config.chef.log_level.to_sym
|
:log_level => env.config.chef.log_level.to_sym
|
||||||
}.merge(template_vars))
|
}.merge(template_vars))
|
||||||
|
|
||||||
logger.info "Uploading chef configuration script..."
|
env.ui.info "Uploading chef configuration script..."
|
||||||
vm.ssh.upload!(StringIO.new(config_file), File.join(env.config.chef.provisioning_path, filename))
|
vm.ssh.upload!(StringIO.new(config_file), File.join(env.config.chef.provisioning_path, filename))
|
||||||
end
|
end
|
||||||
|
|
||||||
def setup_json
|
def setup_json
|
||||||
logger.info "Generating chef JSON and uploading..."
|
env.ui.info "Generating chef JSON and uploading..."
|
||||||
|
|
||||||
# Set up initial configuration
|
# Set up initial configuration
|
||||||
data = {
|
data = {
|
||||||
|
|
|
@ -26,7 +26,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_client_key_folder
|
def create_client_key_folder
|
||||||
logger.info "Creating folder to hold client key..."
|
env.ui.info "Creating folder to hold client key..."
|
||||||
path = Pathname.new(env.config.chef.client_key_path)
|
path = Pathname.new(env.config.chef.client_key_path)
|
||||||
|
|
||||||
vm.ssh.execute do |ssh|
|
vm.ssh.execute do |ssh|
|
||||||
|
@ -35,7 +35,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload_validation_key
|
def upload_validation_key
|
||||||
logger.info "Uploading chef client validation key..."
|
env.ui.info "Uploading chef client validation key..."
|
||||||
vm.ssh.upload!(validation_key_path, guest_validation_key_path)
|
vm.ssh.upload!(validation_key_path, guest_validation_key_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -52,13 +52,13 @@ module Vagrant
|
||||||
def run_chef_client
|
def run_chef_client
|
||||||
command = "cd #{env.config.chef.provisioning_path} && sudo -E chef-client -c client.rb -j dna.json"
|
command = "cd #{env.config.chef.provisioning_path} && sudo -E chef-client -c client.rb -j dna.json"
|
||||||
|
|
||||||
logger.info "Running chef-client..."
|
env.ui.info "Running chef-client..."
|
||||||
vm.ssh.execute do |ssh|
|
vm.ssh.execute do |ssh|
|
||||||
ssh.exec!(command) do |channel, type, data|
|
ssh.exec!(command) do |channel, type, data|
|
||||||
if type == :exit_status
|
if type == :exit_status
|
||||||
ssh.check_exit_status(data, command)
|
ssh.check_exit_status(data, command)
|
||||||
else
|
else
|
||||||
logger.info("#{data}: #{type}")
|
env.ui.info("#{data}: #{type}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,11 +40,11 @@ module Vagrant
|
||||||
def run_chef_solo
|
def run_chef_solo
|
||||||
command = "cd #{env.config.chef.provisioning_path} && sudo -E chef-solo -c solo.rb -j dna.json"
|
command = "cd #{env.config.chef.provisioning_path} && sudo -E chef-solo -c solo.rb -j dna.json"
|
||||||
|
|
||||||
logger.info "Running chef-solo..."
|
env.ui.info "Running chef-solo..."
|
||||||
vm.ssh.execute do |ssh|
|
vm.ssh.execute do |ssh|
|
||||||
ssh.exec!(command) do |channel, type, data|
|
ssh.exec!(command) do |channel, type, data|
|
||||||
ssh.check_exit_status(data, command) if type == :exit_status
|
ssh.check_exit_status(data, command) if type == :exit_status
|
||||||
logger.info("#{data}: #{type}") if type != :exit_status
|
env.ui.info("#{data}: #{type}") if type != :exit_status
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -118,7 +118,7 @@ module Vagrant
|
||||||
stat = File.stat(key_path)
|
stat = File.stat(key_path)
|
||||||
|
|
||||||
if stat.owned? && file_perms(key_path) != "600"
|
if stat.owned? && file_perms(key_path) != "600"
|
||||||
env.logger.info "Permissions on private key incorrect, fixing..."
|
env.ui.info "Permissions on private key incorrect, fixing..."
|
||||||
File.chmod(0600, key_path)
|
File.chmod(0600, key_path)
|
||||||
|
|
||||||
error_and_exit(:ssh_bad_permissions, :key_path => key_path) if file_perms(key_path) != "600"
|
error_and_exit(:ssh_bad_permissions, :key_path => key_path) if file_perms(key_path) != "600"
|
||||||
|
|
|
@ -27,12 +27,6 @@ module Vagrant
|
||||||
@vm = vm
|
@vm = vm
|
||||||
end
|
end
|
||||||
|
|
||||||
# A convenience method to access the logger on the VM
|
|
||||||
# environment.
|
|
||||||
def logger
|
|
||||||
vm.env.logger
|
|
||||||
end
|
|
||||||
|
|
||||||
# Halt the machine. This method should gracefully shut down the
|
# Halt the machine. This method should gracefully shut down the
|
||||||
# operating system. This method will cause `vagrant halt` and associated
|
# operating system. This method will cause `vagrant halt` and associated
|
||||||
# commands to _block_, meaning that if the machine doesn't halt
|
# commands to _block_, meaning that if the machine doesn't halt
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Vagrant
|
||||||
# Overridden methods
|
# Overridden methods
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
def halt
|
def halt
|
||||||
logger.info "Attempting graceful shutdown of linux..."
|
vm.env.ui.info "Attempting graceful shutdown of linux..."
|
||||||
vm.ssh.execute do |ssh|
|
vm.ssh.execute do |ssh|
|
||||||
ssh.exec!("sudo halt")
|
ssh.exec!("sudo halt")
|
||||||
end
|
end
|
||||||
|
@ -66,7 +66,7 @@ module Vagrant
|
||||||
def prepare_unison(ssh)
|
def prepare_unison(ssh)
|
||||||
ssh.exec!("which unison", :error_key => :unison_not_found)
|
ssh.exec!("which unison", :error_key => :unison_not_found)
|
||||||
|
|
||||||
logger.info "Preparing system for unison sync..."
|
vm.env.ui.info "Preparing system for unison sync..."
|
||||||
vm.ssh.upload!(StringIO.new(TemplateRenderer.render('/unison/script')), config.unison.script)
|
vm.ssh.upload!(StringIO.new(TemplateRenderer.render('/unison/script')), config.unison.script)
|
||||||
ssh.exec!("sudo chmod +x #{config.unison.script}")
|
ssh.exec!("sudo chmod +x #{config.unison.script}")
|
||||||
ssh.exec!("sudo rm #{config.unison.crontab_entry_file}", :error_check => false)
|
ssh.exec!("sudo rm #{config.unison.crontab_entry_file}", :error_check => false)
|
||||||
|
|
|
@ -15,16 +15,10 @@ class DestroyBoxActionTest < Test::Unit::TestCase
|
||||||
@instance = @klass.new(@app, @env)
|
@instance = @klass.new(@app, @env)
|
||||||
end
|
end
|
||||||
|
|
||||||
context "calling" do
|
|
||||||
setup do
|
|
||||||
@env.logger.stubs(:info)
|
|
||||||
end
|
|
||||||
|
|
||||||
should "delete the box directory" do
|
should "delete the box directory" do
|
||||||
seq = sequence("seq")
|
seq = sequence("seq")
|
||||||
FileUtils.expects(:rm_rf).with(@env["box"].directory).in_sequence(seq)
|
FileUtils.expects(:rm_rf).with(@env["box"].directory).in_sequence(seq)
|
||||||
@app.expects(:call).with(@env).once.in_sequence(seq)
|
@app.expects(:call).with(@env).once.in_sequence(seq)
|
||||||
@instance.call(@env)
|
@instance.call(@env)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,10 +16,6 @@ class VerifyBoxActionTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
context "calling" do
|
context "calling" do
|
||||||
setup do
|
|
||||||
@env.logger.stubs(:info)
|
|
||||||
end
|
|
||||||
|
|
||||||
should "continue fine if verification succeeds" do
|
should "continue fine if verification succeeds" do
|
||||||
seq = sequence("seq")
|
seq = sequence("seq")
|
||||||
VirtualBox::Appliance.expects(:new).with(@env["box"].ovf_file).in_sequence(seq)
|
VirtualBox::Appliance.expects(:new).with(@env["box"].ovf_file).in_sequence(seq)
|
||||||
|
|
|
@ -5,7 +5,6 @@ class BSDHostTest < Test::Unit::TestCase
|
||||||
@klass = Vagrant::Hosts::BSD
|
@klass = Vagrant::Hosts::BSD
|
||||||
@env = mock_environment
|
@env = mock_environment
|
||||||
@env.stubs(:vm).returns(Vagrant::VM.new(:env => @env))
|
@env.stubs(:vm).returns(Vagrant::VM.new(:env => @env))
|
||||||
@env.logger.stubs(:info)
|
|
||||||
|
|
||||||
@instance = @klass.new(@env)
|
@instance = @klass.new(@env)
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,6 @@ class LinuxHostTest < Test::Unit::TestCase
|
||||||
@klass = Vagrant::Hosts::Linux
|
@klass = Vagrant::Hosts::Linux
|
||||||
@env = mock_environment
|
@env = mock_environment
|
||||||
@env.stubs(:vm).returns(Vagrant::VM.new(:env => @env))
|
@env.stubs(:vm).returns(Vagrant::VM.new(:env => @env))
|
||||||
@env.logger.stubs(:info)
|
|
||||||
|
|
||||||
@instance = @klass.new(@env)
|
@instance = @klass.new(@env)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue