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

migrate device to router, fix bug with playbook output

parent 95ba15a2
No related branches found
No related tags found
1 merge request!41Feature/migrate device to router
Pipeline #83831 failed
...@@ -5,7 +5,7 @@ from fastapi import FastAPI ...@@ -5,7 +5,7 @@ from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.cors import CORSMiddleware
from lso import config, environment from lso import config, environment
from lso.routes import default, device, ip_trunk from lso.routes import default, router, ip_trunk
def create_app() -> FastAPI: def create_app() -> FastAPI:
...@@ -26,7 +26,7 @@ def create_app() -> FastAPI: ...@@ -26,7 +26,7 @@ def create_app() -> FastAPI:
) )
app.include_router(default.router, prefix="/api") app.include_router(default.router, prefix="/api")
app.include_router(device.router, prefix="/api/device") app.include_router(router.router, prefix="/api/router")
app.include_router(ip_trunk.router, prefix="/api/ip_trunk") app.include_router(ip_trunk.router, prefix="/api/ip_trunk")
# test that config params are loaded and available # test that config params are loaded and available
......
...@@ -94,7 +94,7 @@ def _run_playbook_proc(job_id: str, playbook_path: str, extra_vars: dict, invent ...@@ -94,7 +94,7 @@ def _run_playbook_proc(job_id: str, playbook_path: str, extra_vars: dict, invent
try: try:
task_output = json.loads(line) task_output = json.loads(line)
if "res" in task_output["event_data"] and ( if "res" in task_output["event_data"] and (
task_output["event_data"]["res"]["changed"] is True or int(ansible_playbook_run.rc) != 0 int(ansible_playbook_run.rc) != 0 or task_output["event_data"]["res"]["changed"] is True
): ):
# The line contains result data, and must either consist of a change, or the playbook failed, and we # The line contains result data, and must either consist of a change, or the playbook failed, and we
# want all steps, including those that didn't make changes. # want all steps, including those that didn't make changes.
......
...@@ -42,20 +42,17 @@ async def provision_node(params: NodeProvisioningParams) -> playbook.PlaybookLau ...@@ -42,20 +42,17 @@ async def provision_node(params: NodeProvisioningParams) -> playbook.PlaybookLau
:rtype: :class:`lso.playbook.PlaybookLaunchResponse` :rtype: :class:`lso.playbook.PlaybookLaunchResponse`
""" """
extra_vars = { extra_vars = {
"wfo_device_json": params.subscription, "wfo_router_json": params.subscription,
"dry_run": str(params.dry_run), "dry_run": str(params.dry_run),
"verb": "deploy", "verb": "deploy",
"commit_comment": "Base config deployed with WFO/LSO & Ansible", "commit_comment": "Base config deployed with WFO/LSO & Ansible",
} }
if params.subscription["device_type"] == "router": playbook_path = os.path.join(config_params.ansible_playbooks_root_dir, "base_config.yaml")
playbook_path = os.path.join(config_params.ansible_playbooks_root_dir, "base_config.yaml")
else:
raise ValueError(f"Cannot find playbook path for device type " f"{params.subscription['device_type']}!!")
return playbook.run_playbook( return playbook.run_playbook(
playbook_path=playbook_path, playbook_path=playbook_path,
inventory=f"{params.subscription['device']['device_fqdn']}", inventory=f"{params.subscription['router']['router_fqdn']}",
extra_vars=extra_vars, extra_vars=extra_vars,
callback=params.callback, callback=params.callback,
) )
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment