Class: Puppet::Util::EsInstanceValidator
- Inherits:
- 
      Object
      
        - Object
- Puppet::Util::EsInstanceValidator
 
- Defined in:
- lib/puppet/util/es_instance_validator.rb
Instance Attribute Summary collapse
- 
  
    
      #instance_port  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute instance_port. 
- 
  
    
      #instance_server  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute instance_server. 
Instance Method Summary collapse
- 
  
    
      #attempt_connection  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Utility method; attempts to make an https connection to the Elasticsearch instance. 
- 
  
    
      #initialize(instance_server, instance_port)  ⇒ EsInstanceValidator 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of EsInstanceValidator. 
Constructor Details
#initialize(instance_server, instance_port) ⇒ EsInstanceValidator
Returns a new instance of EsInstanceValidator.
| 10 11 12 13 14 15 16 17 18 19 20 | # File 'lib/puppet/util/es_instance_validator.rb', line 10 def initialize(instance_server, instance_port) @instance_server = instance_server @instance_port = instance_port # Avoid deprecation warnings in Puppet versions < 4 if Facter.value(:puppetversion).split('.').first.to_i < 4 @timeout = Puppet[:configtimeout] else @timeout = Puppet[:http_connect_timeout] end end | 
Instance Attribute Details
#instance_port ⇒ Object (readonly)
Returns the value of attribute instance_port.
| 8 9 10 | # File 'lib/puppet/util/es_instance_validator.rb', line 8 def instance_port @instance_port end | 
#instance_server ⇒ Object (readonly)
Returns the value of attribute instance_server.
| 7 8 9 | # File 'lib/puppet/util/es_instance_validator.rb', line 7 def instance_server @instance_server end | 
Instance Method Details
#attempt_connection ⇒ Object
Utility method; attempts to make an https connection to the Elasticsearch instance. This is abstracted out into a method so that it can be called multiple times for retry attempts.
| 27 28 29 30 31 32 33 34 35 36 37 38 39 | # File 'lib/puppet/util/es_instance_validator.rb', line 27 def attempt_connection Timeout::timeout(@timeout) do begin TCPSocket.new(@instance_server, @instance_port).close true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH => e Puppet.debug "Unable to connect to Elasticsearch instance (#{@instance_server}:#{@instance_port}): #{e.}" false end end rescue Timeout::Error false end |