def create_overlay_policy(apic=None, policy=None): mo = aciPol.Uni('') for name, data in policy.items(): # Create tenant behind the scenes tenantName = '{0}_Tenant'.format(name) fvTenant = aciFv.Tenant(mo, name=tenantName) # Create the required VRF as well vrfName = '{0}_VRF'.format(name) fvCtx = aciFv.Ctx(fvTenant, name=vrfName) # Create BD for vlan in data['vlans']: vlanName = 'VLAN_{0}'.format(vlan['id']) if vlan['optimized']: fvBD = aciFv.BD(fvTenant, name=vlanName, OptimizeWanBandwidth='no', arpFlood='no', epClear='no', hostBasedRouting='yes', intersiteBumTrafficAllow='no', intersiteL2Stretch='no', ipLearning='yes', limitIpLearnToSubnets='yes', llAddr='::', mac='00:22:BD:F8:19:FF', mcastAllow='no', multiDstPktAct='encap-flood', type='regular', unicastRoute='yes', unkMacUcastAct='proxy', unkMcastAct='opt-flood', v6unkMcastAct='flood', vmac='not-applicable') else: fvBD = aciFv.BD(fvTenant, name=vlanName, OptimizeWanBandwidth='no', arpFlood='yes', epClear='no', hostBasedRouting='no', intersiteBumTrafficAllow='no', intersiteL2Stretch='no', ipLearning='yes', limitIpLearnToSubnets='yes', llAddr='::', mac='00:22:BD:F8:19:FF', mcastAllow='no', multiDstPktAct='bd-flood', type='regular', unicastRoute='yes', unkMacUcastAct='flood', unkMcastAct='flood', v6unkMcastAct='flood', vmac='not-applicable') aciFv.Subnet(fvBD, ip=vlan['subnet'], preferred='no', scope='private', virtual='no') aciFv.RsCtx(fvBD, tnFvCtxName='{0}_VRF'.format(name)) fvAp = aciFv.Ap(fvTenant, name='{0}_AppProf'.format(vlanName)) aciFv.RsApMonPol(fvAp, tnMonEPGPolName='default') # REMAINING TASKS # Create EPGs # aciFv.EPg(fvAp, name, matchT, etc...) # Contracts return mo
# APIC Login Credentials apicUrl = 'https://' + apicIP apicUsername = '******' + TacacsUser apicPassword = TacacsPassword loginSession = LoginSession(apicUrl, apicUsername, apicPassword) # Create a session with the APIC and login moDir = MoDirectory(loginSession) moDir.login() # Start at the Top of MIT tree uniMo = moDir.lookupByDn('uni') # Create a new Tenant MO and connect it as a Child object to the root of the MIM # Call the new Tenant MO 'ExampleSdkTenant' fvTenantMo = fvModels.Tenant(uniMo, 'ExampleSdkTenant-3') # Create new Private network/VRF under the new Tenant fvContextMo = fvModels.Ctx(fvTenantMo, 'myVRF') #Create new BD under new Tenant #fvBDMo = # Create a new configuration request to the APIC and pass in the new Tenant MO (including its children MOs) # Commit the changes to the APIC cfgRequest = ConfigRequest() cfgRequest.addMo(fvTenantMo) moDir.commit(cfgRequest) # Log Out once the request is complete moDir.logout()
pathEPName = 'HSC_Lab_pg' #Format some values based on the data provided that we can then use later vlanfield = 'vlan-{}'.format(vlan) l3OutName = '{}_l3'.format(vrfName) OSPFProfile = '{}_ospfprof'.format(vrfName) l3outtDn = 'uni/l3dom-{}'.format(l3outDomainName) rsaaepntdn = 'uni/infra/attentp-{}'.format(aaEPName) nodeProfileName = '{}_nodeprof'.format(vrfName) tdn1 = 'topology/pod-1/{}'.format(leafNode1) tdn2 = 'topology/pod-1/{}'.format(leafNode2) testpathTDN = 'topology/pod-1/protpaths-101-103/pathep-[{}]'.format( pathEPName) ## Create VRF object vrfMo = fv.Ctx(fvTenant, name=vrfName) ## Create L3Out object l3outMo = l3ext.Out(fvTenant, name=l3OutName) # Associate L3Out to VRF l3ext.RsEctx(l3outMo, tnFvCtxName=vrfName) # Associate L3Out to NodeProfile lNodePMo = l3ext.LNodeP(l3outMo, name=nodeProfileName) # Assign router IPs to each node l3ext.RsNodeL3OutAtt(lNodePMo, tDn=tdn1, rtrId=routerID1, rtrIdLoopBack='yes') l3ext.RsNodeL3OutAtt(lNodePMo, tDn=tdn2, rtrId=routerID2,