Skip to content

Instantly share code, notes, and snippets.

@dhollinger
Created September 21, 2016 15:19
Show Gist options
  • Save dhollinger/c249f8ad64413a710f6b843b9619feb9 to your computer and use it in GitHub Desktop.
Save dhollinger/c249f8ad64413a710f6b843b9619feb9 to your computer and use it in GitHub Desktop.
Beaker Openstack Floating IP Current gem vs Upstream
def get_ip
ip = @compute_client.addresses.find { |ip| ip.instance_id.nil? }
if ip.nil?
@logger.debug "Creating IP"
ip = @compute_client.addresses.create
end
ip
end
def get_ip
@logger.debug "Finding IP"
ip = @compute_client.addresses.find { |ip| ip.instance_id.nil? }
if ip.nil?
begin
@logger.debug "Creating IP"
ip = @compute_client.addresses.create
rescue Fog::Compute::OpenStack::NotFound
# If there are no more floating IP addresses, allocate a
# new one and try again.
@compute_client.allocate_address(@options[:floating_ip_pool])
ip = @compute_client.addresses.find { |ip| ip.instance_id.nil? }
end
end
raise 'Could not find or allocate an address' if not ip
ip
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment