Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JSON to parse Foreman API responses #1142

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/puppet/functions/foreman/foreman.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def foreman(item, search, per_page = "20", foreman_url = "https://localhost", fo
http.use_ssl = true if uri.scheme == 'https'
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl?
end
results = Timeout::timeout(timeout) { PSON.parse http.request(req).body }
results = Timeout::timeout(timeout) { JSON.parse http.request(req).body }
rescue Exception => e
raise Puppet::ParseError, "Failed to contact Foreman at #{foreman_url}: #{e}"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/functions/foreman/smartvar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def smartvar(var, foreman_url = "http://foreman", foreman_user = "admin", forema
req['Accept'] = 'application/json'

begin
Timeout::timeout(5) { PSON.parse(http.request(req).body)["value"] }
Timeout::timeout(5) { JSON.parse(http.request(req).body)["value"] }
rescue Exception => e
raise Puppet::ParseError, "Failed to contact Foreman #{e}"
end
Expand Down
Loading