def remove_interface_pc_and_vpc(infra, switch_profile, switches, interface_type, ports, selector, policy_group):
    """The interface profile, which enables you to specify the interface you want to configure. """
    infra_nodep = NodeP(infra, switch_profile)
    infra_leafs = LeafS(infra_nodep, switch_profile+'_selector_'+''.join(map(str,switches)), DEFAULT_TYPE)
    infra_accportp = AccPortP(infra, switch_profile + '_ifselector')
    infra_hports = HPortS(infra_accportp, selector, DEFAULT_TYPE)
    infra_leafs.delete()
    infra_nodep.delete()
    infra_hports.delete()
    infra_accportp.delete()
def remove_interface_pc_and_vpc(infra, switch_profile, switches,
                                interface_type, ports, selector, policy_group):
    """The interface profile, which enables you to specify the interface you want to configure. """
    infra_nodep = NodeP(infra, switch_profile)
    infra_leafs = LeafS(
        infra_nodep,
        switch_profile + '_selector_' + ''.join(map(str, switches)),
        DEFAULT_TYPE)
    infra_accportp = AccPortP(infra, switch_profile + '_ifselector')
    infra_hports = HPortS(infra_accportp, selector, DEFAULT_TYPE)
    infra_leafs.delete()
    infra_nodep.delete()
    infra_hports.delete()
    infra_accportp.delete()
Beispiel #3
0
def switch_profile(host, user, password, if_profile):

    print('[BEG] Switch Profile Configuration')
    moDir = apic_login(host, user, password)

    # Get Top Level Objects
    polUni = Uni('')
    infraInfra = Infra(polUni)

    #Create Variables to be used later

    sPName = 'ASA-VPC-1-Cobra'
    swSelName = 'L103-104-ASA-VPC'
    LFrom = '103'
    LTo = '104'
    ifProfName = if_profile
    nodeBlkName = 'somethingsomethingnodeBlk'
    print('--- Creating Switch Profile: ' + sPName)
    infraNodeP = NodeP(infraInfra, ownerKey=u'', name=sPName)

    print('	Adding Switch Selector: ' + swSelName + ' with Nodes :' + LFrom +
          ',' + LTo)
    infraLeafS = LeafS(infraNodeP, ownerKey=u'', type=u'range', name=swSelName)
    infraNodeBlk = NodeBlk(infraLeafS, from_=LFrom, name=nodeBlkName, to_=LTo)

    print('	Adding Interface Selector Profile: ' + ifProfName)
    infraRsAccPortP = RsAccPortP(infraNodeP,
                                 tDn=u'uni/infra/accportprof-' + ifProfName)

    # Commit Configuration
    cfg_commit(moDir, infraInfra)
    print('[END] Switch Profile Configuration \n')
Beispiel #4
0
def configure_interface_pc_and_vpc(infra, switch_profile, switch_selector,
                                   switches, interface_type,
                                   interface_selector_profile,
                                   interface_selector, policy_group):
    """The interface profile, which enables you to specify the interface you want to configure. """

    infra_accportp = AccPortP(infra, interface_selector_profile)

    for int_sel_name in interface_selector.keys():
        infra_hports = HPortS(infra_accportp, int_sel_name, DEFAULT_TYPE)
        block = 0
        for port in interface_selector[int_sel_name]:
            block += 1
            card, fromPort, toPort = input_ports(port)
            infra_portblk = PortBlk(infra_hports,
                                    'block' + str(block),
                                    fromCard=card,
                                    fromPort=fromPort,
                                    toPort=toPort)
        if interface_type == 'individual':
            policy_group_type = 'accportgrp'

        elif interface_type in ['pc', 'PC', 'VPC', 'vpc']:
            policy_group_type = 'accbundle'

        else:
            print 'Invalid interface type. Option of interface type is "individual", "pc" or, "vpc".'
            sys.exit()
        infra_rsaccbasegrp = RsAccBaseGrp(
            infra_hports,
            tDn='uni/infra/funcprof/' + policy_group_type + '-' + policy_group)
        infra_nodep = NodeP(infra, switch_profile)
        infra_leafs = LeafS(infra_nodep, switch_selector, DEFAULT_TYPE)
        single = 0
        for switch in switches:
            single += 1
            infra_nodeblk = NodeBlk(infra_leafs,
                                    'single' + str(single),
                                    from_=str(switch),
                                    to_=str(switch))

        infra_rsaccportp = RsAccPortP(
            infra_nodep, 'uni/infra/accportprof-' + interface_selector_profile)
Beispiel #5
0
def configure_interface_pc_and_vpc(modir, switches, switch_profile, ports, selector, policy_group):

    # Query a parent
    infra = modir.lookupByDn('uni/infra')
    infra_accportp = AccPortP(infra, switch_profile + '_ifselector')
    infra_hports = HPortS(infra_accportp, selector + '_selector', DEFAULT_TYPE)
    block = 0
    for port in ports:
        block += 1
        card, fromPort, toPort = get_numbers(port)
        infra_portblk = PortBlk(infra_hports, 'block'+str(block), fromCard=card, fromPort=fromPort, toPort=toPort)
    infra_rsaccbasegrp = RsAccBaseGrp(infra_hports, tDn='uni/infra/funcprof/accportgrp-'+policy_group)

    infra_nodep = NodeP(infra, switch_profile)
    infra_leafs = LeafS(infra_nodep, switch_profile+'_selector_'+''.join(map(str,switches)), DEFAULT_TYPE)
    single = 0
    for switch in switches:
        single += 1
        infra_nodeblk = NodeBlk(infra_leafs, 'single'+str(single), from_=str(switch), to_=str(switch))

    infra_rsaccportp = RsAccPortP(infra_nodep, 'uni/infra/accportprof-'+switch_profile+'_ifselector')

    print_query_xml(infra)
    commit_change(modir, infra)