cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1011
Views
0
Helpful
1
Replies

Acitoolkit to create vlan

sqambera
Level 1
Level 1

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)

1 Reply 1

Sergiu.Daniluk
VIP Alumni
VIP Alumni

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

Save 25% on Day-2 Operations Add-On License