mirror of
https://github.com/ansible/awx.git
synced 2026-04-10 20:49:24 -02:30
Update the Insights action plugin to make calls against the new API
This commit is contained in:
@@ -9,8 +9,9 @@ from ansible.plugins.action import ActionBase
|
|||||||
|
|
||||||
class ActionModule(ActionBase):
|
class ActionModule(ActionBase):
|
||||||
|
|
||||||
def save_playbook(self, proj_path, plan, content):
|
def save_playbook(self, proj_path, remediation, content):
|
||||||
fname = '{}-{}.yml'.format(plan.get('name', None) or 'insights-plan', plan['maintenance_id'])
|
fname = '{}-{}.yml'.format(
|
||||||
|
remediation.get('name', None) or 'insights-remediation', remediation['id'])
|
||||||
file_path = os.path.join(proj_path, fname)
|
file_path = os.path.join(proj_path, fname)
|
||||||
with open(file_path, 'wb') as f:
|
with open(file_path, 'wb') as f:
|
||||||
f.write(content)
|
f.write(content)
|
||||||
@@ -55,7 +56,7 @@ class ActionModule(ActionBase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
url = '{}/r/insights/v3/maintenance?ansible=true'.format(insights_url)
|
url = '{}/r/insights/platform/remediations/v1/remediations?sort=-updated_at'.format(insights_url)
|
||||||
|
|
||||||
res = session.get(url, headers=headers, timeout=120)
|
res = session.get(url, headers=headers, timeout=120)
|
||||||
|
|
||||||
@@ -79,8 +80,9 @@ class ActionModule(ActionBase):
|
|||||||
result['version'] = version
|
result['version'] = version
|
||||||
return result
|
return result
|
||||||
|
|
||||||
for item in res.json():
|
for item in res.json()['remediations']:
|
||||||
url = '{}/r/insights/v3/maintenance/{}/playbook'.format(insights_url, item['maintenance_id'])
|
url = '{}/r/insights/platform/remediations/v1/remediations/{}/playbook'.format(
|
||||||
|
insights_url, item['id'])
|
||||||
res = session.get(url, timeout=120)
|
res = session.get(url, timeout=120)
|
||||||
if res.status_code != 200:
|
if res.status_code != 200:
|
||||||
result['failed'] = True
|
result['failed'] = True
|
||||||
|
|||||||
Reference in New Issue
Block a user