A python wrapper to the Cisco ACI REST-API.
We support Python 3.6 and up. Python 2 is not supported and there is no plan to add support for it.
pip install aciClient
git clone https://github.com/netcloud/aciclient.git
pip install -r requirements.txt
python setup.py develop
import aciClient
import logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
aciclient = aciClient.ACI(apic_hostname, apic_username, apic_password, refresh=False)
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)
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")
tenants = aciclient.getJson('class/fvTenant.json?order-by=fvTenant.dn|asc')
for mo in tenants:
print(f'tenant DN: {mo["fvTenant"]["attributes"]["dn"]}')
config = {
"fvTenant": {
"attributes": {
"dn": "uni/tn-XYZ"
}
}
}
aciclient.postJson(config)
aciclient.deleteMo('uni/tn-XYZ')
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')
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
pip install -r requirements.txt
python -m pytest
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to this project.
- Marcel Zehnder - Initial work
- Andreas Graber - Migration to open source
- Richard Strnad - Paginagtion for large requests, various small stuff
- Dario Kaelin - Added snapshot creation
This project is licensed under MIT - see the LICENSE.md file for details.