class Cumulus::SecurityGroups::SecurityGroupDiff
Public: Represents a single difference between local configuration and AWS configuration of security groups
Attributes
Public Class Methods
Public: Static method that will produce a diff that contains changes in inbound rules
aws - the aws configuration local - the local configuration inbound_diffs
- the differences in inbound rules
Returns the diff
# File lib/security/models/SecurityGroupDiff.rb, line 34 def SecurityGroupDiff.inbound(aws, local, inbound_diffs) diff = SecurityGroupDiff.new(INBOUND, aws, local) diff.inbound_diffs = inbound_diffs diff end
Public: Static method that will produce a diff that contains changes in outbound rules
aws - the aws configuration local - the local configuration outbound_diffs
- the differences in outbound rules
Returns the diff
# File lib/security/models/SecurityGroupDiff.rb, line 47 def SecurityGroupDiff.outbound(aws, local, outbound_diffs) diff = SecurityGroupDiff.new(OUTBOUND, aws, local) diff.outbound_diffs = outbound_diffs diff end
Public Instance Methods
Public: Get the inbound rules to add
Returns the added rules
# File lib/security/models/SecurityGroupDiff.rb, line 86 def added_inbounds inbound_diffs.reject { |i| i.type == RuleChange::REMOVED }.map(&:local) end
Public: Get the outbound rules to add
Returns the added rules
# File lib/security/models/SecurityGroupDiff.rb, line 100 def added_outbounds outbound_diffs.reject { |o| o.type == RuleChange::REMOVED }.map(&:local) end
# File lib/security/models/SecurityGroupDiff.rb, line 53 def asset_type "Security group" end
# File lib/security/models/SecurityGroupDiff.rb, line 57 def aws_name @aws.vpc_group_name end
# File lib/security/models/SecurityGroupDiff.rb, line 61 def diff_string case @type when DESCRIPTION [ "Description:", Colors.aws_changes("\tAWS - #{@aws.description}"), Colors.local_changes("\tLocal - #{@local.description}"), "\tUnfortunately, AWS's SDK does not allow updating the description." ].join("\n") when INBOUND lines = ["Inbound rules:"] lines << inbound_diffs.map { |d| "\t#{d}" } lines.flatten.join("\n") when OUTBOUND lines = ["Outbound rules:"] lines << outbound_diffs.map { |d| "\t#{d}" } lines.flatten.join("\n") when TAGS tags_diff_string end end
Public: Get the inbound rules to remove
Returns the removed rules
# File lib/security/models/SecurityGroupDiff.rb, line 93 def removed_inbounds inbound_diffs.reject { |i| i.type == RuleChange::ADD }.map(&:aws) end
Public: Get the outbound rules to remove
Returns the removed rules
# File lib/security/models/SecurityGroupDiff.rb, line 107 def removed_outbounds outbound_diffs.reject { |o| o.type == RuleChange::ADD }.map(&:aws) end