Sha256: a5bc842a04042315e6588496ef0886d4a71869f8f4074ba9b1963743db009c23

Contents?: true

Size: 1.54 KB

Versions: 16

Compression:

Stored size: 1.54 KB

Contents

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

        identity :id
        attribute :url
        attribute :resource_type

        attribute :name
        attribute :username
        attribute :status
        attribute :description

        attribute :source
        attribute :source_type
        attribute :arch
        attribute :virtual_size
        attribute :disk_size
        attribute :licence_name

        # Boolean flags
        attribute :public
        attribute :official
        attribute :compatibility_mode

        # Times
        attribute :created_at, :type => :time

        # Links - to be replaced
        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?
          requires :source, :arch
          options = {
            :source => source,
            :arch => arch,
            :name => name,
            :username => username,
            :description => description
          }.delete_if { |_k, v| v.nil? || v == "" }
          data = service.create_image(options)
          merge_attributes(data)
          true
        end

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

Version data entries

16 entries across 14 versions & 3 rubygems

Version Path
fog-brightbox-1.0.0.rc1 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.16.1 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.16.0 lib/fog/brightbox/models/compute/image.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-brightbox-0.15.0/lib/fog/brightbox/models/compute/image.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-brightbox-0.15.0/lib/fog/brightbox/models/compute/image.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-brightbox-0.15.0/lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.15.0 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.14.0 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.13.0 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.12.0 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.11.0 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.10.1 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.10.0 lib/fog/brightbox/models/compute/image.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-brightbox-0.9.0/lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.9.0 lib/fog/brightbox/models/compute/image.rb
fog-brightbox-0.8.0 lib/fog/brightbox/models/compute/image.rb