Class: Cumulus::VPC::NetworkAclConfig
- Inherits:
-
Object
- Object
- Cumulus::VPC::NetworkAclConfig
- Defined in:
- lib/vpc/models/NetworkAclConfig.rb
Overview
Public: An object representing configuration for a VPC Network ACL
Instance Attribute Summary collapse
-
#inbound ⇒ Object
readonly
Returns the value of attribute inbound.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#outbound ⇒ Object
readonly
Returns the value of attribute outbound.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Instance Method Summary collapse
-
#diff(aws) ⇒ Object
Public: Produce an array of differences between this local configuration and the configuration in AWS.
-
#initialize(name, json = nil) ⇒ NetworkAclConfig
constructor
Public: Constructor.
- #populate!(aws) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(name, json = nil) ⇒ NetworkAclConfig
Public: Constructor
name - the name of the network acl config json - a hash containing the JSON configuration for the Network ACL
21 22 23 24 25 26 27 28 |
# File 'lib/vpc/models/NetworkAclConfig.rb', line 21 def initialize(name, json = nil) @name = name if !json.nil? @inbound = (json["inbound"] || []).map { |entry| AclEntryConfig.new(entry) } @outbound = (json["outbound"] || []).map { |entry| AclEntryConfig.new(entry) } @tags = json["tags"] || {} end end |
Instance Attribute Details
#inbound ⇒ Object (readonly)
Returns the value of attribute inbound.
12 13 14 |
# File 'lib/vpc/models/NetworkAclConfig.rb', line 12 def inbound @inbound end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/vpc/models/NetworkAclConfig.rb', line 15 def name @name end |
#outbound ⇒ Object (readonly)
Returns the value of attribute outbound.
13 14 15 |
# File 'lib/vpc/models/NetworkAclConfig.rb', line 13 def outbound @outbound end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
14 15 16 |
# File 'lib/vpc/models/NetworkAclConfig.rb', line 14 def @tags end |
Instance Method Details
#diff(aws) ⇒ Object
Public: Produce an array of differences between this local configuration and the configuration in AWS
aws - the AWS resource
Returns an array of the NetworkAclDiffs that were found
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/vpc/models/NetworkAclConfig.rb', line 62 def diff(aws) diffs = [] aws_inbound = aws.diffable_entries.select { |entry| !entry.egress } inbound_diff = NetworkAclDiff.entries(NetworkAclChange::INBOUND, aws_inbound, @inbound) if inbound_diff diffs << inbound_diff end aws_outbound = aws.diffable_entries.select { |entry| entry.egress } outbound_diff = NetworkAclDiff.entries(NetworkAclChange::OUTBOUND, aws_outbound, @outbound) if outbound_diff diffs << outbound_diff end = Hash[aws..map { |tag| [tag.key, tag.value] }] if @tags != diffs << NetworkAclDiff.new(NetworkAclChange::TAGS, , @tags) end diffs end |
#populate!(aws) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/vpc/models/NetworkAclConfig.rb', line 38 def populate!(aws) @inbound = aws.diffable_entries.select { |entry| !entry.egress } .map { |entry| AclEntryConfig.new().populate!(entry) } .sort_by!(&:rule) @outbound = aws.diffable_entries.select { |entry| entry.egress } .map { |entry| AclEntryConfig.new().populate!(entry) } .sort_by!(&:rule) @tags = Hash[aws..map { |tag| [tag.key, tag.value] }] # If there is not a name then add a name tag using the given name if !@tags["Name"] puts "Network ACL #{aws.network_acl_id} does not have a Name defined. Cumulus will use #{name} as the name when migrated." @tags["Name"] = @name end self end |
#to_hash ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/vpc/models/NetworkAclConfig.rb', line 30 def to_hash { "inbound" => @inbound.map(&:to_hash), "outbound" => @outbound.map(&:to_hash), "tags" => @tags }.reject { |k, v| v.nil? } end |