Skip to main content

Python API Client for Nvidia Cumulus

Project description

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

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

py_nvidia_cumulus-0.0.4.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

py_nvidia_cumulus-0.0.4-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file py_nvidia_cumulus-0.0.4.tar.gz.

File metadata

  • Download URL: py_nvidia_cumulus-0.0.4.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/5.15.0-1037-azure

File hashes

Hashes for py_nvidia_cumulus-0.0.4.tar.gz
Algorithm Hash digest
SHA256 8e2fcdf1780f918d51542477c6dcd0d94331a11ca3b438c888fb5e3f20bd081f
MD5 d997db4865fde9f5c0cd175d67365bf4
BLAKE2b-256 ef84566f62b9da90a2194e5484f27590641dfc52c7f5f99c0e0a0f99d39c7ae2

See more details on using hashes here.

File details

Details for the file py_nvidia_cumulus-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: py_nvidia_cumulus-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.10.11 Linux/5.15.0-1037-azure

File hashes

Hashes for py_nvidia_cumulus-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 42ecd365fbb718b8a92fcbbb1233fea22bc95102de71ba70aaffb419c17bd644
MD5 f7b4dbe5c0c5a31bfc43a03a332be893
BLAKE2b-256 77d16ef43a758a7ee6485b68ae06b4c69a470b18eafd131470b12b3830711f54

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