Skip to main content

Cisco NX-API asyncio client

Project description

Cisco NX-API asyncio Client

This repository contains a Cisco NX-API asyncio based client that uses the httpx as an underlying transport and lxml as the basis for handling XML.

Note: This client does not support the NETCONF interface.

WORK IN PROGESS

Quick Example

Thie following shows how to create a Device instance and run a list of commands.

By default the Device instance will use HTTPS transport. The Device instance supports the following settings:

  • host - The device hostname or IP address
  • username - The login user-name
  • password - The login password
  • proto - (Optional) Choose either "https" or "http", defaults to "https"
  • port - (Optional) Chose the protocol port to override proto default

The result of command execution is a list of CommandResults (namedtuple). The output field will be:

  • lxml.Element when output format is 'xml'
  • dict when output format is 'json'
  • str when output format is 'text'
from asyncnxapi import Device

username = 'dummy-user'
password = 'dummy-password'

async def run_test(host):
    dev = Device(host=host, creds=(username, password))
    res = await dev.exec(['show hostname', 'show version'], ofmt='json')
    for cmd in res:
       if not cmd.ok:
          print(f"{cmd.command} failed")
          continue

       # do something with cmd.output as dict since ofmt was 'json'

Limitations

  • Chunking is not currently supported. If anyone has need of this feature please open an issue requesting support.

References

Cisco DevNet NX-API Rerefence:

Cisco platform specific NX-API references:

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

aio_nxapi-0.6.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

aio_nxapi-0.6.0-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file aio_nxapi-0.6.0.tar.gz.

File metadata

  • Download URL: aio_nxapi-0.6.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.6.0

File hashes

Hashes for aio_nxapi-0.6.0.tar.gz
Algorithm Hash digest
SHA256 b81e2190951d46b558e27b5f50fcfa1a61c2db6cc2d44ee138b3402ac7ecae3a
MD5 24419f78a6f46eabc4c85437ff04464c
BLAKE2b-256 1752fb0e35e013002f820e88d7e153c5941e10850b88396e9242347c2313e16a

See more details on using hashes here.

File details

Details for the file aio_nxapi-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: aio_nxapi-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.6.0

File hashes

Hashes for aio_nxapi-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c8199b33cf7b4850a9705cd54c3f1c163f2d82ce19b87adcac03597661b941d
MD5 d80f6a4ead58e985b839e5eb53f638e8
BLAKE2b-256 d8da6f01b7e7488947aabb3340f4bd4d1fc48c1831327b8839383214713d347b

See more details on using hashes here.

Supported by

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