Sha256: d266dc563b180dc1c8d97c46e5ca3cdaa8d2b00c9da2d1ad9ad16d65f4a56a59
Contents?: true
Size: 1.32 KB
Versions: 8
Compression:
Stored size: 1.32 KB
Contents
module Fog module AWS class EC2 def addresses(attributes = {}) Fog::AWS::EC2::Addresses.new({ :connection => self }.merge!(attributes)) end class Addresses < Fog::Collection attribute :public_ip attribute :server model Fog::AWS::EC2::Address def initialize(attributes) @public_ip ||= [] super end def all(public_ip = @public_ip) @public_ip = public_ip if @loaded clear end @loaded = true data = connection.describe_addresses(public_ip).body addresses = [] data['addressesSet'].each do |address| addresses << new(address.reject {|key, value| value.nil? || value.empty? }) end if server addresses = addresses.select {|address| address.instance_id == server.id} end self.replace(addresses) end def get(public_ip) if public_ip all(public_ip).first end rescue Excon::Errors::BadRequest nil end def new(attributes = {}) if server super({ :server => server }.merge!(attributes)) else super(attributes) end end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems