Sha256: f5165821a184fdd771b5a9ade0f845a9c8ae043d385aca10c2ed8fd4b512f724

Contents?: true

Size: 1.16 KB

Versions: 33

Compression:

Stored size: 1.16 KB

Contents

require 'fog/collection'
require 'fog/aws/models/ec2/volume'

module Fog
  module AWS
    module EC2

      module Collections
        def volumes(attributes = {})
          Fog::AWS::EC2::Volumes.new({
            :connection => self
          }.merge!(attributes))
        end
      end

      class Volumes < Fog::Collection

        attribute :volume_id
        attribute :server

        model Fog::AWS::EC2::Volume

        def initialize(attributes)
          @volume_id ||= []
          super
        end

        def all(volume_id = @volume_id)
          @volume_id = volume_id
          data = connection.describe_volumes(volume_id).body
          load(data['volumeSet'])
          if server
            self.replace(self.select {|volume| volume.server_id == server.id})
          end
          self
        end

        def get(volume_id)
          if volume_id
            all(volume_id).first
          end
        rescue Fog::Errors::NotFound
          nil
        end

        def new(attributes = {})
          if server
            super({ :server => server }.merge!(attributes))
          else
            super
          end
        end

      end

    end
  end
end

Version data entries

33 entries across 33 versions & 2 rubygems

Version Path
fog-0.2.30 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.28 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.27 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.26 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.25 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.24 lib/fog/aws/models/ec2/volumes.rb
tecnh-fog-0.2.23.vpc lib/fog/aws/models/ec2/volumes.rb
fog-0.2.23 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.22 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.21 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.20 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.19 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.18 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.17 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.16 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.15 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.14 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.13 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.12 lib/fog/aws/models/ec2/volumes.rb
fog-0.2.11 lib/fog/aws/models/ec2/volumes.rb