Sha256: 0cb781518f8225c42af6ae144418f16e3c029a1408d312196006e41026a6510c

Contents?: true

Size: 901 Bytes

Versions: 39

Compression:

Stored size: 901 Bytes

Contents

require 'fog/openstack/models/collection'
require 'fog/compute/openstack/models/image'

module Fog
  module Compute
    class OpenStack
      class Images < Fog::OpenStack::Collection
        attribute :filters

        model Fog::Compute::OpenStack::Image

        attribute :server

        def initialize(attributes)
          self.filters ||= {}
          super
        end

        def all(filters_arg = filters)
          filters = filters_arg
          data = service.list_images_detail(filters)
          images = load_response(data, 'images')
          if server
            replace(select { |image| image.server_id == server.id })
          end
          images
        end

        def get(image_id)
          data = service.get_image_details(image_id).body['image']
          new(data)
        rescue Fog::Compute::OpenStack::NotFound
          nil
        end
      end
    end
  end
end

Version data entries

39 entries across 37 versions & 3 rubygems

Version Path
fog-openstack-0.1.31 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.3.10 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.1.30 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.1.29 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.3.9 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.1.28 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.3.8 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.3.7 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.3.6 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.3.5 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.3.4 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.3.3 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.3.2 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.3.0 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.2.4 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.2.3 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.2.2 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.2.1 lib/fog/compute/openstack/models/images.rb
fog-openstack-0.2.0 lib/fog/compute/openstack/models/images.rb
fog-zj-0.1.28 lib/fog/compute/openstack/models/images.rb