Skip to content

Lso calls

CLI for GSO pre-check using LSO remote exec endpoint.

_load_import_file(import_file_path)

Read a JSON file from the given path, return it as a compact JSON string, Exits on error.

Source code in gso/cli/lso_calls.py
def _load_import_file(import_file_path: Path) -> str:
    """Read a JSON file from the given path, return it as a compact JSON string, Exits on error."""
    try:
        with import_file_path.open("r", encoding="utf-8") as f:
            data = json.load(f)
        return json.dumps(data, separators=(",", ":"))
    except Exception as e:
        logger.exception("Failed to read import file")
        typer.echo(f"Error: could not read or parse '{import_file_path}': {e}")
        raise typer.Exit(2) from e

bgp_status_precheck(host=typer.Argument(..., help='FQDN of the router to pre-check'), partner=typer.Argument(..., help='Partner name for import file path'), import_file_path=_IMPORT_FILE_ARG)

Trigger the bgp_status_pre-check script on LSO, print results, and optionally save.

Source code in gso/cli/lso_calls.py
@app.command()
def bgp_status_precheck(
    host: str = typer.Argument(..., help="FQDN of the router to pre-check"),
    partner: str = typer.Argument(..., help="Partner name for import file path"),
    import_file_path: Path = _IMPORT_FILE_ARG,
) -> None:
    """Trigger the bgp_status_pre-check script on LSO, print results, and optionally save."""
    _validate_partner(partner)
    import_json_str = _load_import_file(import_file_path)
    exec_resp = _call_lso(host, partner, import_json_str)
    _print_full(exec_resp)
    _print_parsed_output(exec_resp)
    _maybe_save(host, partner, exec_resp)