Sha256: 6600d4ebec898e50f1cc0505747ec3e219a40b48638f41a6dee1350f1d61b36b

Contents?: true

Size: 886 Bytes

Versions: 9

Compression:

Stored size: 886 Bytes

Contents

module Fog
  module Rackspace
    class Servers

      def images(attributes = {})
        Fog::Rackspace::Servers::Images.new({
          :connection => self
        }.merge!(attributes))
      end

      class Images < Fog::Collection

        model Fog::Rackspace::Servers::Image

        attribute :server

        def all
          if @loaded
            clear
          end
          @loaded = true
          data = connection.list_images_detail.body
          images = []
          for image in data['images']
            images << new(image)
          end
          if server
            images = images.select {|image| image.server_id == server.id}
          end
          self.replace(images)
        end

        def get(image_id)
          connection.get_image_details(image_id)
        rescue Excon::Errors::NotFound
          nil
        end

      end

    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fog-0.0.47 lib/fog/rackspace/models/servers/images.rb
fog-0.0.46 lib/fog/rackspace/models/servers/images.rb
fog-0.0.45 lib/fog/rackspace/models/servers/images.rb
fog-0.0.44 lib/fog/rackspace/models/servers/images.rb
fog-0.0.43 lib/fog/rackspace/models/servers/images.rb
fog-0.0.42 lib/fog/rackspace/models/servers/images.rb
fog-0.0.41 lib/fog/rackspace/models/servers/images.rb
fog-0.0.40 lib/fog/rackspace/models/servers/images.rb
fog-0.0.39 lib/fog/rackspace/models/servers/images.rb