Skip to content
Snippets Groups Projects
Commit ffbccc7f authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

add redundant key, change handling of Nokia config diff

parent 29003b99
No related branches found
No related tags found
1 merge request!42less verbose Nokia output
...@@ -7,6 +7,7 @@ import uuid ...@@ -7,6 +7,7 @@ import uuid
import ansible_runner import ansible_runner
import requests import requests
import xmltodict
from pydantic import BaseModel, HttpUrl from pydantic import BaseModel, HttpUrl
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -89,6 +90,7 @@ def _run_playbook_proc(job_id: str, playbook_path: str, extra_vars: dict, invent ...@@ -89,6 +90,7 @@ def _run_playbook_proc(job_id: str, playbook_path: str, extra_vars: dict, invent
"invocation", "invocation",
"include", "include",
"include_args", "include_args",
"server_capabilities",
] ]
for line in json_content.strip().splitlines(): for line in json_content.strip().splitlines():
try: try:
...@@ -110,8 +112,18 @@ def _run_playbook_proc(job_id: str, playbook_path: str, extra_vars: dict, invent ...@@ -110,8 +112,18 @@ def _run_playbook_proc(job_id: str, playbook_path: str, extra_vars: dict, invent
continue continue
if "diff_lines" in task_result: if "diff_lines" in task_result:
# Juniper-specific
# Prevent the diff from being displayed twice, and only keep the formatted version. # Prevent the diff from being displayed twice, and only keep the formatted version.
task_result.pop("diff", None) task_result.pop("diff", None)
elif "before" in task_result["diff"] and "after" in task_result["diff"]:
# Nokia-specific
# We have a chunk of Nokia config, and we would like to show the actual diff, not a full before and
# after. This will take some extra steps.
before_parsed = xmltodict.parse(task_result["diff"]["before"])
after_parsed = xmltodict.parse(task_result["diff"]["after"])
# Only leave the diff in the resulting output
task_result["diff"] = {k: v for k, v in after_parsed.items() if
k not in before_parsed or v != before_parsed[k]}
if bool(task_result): if bool(task_result):
# Only add the event if there are any relevant keys left. # Only add the event if there are any relevant keys left.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment