diff --git a/source/lib/vagrant-openstack-provider/config_resolver.rb b/source/lib/vagrant-openstack-provider/config_resolver.rb index 2b6ac7b..e3b2da4 100644 --- a/source/lib/vagrant-openstack-provider/config_resolver.rb +++ b/source/lib/vagrant-openstack-provider/config_resolver.rb @@ -3,6 +3,7 @@ module Openstack class ConfigResolver def initialize @logger = Log4r::Logger.new('vagrant_openstack::action::config_resolver') + @mutex = Mutex.new end def resolve_ssh_port(env) @@ -159,14 +160,16 @@ def resolve_image_internal(env, image_name) end def search_free_ip(config, nova, env) - @logger.debug 'Retrieving all allocated floating ips on tenant' - all_floating_ips = nova.get_all_floating_ips(env) - all_floating_ips.each do |floating_ip| - log_attach = floating_ip.instance_id ? "attached to #{floating_ip.instance_id}" : 'not attached' - @logger.debug "#{floating_ip.ip} #{log_attach}" if config.floating_ip_pool.include? floating_ip.pool - return floating_ip.ip if (config.floating_ip_pool.include? floating_ip.pool) && floating_ip.instance_id.nil? - end unless config.floating_ip_pool_always_allocate - @logger.debug 'No free ip found' + @mutex.synchronize do + @logger.debug 'Retrieving all allocated floating ips on tenant' + all_floating_ips = nova.get_all_floating_ips(env) + all_floating_ips.each do |floating_ip| + log_attach = floating_ip.instance_id ? "attached to #{floating_ip.instance_id}" : 'not attached' + @logger.debug "#{floating_ip.ip} #{log_attach}" if config.floating_ip_pool.include? floating_ip.pool + return floating_ip.ip if (config.floating_ip_pool.include? floating_ip.pool) && floating_ip.instance_id.nil? + end unless config.floating_ip_pool_always_allocate + @logger.debug 'No free ip found' + end nil end diff --git a/source/lib/vagrant-openstack-provider/plugin.rb b/source/lib/vagrant-openstack-provider/plugin.rb index 1b70b9a..5478d1e 100644 --- a/source/lib/vagrant-openstack-provider/plugin.rb +++ b/source/lib/vagrant-openstack-provider/plugin.rb @@ -25,7 +25,7 @@ class Plugin < Vagrant.plugin('2') Config end - provider(:openstack, box_optional: true) do + provider(:openstack, box_optional: true, parallel: true) do Openstack.init_i18n Openstack.init_logging VagrantPlugins::Openstack.check_version