Sha256: bb54c2b1a8f1d386d2a8d44b202f8f5e0dc03fa5c5a3c7c335c47bea5264b652

Contents?: true

Size: 1.26 KB

Versions: 71

Compression:

Stored size: 1.26 KB

Contents

require 'fog/core/model'
require 'fog/openstack/models/compute/metadata'

module Fog
  module Compute
    class OpenStack

      class Image < Fog::Model

        identity :id

        attribute :name
        attribute :created_at,  :aliases => 'created'
        attribute :updated_at,  :aliases => 'updated'
        attribute :progress
        attribute :status
        attribute :minDisk
        attribute :minRam
        attribute :server,   :aliases => 'server'
        attribute :metadata
        attribute :links

        def initialize(attributes)
          # Old 'connection' is renamed as service and should be used instead
          prepare_service_value(attributes)
          super
        end

        def metadata
          @metadata ||= begin
            Fog::Compute::OpenStack::Metadata.new({
              :service => service,
              :parent => self
            })
          end
        end

        def metadata=(new_metadata={})
          metas = []
          new_metadata.each_pair {|k,v| metas << {"key" => k, "value" => v} }
          metadata.load(metas)
        end

        def destroy
          requires :id
          service.delete_image(id)
          true
        end

        def ready?
          status == 'ACTIVE'
        end

      end

    end
  end
end

Version data entries

71 entries across 71 versions & 7 rubygems

Version Path
fog-maestrodev-1.18.0.20131218202447 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131209090811 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131206115947 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131205181604 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131127194823 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131126183714 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131126122111 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131125111730 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131125083406 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131123105121 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131122203507 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131121075022 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131118164830 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131115184302 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131114200144 lib/fog/openstack/models/compute/image.rb
gapinc-fog-1.12.1.2.1 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131112185232 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.18.0.20131111203459 lib/fog/openstack/models/compute/image.rb
fog-1.18.0 lib/fog/openstack/models/compute/image.rb