Created
September 21, 2016 15:19
-
-
Save dhollinger/c249f8ad64413a710f6b843b9619feb9 to your computer and use it in GitHub Desktop.
Beaker Openstack Floating IP Current gem vs Upstream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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