class Cumulus::VPC::RouteTableDiff
Public: Represents a single difference between local configuration and AWS configuration
Public Class Methods
propagate_vgws(aws, local)
click to toggle source
# File lib/vpc/models/RouteTableDiff.rb, line 48 def self.propagate_vgws(aws, local) changes = Common::ListChange.simple_list_diff(aws, local) if changes diff = RouteTableDiff.new(VGWS, aws, local) diff.changes = changes diff end end
routes(aws, local)
click to toggle source
# File lib/vpc/models/RouteTableDiff.rb, line 23 def self.routes(aws, local) aws_cidr_routes = Hash[aws.map { |route| [route.destination_cidr_block, route] }] local_cidr_routes = Hash[local.map { |route| [route.dest_cidr, route] }] added = local_cidr_routes.reject { |k, v| aws_cidr_routes.has_key? k } removed = aws_cidr_routes.reject { |k, v| local_cidr_routes.has_key? k } modified = local_cidr_routes.select { |k, v| aws_cidr_routes.has_key? k } added_diffs = Hash[added.map { |cidr, route| [cidr, RouteDiff.added(route)] }] removed_diffs = Hash[removed.map { |cidr, route| [cidr, RouteDiff.unmanaged(route)] }] modified_diffs = Hash[modified.map do |cidr, route| aws_route = aws_cidr_routes[cidr] route_diffs = route.diff(aws_route) if !route_diffs.empty? [cidr, RouteDiff.modified(aws_route, route, route_diffs)] end end.reject { |v| v.nil? }] if !added_diffs.empty? or !removed_diffs.empty? or !modified_diffs.empty? diff = RouteTableDiff.new(ROUTES, aws, local) diff.changes = Common::ListChange.new(added_diffs, removed_diffs, modified_diffs) diff end end
Public Instance Methods
asset_type()
click to toggle source
# File lib/vpc/models/RouteTableDiff.rb, line 65 def asset_type "Route Table" end
aws_name()
click to toggle source
# File lib/vpc/models/RouteTableDiff.rb, line 69 def aws_name @aws.name end
diff_string()
click to toggle source
# File lib/vpc/models/RouteTableDiff.rb, line 73 def diff_string case @type when ROUTES [ "Routes:", @changes.removed.map { |s, _| Colors.unmanaged("\t#{s} will be deleted") }, @changes.added.map { |s, _| Colors.added("\t#{s} will be created") }, @changes.modified.map do |cidr, diff| [ "\t#{cidr}:", diff.changes.map do |diff| diff.to_s.lines.map { |l| "\t\t#{l}".chomp("\n") } end ] end ].flatten.join("\n") when VGWS [ "Propagate VGWs:", @changes.removed.map { |s, _| Colors.unmanaged("\t#{s}") }, @changes.added.map { |s, _| Colors.added("\t#{s}") }, ].flatten.join("\n") when TAGS tags_diff_string end end