Sha256: 30326a00324973837f693efcf7766e03604e7e29ba553e9a0d79e3ea609c2927

Contents?: true

Size: 1.52 KB

Versions: 61

Compression:

Stored size: 1.52 KB

Contents

require 'fog/core/model'

module Fog
  module HP
    class BlockStorage

      class Snapshot < Fog::Model

        identity  :id

        attribute :name,                 :aliases => 'displayName'
        attribute :description,          :aliases => 'displayDescription'
        attribute :size
        attribute :status
        attribute :created_at,           :aliases => 'createdAt'
        attribute :volume_id,            :aliases => 'volumeId'
        #attribute :metadata

        def initialize(attributes = {})
          # assign these attributes first to prevent race condition with persisted?
          self.force = attributes.delete(:force)   # force snapshotting of attached volumes
          super
        end

        def destroy
          requires :id
          service.delete_snapshot(id)
          true
        end

        def force=(new_force)
          @force = new_force
        end

        def ready?
          self.status == 'available'
        end

        def save
          raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted?
          requires :name, :volume_id
          options = {
            #'metadata'        => metadata,      # TODO: Add metadata when snapshots support it
            'force'           => @force
          }
          options = options.reject {|key, value| value.nil?}
          data = service.create_snapshot(name, description, volume_id, options)
          merge_attributes(data.body['snapshot'])
          true
        end

      end

    end
  end
end

Version data entries

61 entries across 61 versions & 6 rubygems

Version Path
fog-1.22.0 lib/fog/hp/models/block_storage/snapshot.rb
fog-1.21.0 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/hp/models/block_storage/snapshot.rb
fog-1.20.0 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/hp/models/block_storage/snapshot.rb
fog-1.19.0 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/hp/models/block_storage/snapshot.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/hp/models/block_storage/snapshot.rb