forked from network-evolution/python_code_samples_network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaci-show-tenants.py
44 lines (34 loc) · 1.05 KB
/
aci-show-tenants.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
"""
Simple application that logs on to the APIC and displays all
of the Tenants.
Leverages the DevNet Sandbox - APIC Simulator Always On
Information at https://developer.cisco.com/docs/sandbox/#!data-center
Code sample based off the ACI-Toolkit Code sample
https://github.com/datacenter/acitoolkit/blob/master/samples/aci-show-tenants.py
"""
import sys
import acitoolkit.acitoolkit as ACI
# Credentials and information for the DevNet ACI Simulator Always-On Sandbox
APIC_URL = "https://sandboxapicdc.cisco.com/"
APIC_USER = "admin"
APIC_PASSWORD = "C1sco12345"
def main():
"""
Main execution routine
:return: None
"""
# Login to APIC
session = ACI.Session(APIC_URL, APIC_USER, APIC_PASSWORD)
resp = session.login()
if not resp.ok:
print('%% Could not login to APIC')
sys.exit(0)
# Download all of the tenants
print("TENANT")
print("------")
tenants = ACI.Tenant.get(session)
for tenant in tenants:
print(tenant.name)
if __name__ == '__main__':
main()