Acitoolkit to create vlan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-20-2021 01:26 PM
Hello,
I am very new to automation and have been trying to use the Python SDK for ACI (acitoolkit) for creating specific vlan into a pre-existing vlan pool. I looked at the learning labs and saw that there are functions in the acitoolkit that are being used to create tenants, VRF, BD, etc. like following but I couldn't find one to create vlan inside a vlan pool. Could anyone please guide how to do that? Thanks.
tenant = Tenant(tenant_name)
vrf = Context("Example_VRF", tenant)
bridge_domain = BridgeDomain("Example_BD", tenant)
- Labels:
-
ACI App Center
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2021 04:36 AM - edited 01-21-2021 04:37 AM
Hi @sqambera
I do not see a class for vlan pool, but you can do it as presented here:
https://github.com/datacenter/acitoolkit/blob/master/samples/aci-create-phys-domain.py
Snip:
import acitoolkit.acitoolkit as aci
POOL_NAME = 'dvs-vlans'
ENCAP_TYPE = 'vlan'
VLAN_START = '3150'
VLAN_END = '3200'
POOL_MODE = 'dynamic'
description = 'Create Physical Domain'
creds = aci.Credentials('apic', description)
creds.add_argument('--phys', help='name of the physical domain')
args = creds.get()
# Login to the APIC
session = aci.Session(args.url, args.login, args.password)
resp = session.login()
if not resp.ok:
print('%% Could not login to APIC')
# Define dynamic vlan range
vlans = aci.NetworkPool(POOL_NAME, ENCAP_TYPE, VLAN_START, VLAN_END, POOL_MODE)
# Commit VLAN Range
vlanresp = session.push_to_apic(vlans.get_url(), vlans.get_json())
if not vlanresp.ok:
print('%% Error: Could not push configuration to APIC')
print(vlanresp.text)
Stay safe,
Sergiu
