Class: Puppet::HTTP::Service::Compiler Private
- Inherits:
-
Puppet::HTTP::Service
- Object
- Puppet::HTTP::Service
- Puppet::HTTP::Service::Compiler
- Defined in:
- lib/puppet/http/service/compiler.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
The Compiler service is used to submit and retrieve data from the puppetserver.
Constant Summary collapse
- API =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Returns Default API for the Compiler service.
'/puppet/v3'.freeze
Constants inherited from Puppet::HTTP::Service
EXCLUDED_FORMATS, SERVICE_NAMES
Instance Attribute Summary
Attributes inherited from Puppet::HTTP::Service
Instance Method Summary collapse
-
#get_facts(name, environment:) ⇒ Array<Puppet::HTTP::Response, Puppet::Node::Facts>
private
Submit a GET request to retrieve the facts for the named node.
-
#get_filebucket_file(path, environment:, bucket_path: nil, diff_with: nil, list_all: nil, fromdate: nil, todate: nil) ⇒ Array<Puppet::HTTP::Response, Puppet::FileBucket::File>
private
Submit a GET request to retrieve a file stored with filebucket.
-
#get_node(name, environment:, configured_environment: nil, transaction_uuid: nil) ⇒ Array<Puppet::HTTP::Response, Puppet::Node>
private
Submit a GET request to retrieve a node from the server.
-
#get_status(name) ⇒ Array<Puppet::HTTP::Response, Puppet::Status>
private
Submit a GET request to find the status of a compiler.
-
#head_filebucket_file(path, environment:, bucket_path: nil) ⇒ Puppet::HTTP::Response
private
Submit a HEAD request to check the status of a file stored with filebucket.
-
#initialize(client, session, server, port) ⇒ Compiler
constructor
private
A new instance of Compiler.
-
#post_catalog(name, facts:, environment:, configured_environment: nil, transaction_uuid: nil, job_uuid: nil, static_catalog: true, checksum_type: ) ⇒ Array<Puppet::HTTP::Response, Puppet::Resource::Catalog>
private
Submit a POST request to submit a catalog to the server.
-
#put_facts(name, environment:, facts:) ⇒ Puppet::HTTP::Response
private
Submits a PUT request to submit facts for the node to the server.
-
#put_filebucket_file(path, body:, environment:) ⇒ Puppet::HTTP::Response
private
Submit a PUT request to store a file with filebucket.
Methods inherited from Puppet::HTTP::Service
#connect, create_service, valid_name?, #with_base_url
Constructor Details
#initialize(client, session, server, port) ⇒ Compiler
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Compiler.
24 25 26 27 |
# File 'lib/puppet/http/service/compiler.rb', line 24 def initialize(client, session, server, port) url = build_url(API, server || Puppet[:server], port || Puppet[:serverport]) super(client, session, url) end |
Instance Method Details
#get_facts(name, environment:) ⇒ Array<Puppet::HTTP::Response, Puppet::Node::Facts>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Submit a GET request to retrieve the facts for the named node
144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/puppet/http/service/compiler.rb', line 144 def get_facts(name, environment:) headers = add_puppet_headers('Accept' => get_mime_types(Puppet::Node::Facts).join(', ')) response = @client.get( with_base_url("/facts/#{name}"), headers: headers, params: { environment: environment } ) process_response(response) [response, deserialize(response, Puppet::Node::Facts)] end |
#get_filebucket_file(path, environment:, bucket_path: nil, diff_with: nil, list_all: nil, fromdate: nil, todate: nil) ⇒ Array<Puppet::HTTP::Response, Puppet::FileBucket::File>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Submit a GET request to retrieve a file stored with filebucket
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/puppet/http/service/compiler.rb', line 236 def get_filebucket_file(path, environment:, bucket_path: nil, diff_with: nil, list_all: nil, fromdate: nil, todate: nil) headers = add_puppet_headers('Accept' => 'application/octet-stream') response = @client.get( with_base_url("/file_bucket_file/#{path}"), headers: headers, params: { environment: environment, bucket_path: bucket_path, diff_with: diff_with, list_all: list_all, fromdate: fromdate, todate: todate } ) process_response(response) [response, deserialize(response, Puppet::FileBucket::File)] end |
#get_node(name, environment:, configured_environment: nil, transaction_uuid: nil) ⇒ Array<Puppet::HTTP::Response, Puppet::Node>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Submit a GET request to retrieve a node from the server
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/puppet/http/service/compiler.rb', line 44 def get_node(name, environment:, configured_environment: nil, transaction_uuid: nil) headers = add_puppet_headers('Accept' => get_mime_types(Puppet::Node).join(', ')) response = @client.get( with_base_url("/node/#{name}"), headers: headers, params: { environment: environment, configured_environment: configured_environment || environment, transaction_uuid: transaction_uuid, } ) process_response(response) [response, deserialize(response, Puppet::Node)] end |
#get_status(name) ⇒ Array<Puppet::HTTP::Response, Puppet::Status>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Submit a GET request to find the status of a compiler
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
# File 'lib/puppet/http/service/compiler.rb', line 199 def get_status(name) headers = add_puppet_headers('Accept' => get_mime_types(Puppet::Status).join(', ')) response = @client.get( with_base_url("/status/#{name}"), headers: headers, params: { # environment is required, but meaningless, default to production environment: 'production' }, ) process_response(response) [response, deserialize(response, Puppet::Status)] end |
#head_filebucket_file(path, environment:, bucket_path: nil) ⇒ Puppet::HTTP::Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Submit a HEAD request to check the status of a file stored with filebucket
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/puppet/http/service/compiler.rb', line 303 def head_filebucket_file(path, environment:, bucket_path: nil) headers = add_puppet_headers('Accept' => 'application/octet-stream') response = @client.head( with_base_url("/file_bucket_file/#{path}"), headers: headers, params: { environment: environment, bucket_path: bucket_path } ) process_response(response) response end |
#post_catalog(name, facts:, environment:, configured_environment: nil, transaction_uuid: nil, job_uuid: nil, static_catalog: true, checksum_type: ) ⇒ Array<Puppet::HTTP::Response, Puppet::Resource::Catalog>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Submit a POST request to submit a catalog to the server
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/puppet/http/service/compiler.rb', line 88 def post_catalog(name, facts:, environment:, configured_environment: nil, transaction_uuid: nil, job_uuid: nil, static_catalog: true, checksum_type: Puppet[:supported_checksum_types]) if Puppet[:preferred_serialization_format] == "pson" formatter = Puppet::Network::FormatHandler.format_for(:pson) # must use 'pson' instead of 'text/pson' facts_format = 'pson' else formatter = Puppet::Network::FormatHandler.format_for(:json) facts_format = formatter.mime end facts_as_string = serialize(formatter, facts) # query parameters are sent in the POST request body body = { facts_format: facts_format, facts: Puppet::Util.uri_query_encode(facts_as_string), environment: environment, configured_environment: configured_environment || environment, transaction_uuid: transaction_uuid, job_uuid: job_uuid, static_catalog: static_catalog, checksum_type: checksum_type.join('.') }.map do |key, value| "#{key}=#{Puppet::Util.uri_query_encode(value.to_s)}" end.join("&") headers = add_puppet_headers( 'Accept' => get_mime_types(Puppet::Resource::Catalog).join(', '), 'Content-Type' => 'application/x-www-form-urlencoded' ) response = @client.post( with_base_url("/catalog/#{name}"), body, headers: headers, # for legacy reasons we always send environment as a query parameter too params: { environment: environment }, ) process_response(response) [response, deserialize(response, Puppet::Resource::Catalog)] end |
#put_facts(name, environment:, facts:) ⇒ Puppet::HTTP::Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Submits a PUT request to submit facts for the node to the server
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/puppet/http/service/compiler.rb', line 169 def put_facts(name, environment:, facts:) formatter = Puppet::Network::FormatHandler.format_for(Puppet[:preferred_serialization_format]) headers = add_puppet_headers( 'Accept' => get_mime_types(Puppet::Node::Facts).join(', '), 'Content-Type' => formatter.mime ) response = @client.put( with_base_url("/facts/#{name}"), serialize(formatter, facts), headers: headers, params: { environment: environment }, ) process_response(response) response end |
#put_filebucket_file(path, body:, environment:) ⇒ Puppet::HTTP::Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Submit a PUT request to store a file with filebucket
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/puppet/http/service/compiler.rb', line 270 def put_filebucket_file(path, body:, environment:) headers = add_puppet_headers({ 'Accept' => 'application/octet-stream', 'Content-Type' => 'application/octet-stream' }) response = @client.put( with_base_url("/file_bucket_file/#{path}"), body, headers: headers, params: { environment: environment } ) process_response(response) response end |