Sha256: e77333130d83f30ea7488993f6b4dd894c5ba26edcf2826700c869c6c7811c3d

Contents?: true

Size: 1007 Bytes

Versions: 16

Compression:

Stored size: 1007 Bytes

Contents

require 'fog/core/collection'
require 'fog/cloudstack/models/compute/image'

module Fog
  module Compute
    class Cloudstack
      class Images < Fog::Collection
        model Fog::Compute::Cloudstack::Image

        def all(filters={})
          options = get_filter_options(filters)

          data = service.list_templates(options)["listtemplatesresponse"]["template"] || []
          load(data)
        end

        def get(template_id, filters={})
          filter_option = get_filter_options(filters)
          options = filter_option.merge('id' => template_id)

          if template = service.list_templates(options)["listtemplatesresponse"]["template"].first
            new(template)
          end
        rescue Fog::Compute::Cloudstack::BadRequest
          nil
        end

        private

        def get_filter_options(filters)
          default_filter = {
              'templatefilter' => 'self'
          }
          default_filter.merge(filters)
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 4 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/cloudstack/models/compute/images.rb
fog-1.26.0 lib/fog/cloudstack/models/compute/images.rb
fog-1.25.0 lib/fog/cloudstack/models/compute/images.rb
nsidc-fog-1.24.1 lib/fog/cloudstack/models/compute/images.rb
fog-1.24.0 lib/fog/cloudstack/models/compute/images.rb
ns-fog-1.22.11 lib/fog/cloudstack/models/compute/images.rb
ns-fog-1.22.10 lib/fog/cloudstack/models/compute/images.rb
ns-fog-1.22.9 lib/fog/cloudstack/models/compute/images.rb
ns-fog-1.22.8 lib/fog/cloudstack/models/compute/images.rb
ns-fog-1.22.7 lib/fog/cloudstack/models/compute/images.rb
ns-fog-1.22.6 lib/fog/cloudstack/models/compute/images.rb
fog-1.23.0 lib/fog/cloudstack/models/compute/images.rb
ns-fog-1.22.4 lib/fog/cloudstack/models/compute/images.rb
ns-fog-1.22.3 lib/fog/cloudstack/models/compute/images.rb
ns-fog-1.22.2 lib/fog/cloudstack/models/compute/images.rb
fog-1.22.1 lib/fog/cloudstack/models/compute/images.rb