Post reports to newer Foreman API endpoint (#64955)

The `/api/v2/reports` endpoint has been deprecated a long time ago and should
no longer be used. This changes to callback to use the correct API
endpoint and paramerter.
pull/65665/merge
Tomer Brisker 4 years ago committed by GitHub
parent 435bd91d2e
commit a4f5c2e993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -202,7 +202,7 @@ class CallbackModule(CallbackBase):
metrics["time"] = {"total": int(time.time()) - self.start_time} metrics["time"] = {"total": int(time.time()) - self.start_time}
now = datetime.now().strftime(self.TIME_FORMAT) now = datetime.now().strftime(self.TIME_FORMAT)
report = { report = {
"report": { "config_report": {
"host": host, "host": host,
"reported_at": now, "reported_at": now,
"metrics": metrics, "metrics": metrics,
@ -210,11 +210,8 @@ class CallbackModule(CallbackBase):
"logs": log, "logs": log,
} }
} }
# To be changed to /api/v2/config_reports in 1.11. Maybe we
# could make a GET request to get the Foreman version & do
# this automatically.
try: try:
r = requests.post(url=self.FOREMAN_URL + '/api/v2/reports', r = requests.post(url=self.FOREMAN_URL + '/api/v2/config_reports',
data=json.dumps(report), data=json.dumps(report),
headers=self.FOREMAN_HEADERS, headers=self.FOREMAN_HEADERS,
cert=self.FOREMAN_SSL_CERT, cert=self.FOREMAN_SSL_CERT,

Loading…
Cancel
Save