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-1.17.0 lib/fog/openstack/models/compute/image.rb
fog-1.16.0 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.15.0.20130927082724 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.15.0.20130829165835 lib/fog/openstack/models/compute/image.rb
fog-1.15.0 lib/fog/openstack/models/compute/image.rb
gapinc-fog-1.14.0 lib/fog/openstack/models/compute/image.rb
fog-maestrodev-1.14.0.20130806165225 lib/fog/openstack/models/compute/image.rb
fog-1.14.0 lib/fog/openstack/models/compute/image.rb
fog-1.13.0 lib/fog/openstack/models/compute/image.rb
gapinc-fog-1.12.1.2 lib/fog/openstack/models/compute/image.rb
gapinc-fog-1.12.1.1 lib/fog/openstack/models/compute/image.rb
gapinc-fog-1.12.1a lib/fog/openstack/models/compute/image.rb
gapinc-fog-1.12.1 lib/fog/openstack/models/compute/image.rb
fog-1.12.1 lib/fog/openstack/models/compute/image.rb
fog-1.12.0 lib/fog/openstack/models/compute/image.rb
hpfog-0.0.20 lib/fog/openstack/models/compute/image.rb
vagrant-shell-0.2.6 vendor/bundle/gems/fog-1.10.1/lib/fog/openstack/models/compute/image.rb
vagrant-shell-0.2.5 vendor/bundle/gems/fog-1.10.1/lib/fog/openstack/models/compute/image.rb
fog-1.11.1 lib/fog/openstack/models/compute/image.rb
fog-1.11.0 lib/fog/openstack/models/compute/image.rb