Class: Cumulus::SecurityGroups::SecurityGroupDiff
- Inherits:
-
Common::Diff
- Object
- Common::Diff
- Cumulus::SecurityGroups::SecurityGroupDiff
- Includes:
- Common::TagsDiff, SecurityGroupChange
- Defined in:
- lib/security/models/SecurityGroupDiff.rb
Overview
Public: Represents a single difference between local configuration and AWS configuration of security groups
Constant Summary
Constants included from SecurityGroupChange
Cumulus::SecurityGroups::SecurityGroupChange::DESCRIPTION, Cumulus::SecurityGroups::SecurityGroupChange::INBOUND, Cumulus::SecurityGroups::SecurityGroupChange::OUTBOUND, Cumulus::SecurityGroups::SecurityGroupChange::TAGS
Constants included from Common::DiffChange
Common::DiffChange::ADD, Common::DiffChange::MODIFIED, Common::DiffChange::UNMANAGED
Instance Attribute Summary collapse
-
#inbound_diffs ⇒ Object
Returns the value of attribute inbound_diffs.
-
#outbound_diffs ⇒ Object
Returns the value of attribute outbound_diffs.
Attributes inherited from Common::Diff
#aws, #changes, #info_only, #local, #type
Class Method Summary collapse
-
.inbound(aws, local, inbound_diffs) ⇒ Object
Public: Static method that will produce a diff that contains changes in inbound rules.
-
.outbound(aws, local, outbound_diffs) ⇒ Object
Public: Static method that will produce a diff that contains changes in outbound rules.
Instance Method Summary collapse
-
#added_inbounds ⇒ Object
Public: Get the inbound rules to add.
-
#added_outbounds ⇒ Object
Public: Get the outbound rules to add.
- #asset_type ⇒ Object
- #aws_name ⇒ Object
- #diff_string ⇒ Object
-
#removed_inbounds ⇒ Object
Public: Get the inbound rules to remove.
-
#removed_outbounds ⇒ Object
Public: Get the outbound rules to remove.
Methods included from Common::TagsDiff
#tags_diff_string, #tags_to_add, #tags_to_remove
Methods included from Common::DiffChange
Methods inherited from Common::Diff
#add_string, added, #initialize, #local_name, modified, #to_s, unmanaged, #unmanaged_string
Constructor Details
This class inherits a constructor from Cumulus::Common::Diff
Instance Attribute Details
#inbound_diffs ⇒ Object
Returns the value of attribute inbound_diffs.
24 25 26 |
# File 'lib/security/models/SecurityGroupDiff.rb', line 24 def inbound_diffs @inbound_diffs end |
#outbound_diffs ⇒ Object
Returns the value of attribute outbound_diffs.
25 26 27 |
# File 'lib/security/models/SecurityGroupDiff.rb', line 25 def outbound_diffs @outbound_diffs end |
Class Method Details
.inbound(aws, local, inbound_diffs) ⇒ Object
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
34 35 36 37 38 |
# 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 |
.outbound(aws, local, outbound_diffs) ⇒ Object
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
47 48 49 50 51 |
# 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 |
Instance Method Details
#added_inbounds ⇒ Object
Public: Get the inbound rules to add
Returns the added rules
86 87 88 |
# File 'lib/security/models/SecurityGroupDiff.rb', line 86 def added_inbounds inbound_diffs.reject { |i| i.type == RuleChange::REMOVED }.map(&:local) end |
#added_outbounds ⇒ Object
Public: Get the outbound rules to add
Returns the added rules
100 101 102 |
# File 'lib/security/models/SecurityGroupDiff.rb', line 100 def added_outbounds outbound_diffs.reject { |o| o.type == RuleChange::REMOVED }.map(&:local) end |
#asset_type ⇒ Object
53 54 55 |
# File 'lib/security/models/SecurityGroupDiff.rb', line 53 def asset_type "Security group" end |
#aws_name ⇒ Object
57 58 59 |
# File 'lib/security/models/SecurityGroupDiff.rb', line 57 def aws_name @aws.vpc_group_name end |
#diff_string ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# 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 end end |
#removed_inbounds ⇒ Object
Public: Get the inbound rules to remove
Returns the removed rules
93 94 95 |
# File 'lib/security/models/SecurityGroupDiff.rb', line 93 def removed_inbounds inbound_diffs.reject { |i| i.type == RuleChange::ADD }.map(&:aws) end |
#removed_outbounds ⇒ Object
Public: Get the outbound rules to remove
Returns the removed rules
107 108 109 |
# File 'lib/security/models/SecurityGroupDiff.rb', line 107 def removed_outbounds outbound_diffs.reject { |o| o.type == RuleChange::ADD }.map(&:aws) end |