|
|
@ -153,11 +153,18 @@ def check(module, name, state, service_id, integration_key, api_key, incident_ke
|
|
|
|
if info['status'] != 200:
|
|
|
|
if info['status'] != 200:
|
|
|
|
module.fail_json(msg="failed to check current incident status."
|
|
|
|
module.fail_json(msg="failed to check current incident status."
|
|
|
|
"Reason: %s" % info['msg'])
|
|
|
|
"Reason: %s" % info['msg'])
|
|
|
|
json_out = json.loads(response.read())["incidents"][0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if state != json_out["status"]:
|
|
|
|
incidents = json.loads(response.read())["incidents"]
|
|
|
|
return json_out, True
|
|
|
|
msg = "No corresponding incident"
|
|
|
|
return json_out, False
|
|
|
|
|
|
|
|
|
|
|
|
if len(incidents) == 0:
|
|
|
|
|
|
|
|
if state in ('acknowledged', 'resolved'):
|
|
|
|
|
|
|
|
return msg, False
|
|
|
|
|
|
|
|
return msg, True
|
|
|
|
|
|
|
|
elif state != incidents[0]["status"]:
|
|
|
|
|
|
|
|
return incidents[0], True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return incidents[0], False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def send_event(module, service_key, event_type, desc,
|
|
|
|
def send_event(module, service_key, event_type, desc,
|
|
|
|