2011-05-11 12:27:27 -07:00
|
|
|
require 'fog/aws/models/elb/load_balancer'
|
2011-03-08 17:41:49 -05:00
|
|
|
module Fog
|
|
|
|
module AWS
|
|
|
|
class ELB
|
|
|
|
class LoadBalancers < Fog::Collection
|
|
|
|
model Fog::AWS::ELB::LoadBalancer
|
|
|
|
|
|
|
|
# Creates a new load balancer
|
|
|
|
def initialize(attributes={})
|
|
|
|
super
|
|
|
|
end
|
|
|
|
|
|
|
|
def all
|
2012-04-22 22:46:17 -03:00
|
|
|
result = []
|
|
|
|
marker = nil
|
|
|
|
finished = false
|
|
|
|
while !finished
|
|
|
|
data = connection.describe_load_balancers('Marker' => marker).body
|
|
|
|
result.concat(data['DescribeLoadBalancersResult']['LoadBalancerDescriptions'])
|
|
|
|
marker = data['DescribeLoadBalancersResult']['NextMarker']
|
|
|
|
finished = marker.nil?
|
|
|
|
end
|
|
|
|
load(result) # data is an array of attribute hashes
|
2011-03-08 17:41:49 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def get(identity)
|
2012-04-22 22:04:03 -03:00
|
|
|
data = connection.describe_load_balancers('LoadBalancerNames' => identity).body['DescribeLoadBalancersResult']['LoadBalancerDescriptions'].first
|
2011-03-08 17:41:49 -05:00
|
|
|
new(data)
|
|
|
|
rescue Fog::AWS::ELB::NotFound
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|