Sha256: 2bbca5e61f045c92ebcef3e76d4be3d537085a52403a75c4eee2438839beb4d3

Contents?: true

Size: 1.26 KB

Versions: 23

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

23 entries across 23 versions & 4 rubygems

Version Path
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/openstack/models/compute/image.rb
fog-1.32.0 lib/fog/openstack/models/compute/image.rb
fog-1.31.0 lib/fog/openstack/models/compute/image.rb
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/openstack/models/compute/image.rb
fog-1.30.0 lib/fog/openstack/models/compute/image.rb
fog-1.29.0 lib/fog/openstack/models/compute/image.rb
fog-1.28.0 lib/fog/openstack/models/compute/image.rb
fog-1.27.0 lib/fog/openstack/models/compute/image.rb
fog-1.26.0 lib/fog/openstack/models/compute/image.rb
fog-1.25.0 lib/fog/openstack/models/compute/image.rb
nsidc-fog-1.24.1 lib/fog/openstack/models/compute/image.rb
fog-1.24.0 lib/fog/openstack/models/compute/image.rb
ns-fog-1.22.11 lib/fog/openstack/models/compute/image.rb
ns-fog-1.22.10 lib/fog/openstack/models/compute/image.rb
ns-fog-1.22.9 lib/fog/openstack/models/compute/image.rb
ns-fog-1.22.8 lib/fog/openstack/models/compute/image.rb
ns-fog-1.22.7 lib/fog/openstack/models/compute/image.rb
ns-fog-1.22.6 lib/fog/openstack/models/compute/image.rb
fog-1.23.0 lib/fog/openstack/models/compute/image.rb
ns-fog-1.22.4 lib/fog/openstack/models/compute/image.rb