HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority
Upload Files
File: //var/cache/puppet/lib/puppet/util/puppetdb_validator.rb
require 'puppet/network/http_pool'

# Validator class, for testing that PuppetDB is alive
class Puppet::Util::PuppetdbValidator
  attr_reader :puppetdb_server
  attr_reader :puppetdb_port
  attr_reader :use_ssl
  attr_reader :test_path
  attr_reader :test_headers

  def initialize(puppetdb_server, puppetdb_port, use_ssl = true, test_path = '/pdb/meta/v1/version')
    @puppetdb_server = puppetdb_server
    @puppetdb_port   = puppetdb_port
    @use_ssl         = use_ssl
    @test_path       = test_path
    @test_headers    = { 'Accept' => 'application/json' }
  end

  # Utility method; attempts to make an http/https connection to the puppetdb server.
  # This is abstracted out into a method so that it can be called multiple times
  # for retry attempts.
  #
  # @return true if the connection is successful, false otherwise.
  def attempt_connection
    # All that we care about is that we are able to connect successfully via
    # http(s), so here we're simpling hitting a somewhat arbitrary low-impact URL
    # on the puppetdb server.
    conn = Puppet::Network::HttpPool.http_instance(puppetdb_server, puppetdb_port, use_ssl)

    response = conn.get(test_path, test_headers)
    unless response.is_a?(Net::HTTPSuccess)
      Puppet.notice "Unable to connect to puppetdb server (http#{use_ssl ? 's' : ''}://#{puppetdb_server}:#{puppetdb_port}): [#{response.code}] #{response.msg}"
      return false
    end
    return true
  rescue StandardError => e
    Puppet.notice "Unable to connect to puppetdb server (http#{use_ssl ? 's' : ''}://#{puppetdb_server}:#{puppetdb_port}): #{e.message}"
    return false
  end
end