1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #2040 from bgentry/asg-filters

[AWS|ASG] Filters for ASGs.
This commit is contained in:
Wesley Beary 2013-08-06 14:13:42 -07:00
commit 45687f68c1
2 changed files with 15 additions and 4 deletions

View file

@ -4,19 +4,22 @@ module Fog
module AWS
class AutoScaling
class Groups < Fog::Collection
model Fog::AWS::AutoScaling::Group
attribute :filters
# Creates a new auto scaling group.
def initialize(attributes={})
self.filters = attributes
super
end
def all
def all(filters = filters)
data = []
next_token = nil
self.filters = filters
loop do
result = service.describe_auto_scaling_groups('NextToken' => next_token).body['DescribeAutoScalingGroupsResult']
result = service.describe_auto_scaling_groups(filters.merge('NextToken' => next_token)).body['DescribeAutoScalingGroupsResult']
data += result['AutoScalingGroups']
next_token = result['NextToken']
break if next_token.nil?

View file

@ -111,7 +111,15 @@ module Fog
def describe_auto_scaling_groups(options = {})
results = { 'AutoScalingGroups' => [] }
self.data[:auto_scaling_groups].each do |asg_name, asg_data|
asg_set = self.data[:auto_scaling_groups]
if !options["AutoScalingGroupNames"].nil?
asg_set = asg_set.reject do |asg_name, asg_data|
![*options["AutoScalingGroupNames"]].include?(asg_name)
end
end
asg_set.each do |asg_name, asg_data|
results['AutoScalingGroups'] << {
'AutoScalingGroupName' => asg_name
}.merge!(asg_data)