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) ⇒ Object



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

def post_arf_report(cname, policy_id, date, data)
  begin
    json_data = Proxy::OpenSCAP::Parse.new(data).as_json
    foreman_api_path = upload_path(cname, policy_id, date)
    response = send_request(foreman_api_path, json_data)
    # Raise an HTTP error if the response is not 2xx (success).
    response.value
    res = JSON.parse(response.body)
    raise StandardError, "Received response: #{response.code} #{response.msg}" unless res['result'] == 'OK'
  rescue StandardError => e
    logger.debug response.body if response
    logger.debug e.backtrace.join("\n\t")
    raise e
  end
  res
end