Sha256: 674ab4cfd986b66aa84502514779ddd5888894747ad05c53ba05bc06b4caa38a

Contents?: true

Size: 854 Bytes

Versions: 4

Compression:

Stored size: 854 Bytes

Contents

require 'puppet/indirector/status'
require 'puppet/indirector/rest'

class Puppet::Indirector::Status::Rest < Puppet::Indirector::REST

  desc "Get puppet master's status via REST. Useful because it tests the health
    of both the web server and the indirector."

  def find(request)
    return super unless use_http_client?

    session = Puppet.lookup(:http_session)
    api = session.route_to(:puppet)
    api.get_status(request.key)
  rescue Puppet::HTTP::ResponseError => e
    if e.response.code == 404
      return nil unless request.options[:fail_on_404]

      _, body = parse_response(e.response.nethttp)
      msg = _("Find %{uri} resulted in 404 with the message: %{body}") % { uri: elide(e.response.url.path, 100), body: body }
      raise Puppet::Error, msg
    else
      raise convert_to_http_error(e.response.nethttp)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-6.14.0 lib/puppet/indirector/status/rest.rb
puppet-6.14.0-x86-mingw32 lib/puppet/indirector/status/rest.rb
puppet-6.14.0-x64-mingw32 lib/puppet/indirector/status/rest.rb
puppet-6.14.0-universal-darwin lib/puppet/indirector/status/rest.rb