Skip to main content

Add your description here

Project description

Python NSO Library

Thin wrapper around RestConf designed to interact with NSO.

Key Features:

  • Detect errors raising meaningful exceptions
  • Parameter support in URL to avoid URL Encoding mistakes
  • Support for generating and executing YANG Patches
  • Handling of dry-run responses

Usage

Installing

uv add python-nso-client

Writing code with nso_client

from nso_client import NSOClient
from httpx import BasicAuth

nso = NSOClient(
    "https://localhost",
    auth=BasicAuth("acct", "secret")
)

# Fetching data
resp = nso.get("/tailf-ncs:services/bb:backbone", content="config")
for bb in resp["bb:backbone"]:
    print(bb)


# Create objects
resp = nso.put(
    "/tailf-ncs:services/bb:backbone={}",
    "my-bb-1",
    payload={
        "bb:backbone": [
            {
                "name": "my-bb-1",
                "links": [
                    {"device": "xr0", "interface": "TenGigE0/0/0"},
                    {"device": "xr1", "interface": "TenGigE0/0/1"},
                ],
                "metric": 500,
                "admin-state": "in-service",
            }
        ]
    },
)

# Using yang-patch to modify multiple areas in the same transaction
patch = nso.yang_patch("/tailf-ncs:services")
patch.merge("/bb:backbone={}", "my-bb-1", value=...)
patch.merge("/bb:backbone={}", "my-bb-2", value=...)
patch.delete("/bb:backbone={}", "my-bb-3")
resp = patch.commit(dry_run="cli")
print(resp.changes)
patch.commit()

# Error handling
try:
    nso.delete("/tailf-ncs:services/bb:backbone={}", "does-not-exist")
except NotFoundError as exc:
    print("Backbone already deleted", exc)

# Fetching results in a None, not an exception
resp = nso.get("/tailf-ncs:services/bb:backbone={}", "does-not-exist")
assert resp is None

Developing

# Build
uv build

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_nso_client-0.1.1.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_nso_client-0.1.1-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file python_nso_client-0.1.1.tar.gz.

File metadata

  • Download URL: python_nso_client-0.1.1.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.14

File hashes

Hashes for python_nso_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f7f83a76d07eb05f510b8004a610b293d048a3b2f29cbd91396e6385b8b2c87a
MD5 d7330ed781ed4f4a61c2b9bfef12ac85
BLAKE2b-256 8cef8b4a64e76ce81f853611e341410877b504680f80c7287e00253b5b5350e3

See more details on using hashes here.

File details

Details for the file python_nso_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for python_nso_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d67c3689a0aa71e8e4daaf397a8c7a9abb5f2211d4d2fba7664bbd98b62c7037
MD5 898a5e9aee6b526f6d2f0e6275341dfa
BLAKE2b-256 a5a7b5e9289753c41b061f6253c165bd91e5b8c22546a3700b3e40fa393b7214

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page