Sha256: 63f1d068324ce8e9dac473265e0a3b763105745cde66b21391a05f59414e9d6c

Contents?: true

Size: 1.36 KB

Versions: 11

Compression:

Stored size: 1.36 KB

Contents

require 'fog/core/model'

module Fog
  module Rackspace
    class BlockStorage
      class Volume < Fog::Model
        AVAILABLE = 'available'
        ATTACHING = 'attaching'
        CREATING = 'creating'
        DELETING = 'deleting'
        ERROR = 'error'
        ERROR_DELETING = 'error_deleting'
        IN_USE = 'in-use'

        identity :id

        attribute :created_at, :aliases => 'createdAt'
        attribute :state, :aliases => 'status'
        attribute :display_name
        attribute :display_description
        attribute :size
        attribute :attachments
        attribute :volume_type
        attribute :availability_zone

        def ready?
          state == AVAILABLE
        end

        def attached?
          state == IN_USE
        end

        def snapshots
          connection.snapshots.select { |s| s.volume_id == identity }
        end

        def save
          requires :size
          data = connection.create_volume(size, {
            :display_name => display_name,
            :display_description => display_description,
            :volume_type => volume_type,
            :availability_zone => availability_zone
          })
          merge_attributes(data.body['volume'])
          true
        end

        def destroy
          requires :identity
          connection.delete_volume(identity)
          true
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 7 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/rackspace/models/block_storage/volume.rb
fog-nirvanix-1.8.1 lib/fog/rackspace/models/block_storage/volume.rb
fog-parser-fix-1.6.1 lib/fog/rackspace/models/block_storage/volume.rb
fog-test-again-1.6.0 lib/fog/rackspace/models/block_storage/volume.rb
fog-parser-fix-1.6.0 lib/fog/rackspace/models/block_storage/volume.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/rackspace/models/block_storage/volume.rb
fog-sgonyea-1.8.1 lib/fog/rackspace/models/block_storage/volume.rb
fog-1.8.0 lib/fog/rackspace/models/block_storage/volume.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/rackspace/models/block_storage/volume.rb
fog-1.7.0 lib/fog/rackspace/models/block_storage/volume.rb
fog-1.6.0 lib/fog/rackspace/models/block_storage/volume.rb