from acitoolkit.acitoolkit import *
"""
Create a tenant with a single EPG and assign it statically to 2 interfaces.
This is the minimal configuration necessary to enable packet forwarding
within the ACI fabric.
"""
# Create the Tenant
tenant = Tenant('DEMO_PYTHON')

# Create the Application Profile
app = AppProfile('myapp', tenant)

# Create the EPG
epg = EPG('myepg', app)

# Create a Context and BridgeDomain
context = Context('myvrf', tenant)
bd = BridgeDomain('mybd', tenant)
bd.add_context(context)

# Place the EPG in the BD
epg.add_bd(bd)

# Declare 2 physical interfaces
if1 = Interface('eth', '1', '101', '1', '15')
if2 = Interface('eth', '1', '101', '1', '16')

# Create VLAN 5 on the physical interfaces
vlan5_on_if1 = L2Interface('vlan5_on_if1', 'vlan', '5')
vlan5_on_if1.attach(if1)

vlan5_on_if2 = L2Interface('vlan5_on_if2', 'vlan', '5')
vlan5_on_if2.attach(if2)

# Attach the EPG to the VLANs
epg.attach(vlan5_on_if1)
epg.attach(vlan5_on_if2)

# Get the APIC login credentials
description = 'acitoolkit tutorial application'
creds = Credentials('apic', description)
creds.add_argument('--delete', action='store_true',
                   help='Delete the configuration from the APIC')
args = creds.get()

# Delete the configuration if desired
if args.delete:
    tenant.mark_as_deleted()

# Login to APIC and push the config
session = Session(args.url, args.login, args.password)
session.login()
resp = tenant.push_to_apic(session)
if resp.ok:
    print('Success')

# Print what was sent
print('Pushed the following JSON to the APIC')
print('URL:', tenant.get_url())
print('JSON:', tenant.get_json())

73801f58db7cb163e123ccefbb1cb87dc517bfa1
<mask token>

<mask token>
bd.add_context(context)
epg.add_bd(bd)
<mask token>
vlan5_on_if1.attach(if1)
<mask token>
vlan5_on_if2.attach(if2)
epg.attach(vlan5_on_if1)
epg.attach(vlan5_on_if2)
<mask token>
creds.add_argument('--delete', action='store_true', help=
    'Delete the configuration from the APIC')
<mask token>
if args.delete:
    tenant.mark_as_deleted()
<mask token>
session.login()
<mask token>
if resp.ok:
    print('Success')
print('Pushed the following JSON to the APIC')
print('URL:', tenant.get_url())
print('JSON:', tenant.get_json())

<mask token>
tenant = Tenant('DEMO_PYTHON')
app = AppProfile('myapp', tenant)
epg = EPG('myepg', app)
context = Context('myvrf', tenant)
bd = BridgeDomain('mybd', tenant)
bd.add_context(context)
epg.add_bd(bd)
if1 = Interface('eth', '1', '101', '1', '15')
if2 = Interface('eth', '1', '101', '1', '16')
vlan5_on_if1 = L2Interface('vlan5_on_if1', 'vlan', '5')
vlan5_on_if1.attach(if1)
vlan5_on_if2 = L2Interface('vlan5_on_if2', 'vlan', '5')
vlan5_on_if2.attach(if2)
epg.attach(vlan5_on_if1)
epg.attach(vlan5_on_if2)
description = 'acitoolkit tutorial application'
creds = Credentials('apic', description)
creds.add_argument('--delete', action='store_true', help=
    'Delete the configuration from the APIC')
args = creds.get()
if args.delete:
    tenant.mark_as_deleted()
session = Session(args.url, args.login, args.password)
session.login()
resp = tenant.push_to_apic(session)
if resp.ok:
    print('Success')
print('Pushed the following JSON to the APIC')
print('URL:', tenant.get_url())
print('JSON:', tenant.get_json())

from acitoolkit.acitoolkit import *
<mask token>
tenant = Tenant('DEMO_PYTHON')
app = AppProfile('myapp', tenant)
epg = EPG('myepg', app)
context = Context('myvrf', tenant)
bd = BridgeDomain('mybd', tenant)
bd.add_context(context)
epg.add_bd(bd)
if1 = Interface('eth', '1', '101', '1', '15')
if2 = Interface('eth', '1', '101', '1', '16')
vlan5_on_if1 = L2Interface('vlan5_on_if1', 'vlan', '5')
vlan5_on_if1.attach(if1)
vlan5_on_if2 = L2Interface('vlan5_on_if2', 'vlan', '5')
vlan5_on_if2.attach(if2)
epg.attach(vlan5_on_if1)
epg.attach(vlan5_on_if2)
description = 'acitoolkit tutorial application'
creds = Credentials('apic', description)
creds.add_argument('--delete', action='store_true', help=
    'Delete the configuration from the APIC')
args = creds.get()
if args.delete:
    tenant.mark_as_deleted()
session = Session(args.url, args.login, args.password)
session.login()
resp = tenant.push_to_apic(session)
if resp.ok:
    print('Success')
print('Pushed the following JSON to the APIC')
print('URL:', tenant.get_url())
print('JSON:', tenant.get_json())

from acitoolkit.acitoolkit import *
"""
Create a tenant with a single EPG and assign it statically to 2 interfaces.
This is the minimal configuration necessary to enable packet forwarding
within the ACI fabric.
"""
# Create the Tenant
tenant = Tenant('DEMO_PYTHON')

# Create the Application Profile
app = AppProfile('myapp', tenant)

# Create the EPG
epg = EPG('myepg', app)

# Create a Context and BridgeDomain
context = Context('myvrf', tenant)
bd = BridgeDomain('mybd', tenant)
bd.add_context(context)

# Place the EPG in the BD
epg.add_bd(bd)

# Declare 2 physical interfaces
if1 = Interface('eth', '1', '101', '1', '15')
if2 = Interface('eth', '1', '101', '1', '16')

# Create VLAN 5 on the physical interfaces
vlan5_on_if1 = L2Interface('vlan5_on_if1', 'vlan', '5')
vlan5_on_if1.attach(if1)

vlan5_on_if2 = L2Interface('vlan5_on_if2', 'vlan', '5')
vlan5_on_if2.attach(if2)

# Attach the EPG to the VLANs
epg.attach(vlan5_on_if1)
epg.attach(vlan5_on_if2)

# Get the APIC login credentials
description = 'acitoolkit tutorial application'
creds = Credentials('apic', description)
creds.add_argument('--delete', action='store_true',
                   help='Delete the configuration from the APIC')
args = creds.get()

# Delete the configuration if desired
if args.delete:
    tenant.mark_as_deleted()

# Login to APIC and push the config
session = Session(args.url, args.login, args.password)
session.login()
resp = tenant.push_to_apic(session)
if resp.ok:
    print('Success')

# Print what was sent
print('Pushed the following JSON to the APIC')
print('URL:', tenant.get_url())
print('JSON:', tenant.get_json())
