Sha256: ce158d567e8331e56d5901c656b7e647a7abc68d23a1c456d88756293c7213cf

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

module Fog
  module AWS
    class EC2

      class Volume < Fog::Model

        attribute :attachment_time,   'attachmentTime'
        attribute :availability_zone, 'availabilityZone'
        attribute :create_time,       'createTime'
        attribute :device
        attribute :instance_id,       'instanceId'
        attribute :size
        attribute :snapshot_id,       'snapshotId'
        attribute :status,            'status'
        attribute :volume_id,         'volumeId'
        
        def initialize(attributes = {})
          if attributes['attachmentSet']
            attributes.merge!(attributes.delete('attachmentSet').first || {})
          end
          super
        end

        def destroy
          connection.delete_volume(@volume_id)
          true
        end

        def reload
          new_attributes = volumes.get(@volume_id).attributes
          merge_attributes(new_attributes)
        end

        def save
          data = connection.create_volume(@availability_zone, @size, @snapshot_id).body
          new_attributes = data.reject {|key,value| key == 'requestId'}
          merge_attributes(new_attributes)
          true
        end

        def snapshots
          connection.snapshots(:volume_id => volume_id)
        end

        def volumes
          @volumes
        end

        private

        def volumes=(new_volumes)
          @volumes = new_volumes
        end

      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-0.0.13 lib/fog/aws/models/ec2/volume.rb
fog-0.0.12 lib/fog/aws/models/ec2/volume.rb
fog-0.0.11 lib/fog/aws/models/ec2/volume.rb
fog-0.0.10 lib/fog/aws/models/ec2/volume.rb