Skip to main content

ACI communication helper class

Project description

aciClient

PyPi

A python wrapper to the Cisco ACI REST-API.

Python Version

We support Python 3.10 and up.

Installation

With pip:

pip install aciClient

With uv:

uv add aciClient

Installation for Developing

git clone https://github.com/netcloud/aciClient.git
uv sync --group dev

Usage

Initialisation

Username/password

import aciClient
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

proxies = {
    'http': 'socks5://127.0.0.1:1080',
    'https': 'socks5://127.0.0.1:1080'
}

aciclient = aciClient.ACI(apic_hostname, apic_username, apic_password, refresh=False, proxies=proxies)
try:
    aciclient.login()
    
    aciclient.getJson(uri)
    aciclient.postJson(config)
    aciclient.deleteMo(dn)
    
    aciclient.logout()
except Exception as e:
    logger.exception("Stack Trace")

For automatic authentication token refresh you can set variable refresh to True

aciclient = aciClient.ACI(apic_hostname, apic_username, apic_password, refresh=True)    

Certificate/signature

import aciClient
import logging

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

aciclient = aciClient.ACICert(apic_hostname, path_to_privatekey_file, certificate_dn)

try:
    aciclient.getJson(uri)
    aciclient.postJson(config)
    aciclient.deleteMo(dn)
except Exception as e:
    logger.exception("Stack Trace")

Examples

get config

tenants = aciclient.getJson('class/fvTenant.json?order-by=fvTenant.dn|asc')

for mo in tenants:
    print(f'tenant DN: {mo["fvTenant"]["attributes"]["dn"]}')

post config

config = {
 "fvTenant": {
  "attributes": {
   "dn": "uni/tn-XYZ"
  }
 }
}

aciclient.postJson(config)

delete MOs

aciclient.deleteMo('uni/tn-XYZ')

create snapshot

You can specify a tenant in variable target_dn or not provide any to do a fabric-wide snapshot.

aci.snapshot(description='test', target_dn='/uni/tn-test')

Subscriptions

You can subscribe to an ACI object with websocket and get near-instant updates on-change.
To use the subscriptions you have to:

  • Login to ACI
  • Open websocket to ACI
  • Subscribe to an ACI object via aciClient.subscribe
  • Refresh subscription to an ACI object via aciClient.subscription_refresh
  • Handle messages sent from ACI through websocket

You can find example code here: examples/subscription.py

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to this project.

Authors

  • Marcel Zehnder - Initial work
  • Andreas Graber - Migration to open source
  • Richard Strnad - Paginagtion for large requests, various small stuff
  • Dario Kaelin - Added snapshot creation

License

This project is licensed under MIT - see the LICENSE.md file for details.

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

aciclient-1.9.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

aciclient-1.9.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file aciclient-1.9.0.tar.gz.

File metadata

  • Download URL: aciclient-1.9.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aciclient-1.9.0.tar.gz
Algorithm Hash digest
SHA256 95363673108b0fffd367f3ee42112e64c84bc7d0eb1d78b3c9a3bf270817ef04
MD5 5bb435315d0e39d9ff633f0e1bf61bf4
BLAKE2b-256 ab923f279386addd671f1e0d50e4bf46cdf779910b1aebe815b0723f5ac534a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for aciclient-1.9.0.tar.gz:

Publisher: publish.yml on netcloud/aciClient

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aciclient-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: aciclient-1.9.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for aciclient-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2c29accfdb39bfa36947660ccd24e5fbce74e6491c8bb880e2c43f4c79fa6bd7
MD5 5b46459502587d1efd7a60849671e3a2
BLAKE2b-256 01c2428d54e99e317e3569ebf2b0691a236a7f6dbe842a30f7f6bfb689922024

See more details on using hashes here.

Provenance

The following attestation bundles were made for aciclient-1.9.0-py3-none-any.whl:

Publisher: publish.yml on netcloud/aciClient

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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