def createPodPolicy(config):
    fabricInst = aciFabric.Inst(aciPol.Uni(''))
    aciDateTime.Format(fabricInst, name='default', tz=config.timezone)
    datetimePol = aciDateTime.Pol(fabricInst, name='default')
    for ntp in config.ntpList:
        datetimeNtpProv = aciDateTime.NtpProv(datetimePol,
                                              preferred=ntp['preferred'],
                                              name=ntp['name'],
                                              descr=ntp['descr'])
        aciDateTime.RsNtpProvToEpg(datetimeNtpProv,
                                   tDn='uni/tn-mgmt/mgmtp-default/oob-default')
    bgpInstPol = aciBgp.InstPol(fabricInst, name='default')
    aciBgp.AsP(bgpInstPol, name='aspn', asn=config.bgpAsn)
    bgpRRP = aciBgp.RRP(bgpInstPol, name='route-reflector')
    for rrNodeId in getRrNodeIdList(config.fabricNodes):
        aciBgp.RRNodePEp(bgpRRP, id=rrNodeId)

    fabricFuncP = aciFabric.FuncP(fabricInst)
    fabricPodPGrp = aciFabric.PodPGrp(fabricFuncP,
                                      name='default-PodPolicyGroup')
    aciFabric.RsPodPGrpBGPRRP(fabricPodPGrp, tnBgpInstPolName='default')
    aciFabric.RsTimePol(fabricPodPGrp, tnDatetimePolName='default')
    aciFabric.RsPodPGrpIsisDomP(fabricPodPGrp, tnIsisDomPolName='default')
    aciFabric.RsPodPGrpCoopP(fabricPodPGrp, tnCoopPolName='default')
    aciFabric.RsCommPol(fabricPodPGrp, tnCommPolName='default')
    aciFabric.RsSnmpPol(fabricPodPGrp, tnSnmpPolName='default')
    fabricPodP = aciFabric.PodP(fabricInst, name='default')
    fabricPodS = aciFabric.PodS(fabricPodP, type='ALL', name='default')
    aciFabric.RsPodPGrp(fabricPodS, tDn=fabricPodPGrp.dn)
    return fabricInst
Example #2
0
def create_bgp_policy(mo, policy, nodes):
    """
  If nodes is passed, it's a dictionary of "name": "id" info for the
  fabric nodes (non-controller)
  """
    # Create new object if needed
    if mo is None:
        mo = aciFabric.Inst(aciPol.Uni(''))

    # Create top level BGP policy
    bgpInstPol = aciBgp.InstPol(mo, name=policy['name'])

    # Add ASN daughter
    aciBgp.AsP(bgpInstPol, asn=policy['bgpAsP']['asn'])

    # Add BGP (Internal) RR Fabric Policy
    aciRRP = aciBgp.RRP(bgpInstPol)

    # Add BGP (Internal) RR node
    podId = policy['bgpRRP']['podId']
    for rr in policy['bgpRRP']['bgpRRNodePEp']:
        nodeId = nodes[rr]
        aciBgp.RRNodePEp(aciRRP, id=nodeId, podId=podId)

    return mo
def createIpnL3Out(config):
    fvTenant = aciFv.Tenant(aciPol.Uni(''), name='infra')
    l3extOut = aciL3Ext.Out(fvTenant, name=config.l3OutName,
                            targetDscp='unspecified', enforceRtctrl='export')
    aciOspf.ExtP(l3extOut, areaId=config.ospfArea['id'],
                 areaType=config.ospfArea['type'])
    aciBgp.ExtP(l3extOut)
    aciL3Ext.RsEctx(l3extOut, tnFvCtxName='overlay-1')

    if config.l3Label:
        aciL3Ext.ProvLbl(l3extOut, tag='yellow-green', name=config.l3Label)

    if config.golfLabel:
        aciL3Ext.ProvLbl(l3extOut, tag='yellow-green', name=config.golfLabel)

    l3extInstP = aciL3Ext.InstP(l3extOut, prio='unspecified',
                                matchT='AtleastOne', name='instp1',
                                targetDscp='unspecified')
    aciFv.RsCustQosPol(l3extInstP, tnQosCustomPolName='')
    aciL3Ext.RsL3DomAtt(l3extOut,
                        tDn="uni/l3dom-{}_extL3Dom".format(config.l3OutName))
    fvFabricExtConnP = aciFv.FabricExtConnP(fvTenant, rt=config.routeTarget,
                                            id='1',
                                            name='Fabric_Ext_Conn_Pol1')
    aciFv.PeeringP(fvFabricExtConnP, type='automatic_with_full_mesh')
    fabricExtRoutingP = aciL3Ext.FabricExtRoutingP(fvFabricExtConnP,
                                                   name='ext_routing_prof_1')

    for podId, nodes in config.fabricNodes['pods'].iteritems():
        l3extLNodeP = aciL3Ext.LNodeP(l3extOut,
                                      name="POD{}-L3Nodes".format(podId))
        l3extLIfP = aciL3Ext.LIfP(l3extLNodeP, name='L3Out-InterfacePolicy')
        ospfIfP = aciOspf.IfP(l3extLIfP)
        aciOspf.RsIfPol(ospfIfP, tnOspfIfPolName=config.ospfIfPolicyName)
        fvPodConnP = aciFv.PodConnP(fvFabricExtConnP, id=podId,
                                    descr='this is dp-tep')
        aciFv.Ip(fvPodConnP, addr=config.podProxyTepIp[podId])

        if config.golfPeerList:
            for golfPeer in config.golfPeerList:
                if golfPeer['podId'] == 'all' and golfPeer['podId'] == podId:
                    bgpInfraPeerP = aciBgp.InfraPeerP(
                        l3extLNodeP, ctrl='send-com,send-ext-com', weight='0',
                        privateASctrl='', ttl=config.golfTtl,
                        allowedSelfAsCnt='3', peerT='wan', addr=golfPeer['ip'])
                    aciBgp.RsPeerPfxPol(bgpInfraPeerP, tnBgpPeerPfxPolName='')
                    aciBgp.AsP(bgpInfraPeerP, asn=config.golfAsn, name='')
        for node in nodes:
            if 'l3Out' in node:
                l3extRsNodeL3OutAtt = aciL3Ext.RsNodeL3OutAtt(
                    l3extLNodeP, rtrIdLoopBack='yes',
                    rtrId=node['l3Out']['routerId'],
                    tDn=getDnFromPodIdNodeId(podId, node['nodeId']))
                aciL3Ext.InfraNodeP(l3extRsNodeL3OutAtt,
                                    fabricExtCtrlPeering='yes', name='')
                for interface in node['l3Out']['interfaces']:
                    aciL3Ext.RsPathL3OutAtt(
                        l3extLIfP,
                        ifInstT='sub-interface',
                        addr=interface['addr'],
                        tDn=getPathEpFromPodIdNodeIdIfId(podId,
                                                         node['nodeId'],
                                                         interface['name']),
                        descr='asr',
                        encap='vlan-4')

    for subnet in config.ipnSubnetList:
        aciL3Ext.Subnet(fabricExtRoutingP, aggregate='', ip=subnet)

    return fvTenant