Class: Proxy::OpenSCAP::ForemanForwarder

Inherits:
HttpRequest::ForemanRequest
  • Object
show all
Includes:
Log
Defined in:
lib/smart_proxy_openscap/foreman_forwarder.rb

Direct Known Subclasses

ForemanArfForwarder

Instance Method Summary collapse

Instance Method Details

#post_report(cname, policy_id, date, data, timeout) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/smart_proxy_openscap/foreman_forwarder.rb', line 7

def post_report(cname, policy_id, date, data, timeout)
  foreman_api_path = report_upload_path(cname, policy_id, date)

  json = parse_report(cname, policy_id, date, data)
  response = send_request(foreman_api_path, json, timeout)
  # Raise an HTTP error if the response is not 2xx (success).
  response.value
  JSON.parse(response.body)
rescue Net::HTTPServerException => e
  logger.debug "Received response: #{response.code} #{response.msg}"
  logger.debug response.body
  raise ReportUploadError, e.message if response.code.to_i == 422
  raise e
end