diff --git a/lso/__init__.py b/lso/__init__.py index 831469bfe5822cdf321261bd5e48a285c6451c64..7f48d92984c3061292aa475d52e3bd63bf3abcd7 100644 --- a/lso/__init__.py +++ b/lso/__init__.py @@ -5,7 +5,7 @@ from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware 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: @@ -26,7 +26,7 @@ def create_app() -> FastAPI: ) 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") # test that config params are loaded and available diff --git a/lso/playbook.py b/lso/playbook.py index 73fac95a30a6bf429e63b9d97f1769548f33df3e..7855588ee971383ace99f639c9c45fc26cfd9c3b 100644 --- a/lso/playbook.py +++ b/lso/playbook.py @@ -94,7 +94,7 @@ def _run_playbook_proc(job_id: str, playbook_path: str, extra_vars: dict, invent try: task_output = json.loads(line) 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 # want all steps, including those that didn't make changes. diff --git a/lso/routes/device.py b/lso/routes/router.py similarity index 81% rename from lso/routes/device.py rename to lso/routes/router.py index 2e2b86598f7445449a15f93420b095e9383f458c..5c19d593bde538e3045effb793eacbfd22a07c2a 100644 --- a/lso/routes/device.py +++ b/lso/routes/router.py @@ -42,20 +42,17 @@ async def provision_node(params: NodeProvisioningParams) -> playbook.PlaybookLau :rtype: :class:`lso.playbook.PlaybookLaunchResponse` """ extra_vars = { - "wfo_device_json": params.subscription, + "wfo_router_json": params.subscription, "dry_run": str(params.dry_run), "verb": "deploy", "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") - else: - raise ValueError(f"Cannot find playbook path for device type " f"{params.subscription['device_type']}!!") + playbook_path = os.path.join(config_params.ansible_playbooks_root_dir, "base_config.yaml") return playbook.run_playbook( playbook_path=playbook_path, - inventory=f"{params.subscription['device']['device_fqdn']}", + inventory=f"{params.subscription['router']['router_fqdn']}", extra_vars=extra_vars, callback=params.callback, )