Nexus Dashboard
This guide shows how to use the
CiscoNexusDashboard
client to interact with Cisco Nexus Dashboard APIs.
It handles authentication, token refresh, and error management for you.
Connect to Cisco Nexus Dashboard
from wingpy import CiscoNexusDashboard
nexusdashboard = CiscoNexusDashboard(
base_url="https://nexusdashboard.example.com", # (1)!
username="admin", # (2)!
password="password", # (3)!
verify=False,
)
- Environment variable:
- Environment variable:
- Environment variable:
Get all fabrics
fabrics = nexusdashboard.get_all("/api/v1/manage/fabrics")
for fabric in fabrics:
print(fabric["name"])
Get specific fabric
rsp = nexusdashboard.get(
"/api/v1/manage/fabrics/{fabricName}",
path_params={"fabricName": "MyFabrics"}
)
print(rsp.json())
Add switch credentials
new_switch = {
"switchIds": [{"switchId": "9PRQ123LKAB"}],
"switchUsername": "devnet",
"switchPassword": "Cisco123!",
}
rsp = nd.post(
"/api/v1/manage/credentials/switches",
data=new_switch,
)
print(rsp.status_code())
Replace deployment freeze status
freeze_status = {"deploymentFreeze": False}
rsp = nd.put(
"/api/v1/manage/fabrics/{fabricName}/deploymentFreeze",
path_params={"fabricName": "MyFabric"},
data=freeze_status
)
print(rsp.status_code())
Update tenant
tenant = {
"bsonIdent": "5b90695f1e00005d3b46efa2",
"name": "Tenant01",
"displayName": "My Tenant"
}
rsp = nexusdashboard.patch(
"/mso/api/v1/tenants/{tenantId}",
path_params={"tenantId": "5b90695f1e00005d3b46efa2"},
data=tenant
)
print(rsp.status_code())
```python title="Remove dashboard" rsp = nexusdashboard.delete( "/dashboards/{name}", path_params={"name": "All_Sites"} ) print(rsp.status_code())