Sha256: b767970a035817edfd30c91b04afb209c5593a68d0d70c047d1fe0186ec91a48

Contents?: true

Size: 762 Bytes

Versions: 7

Compression:

Stored size: 762 Bytes

Contents

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

module Fog
  module Compute
    class Linode
      class Servers < Fog::Collection
        model Fog::Compute::Linode::Server

        def all
          load servers
        end

        def get(id)
          new servers(id).first
        rescue Fog::Compute::Linode::NotFound
          nil
        end

        private
        def servers(id=nil)
          connection.linode_list(id).body['DATA'].map { |server| map_server server }
        end
        
        def map_server(server)
          server = server.each_with_object({}) { |(k, v), h| h[k.downcase.to_sym] = v  }
          server.merge! :id => server[:linodeid], :name => server[:label]
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
brightbox-cli-0.13.1 lib/brightbox-cli/vendor/fog/lib/fog/compute/models/linode/servers.rb
brightbox-cli-0.13.0 lib/brightbox-cli/vendor/fog/lib/fog/compute/models/linode/servers.rb
fog-0.11.0 lib/fog/compute/models/linode/servers.rb
fog-0.10.0 lib/fog/compute/models/linode/servers.rb
fog4encbs-0.9.0.1 lib/fog/compute/models/linode/servers.rb
fog4encbs-0.9.0 lib/fog/compute/models/linode/servers.rb
fog-0.9.0 lib/fog/compute/models/linode/servers.rb