Skip to content

Commit

Permalink
Merge pull request #339 from ephracis/130-parallel
Browse files Browse the repository at this point in the history
Enable parallel actions
  • Loading branch information
ggiamarchi authored Oct 24, 2017
2 parents 11e7cad + 1400dea commit d28cf69
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
19 changes: 11 additions & 8 deletions source/lib/vagrant-openstack-provider/config_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion source/lib/vagrant-openstack-provider/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d28cf69

Please sign in to comment.