Class: Puppet::HTTP::Service::Puppetserver

Inherits:
Puppet::HTTP::Service show all
Defined in:
lib/puppet/http/service/puppetserver.rb

Overview

The puppetserver service.

Constant Summary

Constants inherited from Puppet::HTTP::Service

EXCLUDED_FORMATS, SERVICE_NAMES

Instance Attribute Summary

Attributes inherited from Puppet::HTTP::Service

#url

Instance Method Summary collapse

Methods inherited from Puppet::HTTP::Service

#connect, create_service, valid_name?, #with_base_url

Constructor Details

#initialize(client, session, server, port) ⇒ Puppetserver

Use ‘Puppet::HTTP::Session.route_to(:puppetserver)` to create or get an instance of this class.

Parameters:

  • client (Puppet::HTTP::Client)
  • session (Puppet::HTTP::Session)
  • server (String)

    (‘Puppet`) If an explicit server is given, create a service using that server. If server is nil, the default value is used to create the service.

  • port (Integer)

    (‘Puppet`) If an explicit port is given, create a service using that port. If port is nil, the default value is used to create the service.



19
20
21
22
# File 'lib/puppet/http/service/puppetserver.rb', line 19

def initialize(client, session, server, port)
  url = build_url('', server || Puppet[:server], port || Puppet[:serverport])
  super(client, session, url)
end

Instance Method Details

#get_simple_status(ssl_context: nil) ⇒ Object

Request the puppetserver’s simple status.

the connection.

Parameters:

Returns:

  • Puppet::HTTP::Response The HTTP response



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/puppet/http/service/puppetserver.rb', line 32

def get_simple_status(ssl_context: nil)
  request_path = "/status/v1/simple/server"

  begin
    response = @client.get(
      with_base_url(request_path),
      headers: add_puppet_headers({}),
      options: { ssl_context: ssl_context }
    )

    process_response(response)
  rescue Puppet::HTTP::ResponseError => e
    if e.response.code == 404 && e.response.url.path == "/status/v1/simple/server"
      request_path = "/status/v1/simple/master"
      retry
    else
      raise e
    end
  end

  [response, response.body.to_s]
end