lib/poolparty/net/remoter_bases/ec2/ec2.rb
def next_unused_elastic_ip
        # [{"instanceId"=>nil, "publicIp"=>"174.129.212.93"}, {"instanceId"=>nil, "publicIp"=>"174.129.212.94"}]
        if addressesSet = ec2(options).describe_addresses["addressesSet"]
          begin
            empty_addresses = addressesSet["item"].select {|i| i["instanceId"].nil? }
            ips = empty_addresses.map {|addr| addr["publicIp"]}
            if cloud.elastic_ips?
              ips_to_use = cloud.elastic_ips & ips
              ips_to_use.first
            else
              ips.first
            end
          rescue Exception => e
            puts "Error: #{e}"
            nil
          end          
        end
      end
# Get the next usable elastic ip
# First, get the list of addresses from ec2 that the client
# has access to, then select only the ones that are not associated
# with an instance.
# If the cloud has set elastic_ips to use, then, using the 
# intersection of the unused ips and those, find the first one available
# and return that, otherwise, return the first elastic ip available
Get the next usable elastic ip
First, get the list of addresses from ec2 that the client
has access to, then select only the ones that are not associated
with an instance.
If the cloud has set elastic_ips to use, then, using the
intersection of the unused ips and those, find the first one available
and return that, otherwise, return the first elastic ip available
Get the next usable elastic ip First get the list of addresses from ec2 that the client has access to then select only the ones that are not associated with an instance . If the cloud has set elastic_ips to use then using the intersection of the unused ips and those find the first one available and return that otherwise return the first elastic ip available
def next_unused_elastic_ip
        if addressesSet = ec2(options).describe_addresses["addressesSet"]
          begin
            empty_addresses = addressesSet["item"].select {|i| i["instanceId"].nil? }
            ips = empty_addresses.map {|addr| addr["publicIp"]}
            if cloud.elastic_ips?
              ips_to_use = cloud.elastic_ips & ips
              ips_to_use.first
            else
              ips.first
            end
          rescue Exception => e
            puts "Error: #{e}"
            nil
          end          
        end
      end
def next_unused_elastic_ip if addressesSet = ec2 ( options ) . describe_addresses [ "addressesSet" ] begin empty_addresses = addressesSet [ "item" ] . select { | i | i [ "instanceId" ] . nil? } ips = empty_addresses . map { | addr | addr [ "publicIp" ] } if cloud . elastic_ips? ips_to_use = cloud . elastic_ips & ips ips_to_use . first else ips . first end rescue Exception => e puts "Error: #{e}" nil end end end
Get the next usable elastic ip
First, get the list of addresses from ec2 that the client
has access to, then select only the ones that are not associated
with an instance.
Get the next usable elastic ip First get the list of addresses from ec2 that the client has access to then select only the ones that are not associated with an instance .
# [{"instanceId"=>nil, "publicIp"=>"174.129.212.93"}, {"instanceId"=>nil, "publicIp"=>"174.129.212.94"}]