Sha256: cb4595d43c39bfba43f5d46fa36aa2b2f15c7d0daa7210f7bf35776770e6908a

Contents?: true

Size: 1.8 KB

Versions: 5

Compression:

Stored size: 1.8 KB

Contents

module Fog
  module Brightbox
    class Compute
      class Image < Fog::Brightbox::Model
        include Fog::Brightbox::Compute::ResourceLocking

        identity :id
        attribute :resource_type
        attribute :url

        attribute :name
        attribute :status
        attribute :description

        attribute :arch
        attribute :disk_size, type: :integer
        attribute :http_url
        attribute :licence_name
        attribute :min_ram, type: :integer
        attribute :server
        attribute :source
        attribute :source_trigger
        attribute :source_type
        attribute :username
        attribute :virtual_size, type: :integer
        attribute :volume

        # Boolean flags
        attribute :compatibility_mode, type: :boolean
        attribute :official, type: :boolean
        attribute :public, type: :boolean

        # Timestamps
        attribute :created_at, type: :time

        # Links
        attribute :ancestor_id, aliases: "ancestor", squash: "id"
        attribute :owner_id, aliases: "owner", squash: "id"

        def ready?
          status == "available"
        end

        def save
          raise Fog::Errors::Error.new("Resaving an existing object may create a duplicate") if persisted?

          options = {
            :arch => arch,
            :description => description,
            :http_url => http_url,
            :name => name,
            :server => server,
            :source => source,
            :username => username,
            :volume => volume
          }.delete_if { |_k, v| v.nil? || v == "" }
          data = service.create_image(options)
          merge_attributes(data)
          true
        end

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fog-brightbox-1.10.0 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-1.9.1 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-1.9.0 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-1.8.2 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-1.8.1 lib/fog/brightbox/models/compute/image.rb