12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/aws_tracker/models/security_group.rb', line 12
def self.refresh_from_account(acc)
acc.log.info "Updating security groups for account '#{acc.name}'"
right_aws_array = acc.ec2.describe_security_groups
right_aws_array.each do |rs_group|
group_to_update = (acc.security_groups.select() do |grp|
grp.name == rs_group[:aws_group_name]
end).first
group_to_update ||= SecurityGroup.new(:account => acc)
acc.security_groups << group_to_update
group_to_update.update_from_right_hash(rs_group)
group_to_update.save
end
acc.log.info "Account '#{acc.name}' reports #{right_aws_array.count} groups"
end
|