Skip to main content

py-nvidia-cumulus

Unofficial Python API client for Nvidia Cumulus Linux.

📖 General information

The client aims to provide a thin wrapper over the Cumulus OpenAPI specification.
Therefore, it abstracts endpoints in a Pythonic fashion.

🛠 Installation

To install the package, run the following command:

pip install py-nvidia-cumulus

To install the package locally, clone this repository and run the following command:

pip install .

🚀 Quickstart

To start using the client, instantiate the Cumulus class with the host and authentication details

from cumulus import Cumulus

nv = Cumulus(
    url="https://127.0.0.1:8765",
    auth=("cumulus", "password")
)
# nv.http_session = requests.Session() # set your own session if necessary
nv.http_session.verify = False # disable SSL verification if necessary

📄 Examples

  1. Get the IP address of an interface relative to the OpenAPI endpoint
# Instantiate the Cumulus class first
loopback = nv.interface.get('lo/ip/address')
print(loopback) # {'127.0.0.1/8': {}, '::1/128': {}}
  1. Update interface configuration relative to the OpenAPI endpoint:
# Instantiate the Cumulus class first
nv.revision.create() # create a revision
# patch an interface by providing the created revision ID, new data, and path to the object
nv.interface.patch(rev=nv.revision.rev,
                   data={"10.255.255.2/32": {}},
                   target_path="lo/ip/address")
nv.revision.apply() # apply the changes
nv.revision.is_applied() # watch the switch to make sure the changes were applied successfully
  1. Here is a more complex example on how to deploy the entire switch configuration using the root endpoint. We will also see how to get the diff between the current revision and the one we are applying.
from cumulus import Cumulus

configuration = {"key": "value"}
nv = Cumulus(
    url="https://127.0.0.1:8765",
    auth=("cumulus", "password")
)
nv.http_session.verify = False # by default the switch uses self-signed certificate

nv.revision.create()
# remove previous configuration completely.
# Otherwise, only new keys will be applied and old ones won't be removed
nv.root.delete(nv.revision.rev)
nv.root.patch(rev=nv.revision.rev, data=configuration)

# see the changes between the current and pending revisions
print(nv.root.diff(nv.revision.rev))

nv.revision.apply()

# check switch status for 3 minutes
nv.revision.is_applied(retries=180)
# update revision to get the success/error message
nv.revision.refresh()
print(nv.revision.config)
  1. Due to the very dynamic nature of Nvidia Cumulus API, there may not always be a model to cover the endpoint you want to use. Adding your own model is very simple.
from cumulus import Cumulus
from cumulus.models import BaseModel

nv = Cumulus(
    url="https://127.0.0.1:8765",
    auth=("cumulus", "password")
)
programming = BaseModel(client=nv, endpoint="system/forwarding/programming")
print(programming.get(endpoint_params={"rev": "applied"}))

🏷️ Versioning

We use SemVer for versioning. To see the available versions, check the PyPI page or tags in this repository.

🤝 Contribution

We welcome contributions, issues, and feature requests! Also, please refer to our contribution guidelines for details.

Made with ♥ by Namecheap Cloud Team

Metadata

Release files for py-nvidia-cumulus 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-nvidia-cumulus 0.0.4
File Size Uploaded
py_nvidia_cumulus-0.0.4.tar.gz 10.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-nvidia-cumulus 0.0.4
File Interpreter ABI Platform
py_nvidia_cumulus-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / py_nvidia_cumulus-0.0.4.tar.gz

Download URL py_nvidia_cumulus-0.0.4.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8e2fcdf1780f918d51542477c6dcd0d94331a11ca3b438c888fb5e3f20bd081f
BLAKE2b-256 checksum
How to use checksums
ef84566f62b9da90a2194e5484f27590641dfc52c7f5f99c0e0a0f99d39c7ae2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.11 Linux/5.15.0-1037-azure

Release files / py_nvidia_cumulus-0.0.4-py3-none-any.whl

Download URL py_nvidia_cumulus-0.0.4-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42ecd365fbb718b8a92fcbbb1233fea22bc95102de71ba70aaffb419c17bd644
BLAKE2b-256 checksum
How to use checksums
77d16ef43a758a7ee6485b68ae06b4c69a470b18eafd131470b12b3830711f54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.2 CPython/3.10.11 Linux/5.15.0-1037-azure

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page