-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaci_create_EPG.py
49 lines (36 loc) · 1.33 KB
/
aci_create_EPG.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
45
46
47
48
49
'''
Create TENANT/Context/BD in ACI using APIs
'''
import sys
from acitoolkit import Credentials, Session, Tenant, AppProfile, BridgeDomain, EPG
import acitoolkit.acitoolkit as aci
'''
Input from the USER, Tenant Name,Context,Bridge Domain,Application Profile, epg
it will create Tenant Name,Context,Bridge Domain,Application Profile, epg and add epg in bridge domain
'''
newTenant = input("Enter TENANT Name : ")
newContext = input("Enter Context Name : ")
newBD = input("Enter BD Name : ")
app_pro = input("Enter App Profile : ")
epg_group = input("Enter EPG : ")
tenant = aci.Tenant(newTenant)
context = aci.Context(newContext, tenant)
bd = aci.BridgeDomain(newBD, tenant)
app_profile = aci.AppProfile(app_pro, tenant)
epg = aci.EPG(epg_group, app_profile)
bd.add_context(context)
epg.add_bd(bd)
APIC_URL = 'https://10.10.20.14'
USERNAME = 'admin'
PASSWORD = 'C1sco12345'
session = aci.Session(APIC_URL, USERNAME, PASSWORD)
resp = session.login()
resp = session.push_to_apic(tenant.get_url(), data=tenant.get_json()) # this call will push the new tenant to ACI
print(resp)
gettenants = aci.Tenant.get(session)
for gettenants in gettenants:
print(gettenants.name) # checking the Tenant list
print('='*20,'Context ')
getContext = aci.Context.get(session)
for getContext in getContext:
print(getContext.name) # checking the Tenant list