Class: Cumulus::VPC::NetworkAclDiff
- Inherits:
-
Common::Diff
- Object
- Common::Diff
- Cumulus::VPC::NetworkAclDiff
- Includes:
- Common::TagsDiff, NetworkAclChange
- Defined in:
- lib/vpc/models/NetworkAclDiff.rb
Overview
Public: Represents a single difference between local configuration and AWS configuration
Constant Summary
Constants included from NetworkAclChange
Cumulus::VPC::NetworkAclChange::INBOUND, Cumulus::VPC::NetworkAclChange::OUTBOUND, Cumulus::VPC::NetworkAclChange::TAGS
Constants included from Common::DiffChange
Common::DiffChange::ADD, Common::DiffChange::MODIFIED, Common::DiffChange::UNMANAGED
Instance Attribute Summary
Attributes inherited from Common::Diff
#aws, #changes, #info_only, #local, #type
Class Method Summary collapse
Instance Method Summary collapse
- #asset_type ⇒ Object
- #aws_name ⇒ Object
- #aws_tags ⇒ Object
- #diff_string ⇒ Object
- #local_tags ⇒ Object
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
Class Method Details
.entries(type, aws, local) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/vpc/models/NetworkAclDiff.rb', line 25 def self.entries(type, aws, local) aws_rule_entries = Hash[aws.map do |entry| aws_entry = AclEntryConfig.new aws_entry.populate!(entry) [entry.rule_number, aws_entry] end] local_rule_entries = Hash[local.map { |entry| [entry.rule, entry] }] added_diffs = Hash[local_rule_entries.reject { |rule, entry| aws_rule_entries.has_key? rule }.map do |rule, local_entry| [rule, AclEntryDiff.added(local_entry)] end] removed_diffs = Hash[aws_rule_entries.reject { |rule, entry| local_rule_entries.has_key? rule }.map do |rule, aws_entry| [rule, AclEntryDiff.unmanaged(aws_entry)] end] modified_diffs = Hash[local_rule_entries.select { |rule, entry| aws_rule_entries.has_key? rule }.map do |rule, local_entry| aws_entry = aws_rule_entries[rule] entry_diffs = local_entry.diff(aws_entry) if !entry_diffs.empty? [rule, AclEntryDiff.modified(aws_entry, local_entry, entry_diffs)] end end.reject { |v| v.nil? }] if !added_diffs.empty? or !removed_diffs.empty? or !modified_diffs.empty? diff = NetworkAclDiff.new(type, aws, local) diff.changes = Common::ListChange.new(added_diffs, removed_diffs, modified_diffs) diff end end |
Instance Method Details
#asset_type ⇒ Object
63 64 65 |
# File 'lib/vpc/models/NetworkAclDiff.rb', line 63 def asset_type "Network Acl" end |
#aws_name ⇒ Object
67 68 69 |
# File 'lib/vpc/models/NetworkAclDiff.rb', line 67 def aws_name @aws.name || @aws.network_acl_id end |
#aws_tags ⇒ Object
59 60 61 |
# File 'lib/vpc/models/NetworkAclDiff.rb', line 59 def @aws end |
#diff_string ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/vpc/models/NetworkAclDiff.rb', line 71 def diff_string case @type when INBOUND [ "Inbound Rules:", entries_diff_string ].flatten.join("\n") when OUTBOUND [ "Outbound Rules:", entries_diff_string ].flatten.join("\n") when TAGS end end |
#local_tags ⇒ Object
55 56 57 |
# File 'lib/vpc/models/NetworkAclDiff.rb', line 55 def @local end |