Class: Cumulus::ELB::ListenerDiff

Inherits:
Common::Diff show all
Includes:
ListenerChange
Defined in:
lib/elb/models/ListenerDiff.rb

Overview

Public: Represents a single difference between local configuration and an AWS Load Balancer Listener

Constant Summary

Constants included from ListenerChange

Cumulus::ELB::ListenerChange::INST_PORT, Cumulus::ELB::ListenerChange::INST_PROTOCOL, Cumulus::ELB::ListenerChange::LB_PORT, Cumulus::ELB::ListenerChange::LB_PROTOCOL, Cumulus::ELB::ListenerChange::POLICIES, Cumulus::ELB::ListenerChange::SSL

Constants included from Common::DiffChange

Common::DiffChange::ADD, Common::DiffChange::MODIFIED, Common::DiffChange::UNMANAGED

Instance Attribute Summary collapse

Attributes inherited from Common::Diff

#aws, #changes, #info_only, #local, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common::DiffChange

next_change_id

Methods inherited from Common::Diff

#add_string, added, #initialize, modified, #to_s, unmanaged

Constructor Details

This class inherits a constructor from Cumulus::Common::Diff

Instance Attribute Details

#policiesObject

Returns the value of attribute policies.



23
24
25
# File 'lib/elb/models/ListenerDiff.rb', line 23

def policies
  @policies
end

Class Method Details

.policies(aws, local) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/elb/models/ListenerDiff.rb', line 41

def self.policies(aws, local)
  added = local - aws
  removed = aws - local
  diff = ListenerDiff.new(POLICIES, aws, local)
  diff.policies = Common::ListChange.new(added, removed)
  diff
end

Instance Method Details

#asset_typeObject



25
26
27
# File 'lib/elb/models/ListenerDiff.rb', line 25

def asset_type
  "Listener for port"
end

#aws_nameObject



29
30
31
# File 'lib/elb/models/ListenerDiff.rb', line 29

def aws_name
  "#{aws.listener.load_balancer_port}"
end

#diff_stringObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/elb/models/ListenerDiff.rb', line 49

def diff_string
  case @type
  when LB_PROTOCOL
    [
      "load balancer protocol:",
      Colors.aws_changes("\tAWS - #{aws}"),
      Colors.local_changes("\tLocal - #{local}"),
    ].join("\n")
  when LB_PORT
    [
      "load balancer port:",
      Colors.aws_changes("\tAWS - #{aws}"),
      Colors.local_changes("\tLocal - #{local}"),
    ].join("\n")
  when INST_PROTOCOL
    [
      "instance protocol:",
      Colors.aws_changes("\tAWS - #{aws}"),
      Colors.local_changes("\tLocal - #{local}"),
    ].join("\n")
  when INST_PORT
    [
      "instance port:",
      Colors.aws_changes("\tAWS - #{aws}"),
      Colors.local_changes("\tLocal - #{local}"),
    ].join("\n")
  when SSL
    [
      "ssl certificate id:",
      Colors.aws_changes("\tAWS - #{aws}"),
      Colors.local_changes("\tLocal - #{local}"),
    ].join("\n")
  when POLICIES
    [
      "policies:",
      @policies.removed.map { |p| Colors.removed("\t#{p}") },
      @policies.added.map { |p| Colors.added("\t#{p}") },
    ].flatten.join("\n")
  end
end

#local_nameObject



33
34
35
# File 'lib/elb/models/ListenerDiff.rb', line 33

def local_name
  "#{local.load_balancer_port}"
end

#unmanaged_stringObject



37
38
39
# File 'lib/elb/models/ListenerDiff.rb', line 37

def unmanaged_string
  "will be deleted."
end