Class: AWSTracker::SecurityGroup
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AWSTracker::SecurityGroup
- Defined in:
- lib/aws_tracker/models/security_group.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.refresh_from_account(acc) ⇒ Object
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 |
Instance Method Details
#update_from_right_hash(rs_group) ⇒ Object
27 28 29 30 31 |
# File 'lib/aws_tracker/models/security_group.rb', line 27 def update_from_right_hash(rs_group) self.name = rs_group[:aws_group_name] self.description = rs_group[:aws_description] self.owner = rs_group[:aws_owner] end |