Sha256: 008f247068e59016e2850231245a6bdc14e2a83a3522b736c9cdaf9cfc3fa81d

Contents?: true

Size: 979 Bytes

Versions: 108

Compression:

Stored size: 979 Bytes

Contents

require 'fog/core/collection'
require 'fog/linode/models/compute/ip'

module Fog
  module Compute
    class Linode
      class Ips < Fog::Collection
        model Fog::Compute::Linode::Ip
        attribute :server

        def all
          requires :server
          load ips(server.id)
        end

        def get(id)
          requires :server
          new ips(server.id, id).first
        rescue Fog::Compute::Linode::NotFound
          nil
        end

        def new(attributes = {})
          requires :server
          super({ :server => server }.merge!(attributes))
        end

        private
        def ips(linode_id, id=nil)
          service.linode_ip_list(linode_id, id).body['DATA'].map { |ip| map_ip ip }
        end

        def map_ip(ip)
          ip = ip.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v  }
          ip.merge! :id => ip[:ipaddressid], :ip => ip[:ipaddress], :public => ip[:ispublic]==1
        end
      end
    end
  end
end

Version data entries

108 entries across 106 versions & 11 rubygems

Version Path
fog-2.3.0 lib/fog/linode/models/compute/ips.rb
fog-ifeel-2.2.0 lib/fog/linode/models/compute/ips.rb
fog-2.2.0 lib/fog/linode/models/compute/ips.rb
fog-2.1.0 lib/fog/linode/models/compute/ips.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/linode/models/compute/ips.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/linode/models/compute/ips.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/linode/models/compute/ips.rb
fog-1.42.1 lib/fog/linode/models/compute/ips.rb
fog-2.0.0 lib/fog/linode/models/compute/ips.rb
fog-1.42.0 lib/fog/linode/models/compute/ips.rb
fog-1.41.0 lib/fog/linode/models/compute/ips.rb
fog-1.40.0 lib/fog/linode/models/compute/ips.rb
fog-1.39.0 lib/fog/linode/models/compute/ips.rb
fog-1.38.0 lib/fog/linode/models/compute/ips.rb
fog-1.37.0 lib/fog/linode/models/compute/ips.rb
fog-1.36.0 lib/fog/linode/models/compute/ips.rb
fog-1.35.0 lib/fog/linode/models/compute/ips.rb
fog-2.0.0.pre.0 lib/fog/linode/models/compute/ips.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/linode/models/compute/ips.rb
fog-1.34.0 lib/fog/linode/models/compute/ips.rb