class Cumulus::AutoScaling::AlarmDiff
Public: Represents a single difference between local configuration and AWS configuration of Cloudwatch alarms
Attributes
Public Instance Methods
Public: Get the alarm actions that will be added
Returns an array of arns to add
# File lib/autoscaling/models/AlarmDiff.rb, line 104 def alarm_actions_to_add local_actions("alarm") - @aws.alarm_actions end
Public: Get the alarm actions that will be removed
Returns an array of arns to remove
# File lib/autoscaling/models/AlarmDiff.rb, line 97 def alarm_actions_to_remove @aws.alarm_actions - local_actions("alarm") end
# File lib/autoscaling/models/AlarmDiff.rb, line 86 def asset_type "Alarm" end
# File lib/autoscaling/models/AlarmDiff.rb, line 90 def aws_name @aws.alarm_name end
# File lib/autoscaling/models/AlarmDiff.rb, line 33 def diff_string diff_lines = [@local.name] case @type when ALARM lines = ["\tAlarm actions:"] lines << alarm_actions_to_remove.map { |a| "\t\t#{Colors.removed(a)}" } lines << alarm_actions_to_add.map { |a| "\t\t#{Colors.added(a)}" } diff_lines << lines.flatten.join("\n") when COMPARISON diff_lines << "\tComparison type: AWS - #{Colors.aws_changes(@aws.comparison_operator)}, Local - #{Colors.local_changes(@local.comparison)}" when DESCRIPTION diff_lines << [ "\tDescription:", Colors.aws_changes("\t\tAWS - #{@aws.alarm_description}"), Colors.local_changes("\t\tLocal - #{@local.description}") ].join("\n") when DIMENSIONS lines = ["\tDimensions:"] lines << dimensions_to_remove.map { |d| "\t\t#{Colors.removed(d)}" } lines << dimensions_to_add.map { |d| "\t\t#{Colors.added(d)}" } diff_lines << lines.flatten.join("\n") when ENABLED diff_lines << "\tActions enabled: AWS - #{Colors.aws_changes(@aws.actions_enabled)}, Local - #{Colors.local_changes(@local.actions_enabled)}" when EVALUATION diff_lines << "\tEvaluation periods: AWS - #{Colors.aws_changes(@aws.evaluation_periods)}, Local - #{Colors.local_changes(@local.evaluation_periods)}" when INSUFFICIENT lines = ["\tInsufficient data actions:"] lines << insufficient_actions_to_remove.map { |i| "\t\t#{Colors.removed(i)}" } lines << insufficient_actions_to_add.map { |i| "\t\t#{Colors.added(i)}" } diff_lines << lines.flatten.join("\n") when METRIC diff_lines << "\tMetric: AWS - #{Colors.aws_changes(@aws.metric_name)}, Local - #{Colors.local_changes(@local.metric)}" when NAMESPACE diff_lines << "\tNamespace: AWS - #{Colors.aws_changes(@aws.namespace)}, Local - #{Colors.local_changes(@local.namespace)}" when OK lines = ["\tOk actions:"] lines << ok_actions_to_remove.map { |o| "\t\t#{Colors.removed(o)}" } lines << ok_actions_to_add.map { |o| "\t\t#{Colors.added(o)}" } diff_lines << lines.flatten.join("\n") when PERIOD diff_lines << "\tPeriod seconds: AWS - #{Colors.aws_changes(@aws.period)}, Local - #{Colors.local_changes(@local.period)}" when STATISTIC diff_lines << "\tStatistic: AWS - #{Colors.aws_changes(@aws.statistic)}, Local - #{Colors.local_changes(@local.statistic)}" when THRESHOLD diff_lines << "\tThreshold: AWS - #{Colors.aws_changes(@aws.threshold)}, Local - #{Colors.local_changes(@local.threshold)}" when UNIT diff_lines << "\tUnit: AWS - #{Colors.aws_changes(@aws.unit)}, Local - #{Colors.local_changes(@local.unit)}" end diff_lines.flatten.join("\n") end
Public: Get the dimensions that will be added
Returns a hash of key value pairs to add
# File lib/autoscaling/models/AlarmDiff.rb, line 118 def dimensions_to_add @local.dimensions.reject { |k, v| aws_dimensions.include?(k) and aws_dimensions[k] == v } end
Public: Get the dimensions that will be removed
Returns a hash of key value pairs to be removed
# File lib/autoscaling/models/AlarmDiff.rb, line 111 def dimensions_to_remove aws_dimensions.reject { |k, v| @local.dimensions.include?(k) and @local.dimensions[k] == v } end
Public: Get the insufficient data actions that will be added
Returns an array of arns to add
# File lib/autoscaling/models/AlarmDiff.rb, line 132 def insufficient_actions_to_add local_actions("insufficient-data") - @aws.insufficient_data_actions end
Public: Get the insufficient data actions that will be removed
Returns an array of arns to remove
# File lib/autoscaling/models/AlarmDiff.rb, line 125 def insufficient_actions_to_remove @aws.insufficient_data_actions - local_actions("insufficient-data") end
Public: Get the ok actions that will be added
Returns an array of arns to add
# File lib/autoscaling/models/AlarmDiff.rb, line 146 def ok_actions_to_add local_actions("ok") - @aws.ok_actions end
Public: Get the ok actions that will be removed
Returns an array of arns to remove
# File lib/autoscaling/models/AlarmDiff.rb, line 139 def ok_actions_to_remove @aws.ok_actions - local_actions("ok") end
Private Instance Methods
Internal: Get the AWS dimensions in the same format as local configuration
Returns a hash of key value pairs
# File lib/autoscaling/models/AlarmDiff.rb, line 166 def aws_dimensions @aws_dimensions ||= Hash[@aws.dimensions.map { |d| [d.name, d.value] }] end
Internal: Get the actions defined locally for a particular state
Returns an array of arns
# File lib/autoscaling/models/AlarmDiff.rb, line 155 def local_actions(state) local_policies = [] if @local.action_states.include?(state) local_policies << @policy_arn end local_policies end