Simple REST-client for Cisco Catalyst Center
Project description
simple_catalyst_center is a simplified REST Client for the Cisco Catalyst Center (formerly known as DNA Center).
Features
- simple_catalyst_center has following features:
manage login
download files
wait for task results
CRUD interface for all possible API URLs
Installation
Install simple_catalyst_center by running:
pip3 install simple_catalyst_center
Examples
get backup zip file for all devices
from simple_catalyst_center import CiscoCatalystCenterClient
import logging
from getpass import getpass
import secrets
import string
logger = logging.getLogger()
logging.basicConfig(encoding="utf-8", level=logging.INFO)
IP=input("Please Enter Catalyst Center IP: ") or "100.75.2.2"
username=input("Please Enter Catalyst username: ") or "admin"
password=getpass("Please Enter Catalyst password: ") or "not set"
zip_password=input("Please Enter ZIP password: ")
if not zip_password:
zip_password=''.join((secrets.choice(string.ascii_letters + string.digits + string.punctuation) for i in range(12)))
print(f"generated zip password is: {zip_password}")
cc = CiscoCatalystCenterClient(f"https://{IP}/", ssl_verify=False)
cc.login(username, password)
api=cc.api
ids=[]
# collect all device ids
for result in api.dna.intent.api.v1("network-device").get(params={"managementIpAddress": ["100.75.1.11"]}):
ids.append(result["id"])
res=api.dna.intent.api.v1("network-device-archive").cleartext.post(body={
"deviceId": ids,
"password": zip_password
})
# download task result, needs task URL and target filename
cc.download(res.get("url"), res.get("taskId") + ".zip")
use autopaging
import os
try:
from simple_catalyst_center import CiscoCatalystCenterClient
except ImportError:
sys.path.insert(0,os.path.sep.join(__file__.split(os.path.sep)[:-1]))
from simple_catalyst_center import CiscoCatalystCenterClient
import logging
from getpass import getpass
import string
from pprint import pprint
IP = input("Please Enter Catalyst Center IP: ") or "100.75.2.2"
username = input("Please Enter Catalyst username: ") or "admin"
password = getpass("Please Enter Catalyst password: ") or "<not set>"
cc = CiscoCatalystCenterClient(f"https://{IP}/", ssl_verify=False)
cc.login(username, password)
api = cc.api
ids = []
# collect all device ids using all
for result in api.dna.intent.api.v1("network-device").all(limit=10): #default limit is 500
ids.append(result["id"])
pprint(ids)
print(len(ids))
Contribute
Issue Tracker: https://github.com/jinjamator/simple_catalyst_center/issues
Source Code: https://github.com/jinjamator/simple_catalyst_center
Roadmap
- Selected Roadmap items:
add more documentation
add some more examples
For documentation please refer to https://simple_catalyst_center.readthedocs.io/en/latest/
License
This project is licensed under the Apache License Version 2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_catalyst_center-0.3-py3-none-any.whl.
File metadata
- Download URL: simple_catalyst_center-0.3-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca6a1a3f55141acfb1e76decd5c624d44822381086e91c146850dee8bdfe6f41
|
|
| MD5 |
ebedc888a4ad498b73648eac2ebe279f
|
|
| BLAKE2b-256 |
062ab291b34906d12c9a72eb5c82a4e8756b889de88091d330089e57c72fbda7
|