Sha256: 50e623d8600222b1e5db939c98094fde5516eef3b1c9c780c824a16506e62382

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

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

module Fog
  module Compute
    class OpenStack
      class Image < Fog::OpenStack::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 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

7 entries across 7 versions & 1 rubygems

Version Path
fog-openstack-0.1.18 lib/fog/compute/openstack/models/image.rb
fog-openstack-0.1.17 lib/fog/compute/openstack/models/image.rb
fog-openstack-0.1.15 lib/fog/compute/openstack/models/image.rb
fog-openstack-0.1.14 lib/fog/compute/openstack/models/image.rb
fog-openstack-0.1.13 lib/fog/compute/openstack/models/image.rb
fog-openstack-0.1.12 lib/fog/compute/openstack/models/image.rb
fog-openstack-0.1.11 lib/fog/compute/openstack/models/image.rb