mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[aws|elb] Marker support for describe_load_balancers.
This commit is contained in:
parent
f8098a5369
commit
169f5e754c
3 changed files with 29 additions and 4 deletions
|
@ -11,8 +11,16 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def all
|
def all
|
||||||
data = connection.describe_load_balancers.body['DescribeLoadBalancersResult']['LoadBalancerDescriptions']
|
result = []
|
||||||
load(data)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(identity)
|
def get(identity)
|
||||||
|
|
|
@ -111,6 +111,8 @@ module Fog
|
||||||
when 'RequestId'
|
when 'RequestId'
|
||||||
@response['ResponseMetadata'][name] = value
|
@response['ResponseMetadata'][name] = value
|
||||||
|
|
||||||
|
when 'NextMarker'
|
||||||
|
@results['NextMarker'] = value
|
||||||
when 'DescribeLoadBalancersResponse'
|
when 'DescribeLoadBalancersResponse'
|
||||||
@response['DescribeLoadBalancersResult'] = @results
|
@response['DescribeLoadBalancersResult'] = @results
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,9 @@ module Fog
|
||||||
# Describe all or specified load balancers
|
# Describe all or specified load balancers
|
||||||
#
|
#
|
||||||
# ==== Parameters
|
# ==== Parameters
|
||||||
# * lb_name<~Array> - List of load balancer names to describe, defaults to all
|
# * options<~Hash>
|
||||||
|
# * 'LoadBalancerNames'<~Array> - List of load balancer names to describe, defaults to all
|
||||||
|
# * 'Marker'<String> - Indicates where to begin in your list of load balancers
|
||||||
#
|
#
|
||||||
# ==== Returns
|
# ==== Returns
|
||||||
# * response<~Excon::Response>:
|
# * response<~Excon::Response>:
|
||||||
|
@ -42,6 +44,7 @@ module Fog
|
||||||
# * 'SourceSecurityGroup'<~Hash>:
|
# * 'SourceSecurityGroup'<~Hash>:
|
||||||
# * 'GroupName'<~String> - Name of the source security group to use with inbound security group rules
|
# * 'GroupName'<~String> - Name of the source security group to use with inbound security group rules
|
||||||
# * 'OwnerAlias'<~String> - Owner of the source security group
|
# * 'OwnerAlias'<~String> - Owner of the source security group
|
||||||
|
# * 'NextMarker'<~String> - Marker to specify for next page
|
||||||
def describe_load_balancers(options = {})
|
def describe_load_balancers(options = {})
|
||||||
unless options.is_a?(Hash)
|
unless options.is_a?(Hash)
|
||||||
Fog::Logger.deprecation("describe_load_balancers with #{options.class} is deprecated, use all('LoadBalancerNames' => []) instead [light_black](#{caller.first})[/]")
|
Fog::Logger.deprecation("describe_load_balancers with #{options.class} is deprecated, use all('LoadBalancerNames' => []) instead [light_black](#{caller.first})[/]")
|
||||||
|
@ -78,7 +81,15 @@ module Fog
|
||||||
end.compact
|
end.compact
|
||||||
else
|
else
|
||||||
self.data[:load_balancers].map { |lb, values| values.dup }
|
self.data[:load_balancers].map { |lb, values| values.dup }
|
||||||
end[0...400]
|
end
|
||||||
|
|
||||||
|
marker = options.fetch('Marker', 0).to_i
|
||||||
|
if load_balancers.count - marker > 400
|
||||||
|
next_marker = marker + 400
|
||||||
|
load_balancers = load_balancers[marker...next_marker]
|
||||||
|
else
|
||||||
|
next_marker = nil
|
||||||
|
end
|
||||||
|
|
||||||
response = Excon::Response.new
|
response = Excon::Response.new
|
||||||
response.status = 200
|
response.status = 200
|
||||||
|
@ -96,6 +107,10 @@ module Fog
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if next_marker
|
||||||
|
response.body['DescribeLoadBalancersResult']['NextMarker'] = next_marker
|
||||||
|
end
|
||||||
|
|
||||||
response
|
response
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue