From 7b5e5668c5a91b6e4c36a6e50302af940c0cb4ae Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 24 Oct 2014 15:47:37 -0700 Subject: [PATCH] core: add option to not lock for Machine#action [GH-4574] --- CHANGELOG.md | 2 ++ lib/vagrant/machine.rb | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0244c6cac..2c614cc3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,8 @@ BUG FIXES: PLUGIN AUTHOR CHANGES: + - `Machine#action` can be called with the option `lock: false` to not + acquire a machine lock. - `Machine#reload` will now properly trigger the `machine_id_changed` callback on providers. diff --git a/lib/vagrant/machine.rb b/lib/vagrant/machine.rb index e7e7eea97..6adb5a793 100644 --- a/lib/vagrant/machine.rb +++ b/lib/vagrant/machine.rb @@ -144,9 +144,12 @@ module Vagrant # @param [Hash] extra_env This data will be passed into the action runner # as extra data set on the environment hash for the middleware # runner. - def action(name, extra_env=nil) + def action(name, extra_env=nil, **opts) @logger.info("Calling action: #{name} on provider #{@provider}") + # Default to locking + opts[:lock] = true if !opts.has_key?(:lock) + # Create a deterministic ID for this machine vf = nil vf = @env.vagrantfile_name[0] if @env.vagrantfile_name @@ -157,7 +160,7 @@ module Vagrant # we will want to do more fine-grained unlocking in actions themselves # but for a 1.6.2 release this will work. locker = Proc.new { |*args, &block| block.call } - locker = @env.method(:lock) if !name.to_s.start_with?("ssh") + locker = @env.method(:lock) if opts[:lock] && !name.to_s.start_with?("ssh") # Lock this machine for the duration of this action locker.call("machine-action-#{id}") do