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
21
22
23
24
25
# File 'lib/smart_proxy_openscap/foreman_forwarder.rb', line 5

def post_arf_report(cname, policy_id, date, data)
    parser = Proxy::OpenSCAP::Parse.new(data)
  begin
    foreman_api_path = upload_path(cname, policy_id, date)
    response = send_request(foreman_api_path, parser.as_json)
    # 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 OpenSCAP::OpenSCAPError => e
    logger.debug e.backtrace.join("\n\t")
    raise e
  rescue StandardError => e
    logger.debug response.body if response
    logger.debug e.backtrace.join("\n\t")
    raise e
  ensure
    parser.cleanup
  end
  res
end