class Cumulus::EC2::InstanceDiff

Public: Represents a single difference between local configuration and AWS configuration

Public Instance Methods

asset_type() click to toggle source
# File lib/ec2/models/InstanceDiff.rb, line 31
def asset_type
  case @type
  when EBS then "EBS Optimized"
  when PROFILE then "Instance Profile"
  when MONITORING then "Monitoring"
  when INTERFACES then "Network Interfaces"
  when SDCHECK then "Source Dest Check"
  when SECURITY_GROUPS then "Security Groups"
  when SUBNET then "Subnet"
  when TYPE then "Type"
  when TENANCY then "Tenancy"
  when VOLUME_GROUPS then "Volume Groups"
  when TAGS then "Tags"
  else
    "EC2 Instance"
  end
end
aws_name() click to toggle source
# File lib/ec2/models/InstanceDiff.rb, line 49
def aws_name
  @aws.name
end
aws_tags() click to toggle source
# File lib/ec2/models/InstanceDiff.rb, line 57
def aws_tags
  @aws
end
diff_string() click to toggle source
# File lib/ec2/models/InstanceDiff.rb, line 61
def diff_string
  case @type
  when EBS, PROFILE, MONITORING, INTERFACES, SDCHECK, SUBNET, TYPE, TENANCY
    [
      "#{asset_type}:",
      Colors.aws_changes("\tAWS - #{aws}"),
      Colors.local_changes("\tLocal - #{local}"),
    ].join("\n")
  when SECURITY_GROUPS
    [
      "#{asset_type}:",
      @changes.removed.map { |sg| Colors.unmanaged("\t#{sg}") },
      @changes.added.map { |sg| Colors.added("\t#{sg}") }
    ].flatten.join("\n")
  when VOLUME_GROUPS
    [
      "#{asset_type}:",
      @changes.removed.map { |vg, _| Colors.unmanaged("\t#{vg} is attached but not managed by Cumulus") },
      @changes.added.map { |vg, _| Colors.added("\t#{vg} will be attached to the instance") },
      @changes.modified.map do |vg, diff|
        [
          "\t#{vg}:",
          diff.changes.map do |diff|
            diff.to_s.lines.map { |l| "\t\t#{l}".chomp("\n") }
          end
        ]
      end
    ].flatten.join("\n")
  when TAGS
    tags_diff_string
  end
end
local_tags() click to toggle source
# File lib/ec2/models/InstanceDiff.rb, line 53
def local_tags
  @local
end