Sha256: b762502d9b9369c958a4ef6091d5994e0cca8b56411f513cab9855186199e883

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module Fog
  module Compute
    class Serverlove
      class Image < Fog::Model
        identity :id, :aliases => 'drive'

        attribute :name
        attribute :user
        attribute :size
        attribute :claimed
        attribute :status
        attribute :imaging
        attribute :encryption_cipher, :aliases => 'encryption:cipher'

        def save
          attributes = {}

          if(identity)
            attributes = service.update_image(identity, allowed_attributes).body
          else
            requires :name
            requires :size
            attributes = service.create_image(allowed_attributes).body
          end

          merge_attributes(attributes)
          self
        end

        def load_standard_image(standard_image_uuid)
          requires :identity
          service.load_standard_image(identity, standard_image_uuid)
        end

        def ready?
          status.upcase == 'ACTIVE'
        end

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

        def allowed_attributes
          allowed = [:name, :size]
          attributes.select {|k,v| allowed.include? k}
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fog-serverlove-0.1.1 lib/fog/compute/serverlove/models/image.rb
fog-serverlove-0.1.0 lib/fog/compute/serverlove/models/image.rb