Sha256: 33d6d388a2fe4f8db3c1c491284ae7ca0e7fac7ee9f19393c44889fc3ca97c0f
Contents?: true
Size: 1.23 KB
Versions: 7
Compression:
Stored size: 1.23 KB
Contents
module Fog module AWS class EC2 def volumes(attributes = {}) Fog::AWS::EC2::Volumes.new({ :connection => self }.merge!(attributes)) 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 if @loaded clear end @loaded = true data = connection.describe_volumes(volume_id).body volumes = [] data['volumeSet'].each do |volume| volumes << new(volume) end if server volumes = volumes.select {|volume| volume.instance_id == server.id} end self.replace(volumes) end def get(volume_id) if volume_id all(volume_id).first end rescue Excon::Errors::BadRequest nil end def new(attributes = {}) if server super({ :server => server }.merge!(attributes)) else super end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems