Class: Kelbim::ELBWrapper::LoadBalancerCollection::LoadBalancer::ListenerCollection::Listener
- Inherits:
-
Object
- Object
- Kelbim::ELBWrapper::LoadBalancerCollection::LoadBalancer::ListenerCollection::Listener
- Extended by:
- Forwardable
- Includes:
- Logger::ClientHelper
- Defined in:
- lib/kelbim/wrapper/policy.rb,
lib/kelbim/wrapper/listener.rb,
lib/kelbim/wrapper/policy-collection.rb
Defined Under Namespace
Classes: PolicyCollection
Instance Method Summary collapse
- #delete ⇒ Object
- #eql?(dsl) ⇒ Boolean
- #has_difference_protocol_port?(dsl) ⇒ Boolean
-
#initialize(listener, options) ⇒ Listener
constructor
A new instance of Listener.
- #log_id ⇒ Object
- #policies ⇒ Object
- #update(dsl) ⇒ Object
- #update_policies(policy_list, old_policy_list) ⇒ Object
Methods included from Logger::ClientHelper
Constructor Details
#initialize(listener, options) ⇒ Listener
Returns a new instance of Listener.
14 15 16 17 |
# File 'lib/kelbim/wrapper/listener.rb', line 14 def initialize(listener, ) @listener = listener @options = end |
Instance Method Details
#delete ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/kelbim/wrapper/listener.rb', line 74 def delete log(:info, 'Delete Listener', :red, log_id) = self.policies unless @options.dry_run @listener.delete @options.updated = true end unless @options.without_deleting_policy .each do |plcy| plcy.delete end end end |
#eql?(dsl) ⇒ Boolean
23 24 25 |
# File 'lib/kelbim/wrapper/listener.rb', line 23 def eql?(dsl) not has_difference_protocol_port?(dsl) and compare_server_certificate(dsl) and compare_ssl_certificate_id(dsl) end |
#has_difference_protocol_port?(dsl) ⇒ Boolean
91 92 93 94 95 96 97 98 |
# File 'lib/kelbim/wrapper/listener.rb', line 91 def has_difference_protocol_port?(dsl) not ( @listener.protocol == dsl.protocol && @listener.port == dsl.port && @listener.instance_protocol == dsl.instance_protocol && @listener.instance_port == dsl.instance_port ) end |
#log_id ⇒ Object
100 101 102 103 |
# File 'lib/kelbim/wrapper/listener.rb', line 100 def log_id log_id = [[@listener.protocol, @listener.port], [@listener.instance_protocol, @listener.instance_port]].map {|i| i.inspect }.join(' => ') "#{@listener.load_balancer.vpc_id || :classic} > #{@listener.load_balancer.name} > #{log_id}" end |
#policies ⇒ Object
19 20 21 |
# File 'lib/kelbim/wrapper/listener.rb', line 19 def policies PolicyCollection.new(@listener.policies, self, @options) end |
#update(dsl) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/kelbim/wrapper/listener.rb', line 27 def update(dsl) log(:info, 'Update Listener', :green, log_id) compare_server_certificate(dsl) do |old_data, new_data| log(:info, " server_certificate:", :green) log(:info, Kelbim::Utils.diff(old_data, new_data, :color => @options[:color], :indent => ' '), false) unless @options.dry_run ss = @options.iam.server_certificates[dsl.server_certificate] unless ss raise "Can't find ServerCertificate: #{ss_name} in #{log_id}" end @listener.server_certificate = ss @options.updated = true end end compare_ssl_certificate_id(dsl) do |old_data, new_data| log(:info, " ssl_certificate_id:", :green) log(:info, Kelbim::Utils.diff(old_data, new_data, :color => @options[:color], :indent => ' '), false) unless @options.dry_run @listener.ssl_certificate_id = dsl.ssl_certificate_id @options.updated = true end end end |
#update_policies(policy_list, old_policy_list) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/kelbim/wrapper/listener.rb', line 57 def update_policies(policy_list, old_policy_list) old_data = old_policy_list.map {|i| i.name }.sort new_data = policy_list.map {|i| i.name }.sort log(:info, 'Update Listener Policies', :green, log_id) log(:info, Kelbim::Utils.diff(old_data, new_data, :color => @options[:color], :indent => ' '), false) unless @options.dry_run @options.elb.client.set_load_balancer_policies_of_listener({ :load_balancer_name => @listener.load_balancer.name, :load_balancer_port => @listener.port, :policy_names => policy_list.map {|i| i.name }, }) @options.updated = true end end |