Class: Proxy::OpenSCAP::ForemanForwarder

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

Instance Method Summary collapse

Instance Method Details

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



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

def post_arf_report(cname, policy_id, date, data, timeout)
  begin
    foreman_api_path = upload_path(cname, policy_id, date)
    json = Proxy::OpenSCAP::ArfParser.new(cname, policy_id, date).as_json(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
end