Search in sources :

Example 1 with DpnToInterfaceList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.DpnToInterfaceList in project genius by opendaylight.

the class InterfaceManagerConfigurationTest method testDpnToInterfaceList.

@Ignore
@Test
public void testDpnToInterfaceList() throws Exception {
    // Write into DpnToInterfaceList
    createDpnToInterface(DPN_ID_1, "23701c04-7e58-4c65-9425-78a80d49a218", L2vlan.class);
    // Test interface list fetching from dpnId
    GetDpnInterfaceListInput dpnInterfaceListInput = new GetDpnInterfaceListInputBuilder().setDpid(DPN_ID_1).build();
    Future<RpcResult<GetDpnInterfaceListOutput>> dpnInterfaceListOutput = odlInterfaceRpcService.getDpnInterfaceList(dpnInterfaceListInput);
    List<Interfaces> actualDpnInterfaceList = dpnInterfaceListOutput.get().getResult().getInterfaces();
    assertEqualBeans(ExpectedInterfaceListFromDpn.checkDpnToInterfaceList(), actualDpnInterfaceList.get(0));
}
Also used : Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces) GetDpnInterfaceListInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetDpnInterfaceListInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with DpnToInterfaceList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.DpnToInterfaceList in project genius by opendaylight.

the class InterfaceManagerCommonUtils method addStateEntry.

public void addStateEntry(String interfaceName, WriteTransaction interfaceOperShardTransaction, List<ListenableFuture<Void>> futures, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
    // allocate lport tag and create interface-if-index map.
    // This is done even if interface-state is not present, so that there is
    // no throttling
    // on id allocation even when multiple southbound port_up events come in
    // one shot
    Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceName);
    interfaceMetaUtils.createLportTagInterfaceMap(interfaceName, ifIndex);
    if (ifState == null) {
        LOG.debug("could not retrieve interface state corresponding to {}, processing will be resumed when " + "interface-state is available", interfaceName);
        return;
    }
    LOG.debug("adding interface state for {}", interfaceName);
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus = ifState.getOperStatus();
    PhysAddress physAddress = ifState.getPhysAddress();
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus adminStatus = ifState.getAdminStatus();
    NodeConnectorId nodeConnectorId = new NodeConnectorId(ifState.getLowerLayerIf().get(0));
    InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface interfaceInfo = getInterfaceFromConfigDS(interfaceKey);
    if (interfaceInfo != null && !interfaceInfo.isEnabled()) {
        operStatus = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
    }
    List<String> childLowerLayerIfList = new ArrayList<>();
    childLowerLayerIfList.add(0, nodeConnectorId.getValue());
    InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus).setOperStatus(operStatus).setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList);
    ifaceBuilder.setIfIndex(ifIndex).setType(Other.class);
    Class<? extends InterfaceType> interfaceType = null;
    if (interfaceInfo != null) {
        interfaceType = interfaceInfo.getType();
        ifaceBuilder.setType(interfaceType);
    }
    ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
    ifaceBuilder.setStatistics(new StatisticsBuilder().setDiscontinuityTime(DateAndTime.getDefaultInstance(ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT))).build());
    InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
    interfaceOperShardTransaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), true);
    // install ingress flow
    BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
    long portNo = IfmUtil.getPortNumberFromNodeConnectorId(nodeConnectorId);
    if (interfaceInfo != null && interfaceInfo.isEnabled() && ifState.getOperStatus() == org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up) {
        FlowBasedServicesUtils.installLportIngressFlow(dpId, portNo, interfaceInfo, futures, txRunner, ifIndex);
        futures.add(FlowBasedServicesUtils.bindDefaultEgressDispatcherService(txRunner, interfaceInfo, Long.toString(portNo), interfaceName, ifIndex));
    }
    // Update the DpnToInterfaceList OpDS
    createOrUpdateDpnToInterface(dpId, interfaceName, interfaceType);
}
Also used : OperStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) ArrayList(java.util.ArrayList) AdminStatus(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) StatisticsBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state._interface.StatisticsBuilder) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) BigInteger(java.math.BigInteger) BigInteger(java.math.BigInteger) DpnToInterfaceKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface) PhysAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)

Example 3 with DpnToInterfaceList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.DpnToInterfaceList in project netvirt by opendaylight.

the class PolicyRouteGroupProgrammer method programPolicyClassifierGroupBuckets.

public void programPolicyClassifierGroupBuckets(String policyClassifier, List<String> underlayNetworks, int addOrRemove) {
    if (underlayNetworks == null) {
        return;
    }
    coordinator.enqueueJob(policyClassifier, () -> {
        WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
        for (int idx = 0; idx < underlayNetworks.size(); idx++) {
            final int bucketId = idx;
            String underlayNetwork = underlayNetworks.get(idx);
            List<DpnToInterface> dpnToInterfaceList = policyServiceUtil.getUnderlayNetworkDpnToInterfaces(underlayNetwork);
            dpnToInterfaceList.forEach(dpnToInterface -> {
                BigInteger dpId = dpnToInterface.getDpId();
                List<TunnelInterface> tunnelInterfaces = dpnToInterface.getTunnelInterface();
                programPolicyClassifierGroupBuckets(policyClassifier, tunnelInterfaces, dpId, bucketId, addOrRemove, tx);
            });
        }
        return Collections.singletonList(tx.submit());
    });
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.DpnToInterface) BigInteger(java.math.BigInteger) TunnelInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.underlay.networks.underlay.network.dpn.to._interface.TunnelInterface)

Example 4 with DpnToInterfaceList

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.DpnToInterfaceList in project genius by opendaylight.

the class InterfaceManagerCommonUtils method addStateEntry.

public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface addStateEntry(Interface interfaceInfo, String interfaceName, WriteTransaction transaction, PhysAddress physAddress, OperStatus operStatus, AdminStatus adminStatus, NodeConnectorId nodeConnectorId) {
    LOG.debug("adding interface state for {}", interfaceName);
    InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setType(Other.class).setIfIndex(IfmConstants.DEFAULT_IFINDEX);
    Integer ifIndex;
    Class<? extends InterfaceType> interfaceType = null;
    if (interfaceInfo != null) {
        if (!interfaceInfo.isEnabled()) {
            operStatus = OperStatus.Down;
        }
        interfaceType = interfaceInfo.getType();
        ifaceBuilder.setType(interfaceType);
        // retrieve if-index only for northbound configured interfaces
        ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceName);
        ifaceBuilder.setIfIndex(ifIndex);
        interfaceMetaUtils.createLportTagInterfaceMap(interfaceName, ifIndex);
    }
    InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId = IfmUtil.buildStateInterfaceId(interfaceName);
    List<String> childLowerLayerIfList = new ArrayList<>();
    if (nodeConnectorId != null) {
        childLowerLayerIfList.add(0, nodeConnectorId.getValue());
    } else {
        // logical tunnel group doesn't have OF port
        ParentRefs parentRefs = interfaceInfo.getAugmentation(ParentRefs.class);
        if (parentRefs != null) {
            BigInteger dpId = parentRefs.getDatapathNodeIdentifier();
            String lowref = MDSALUtil.NODE_PREFIX + MDSALUtil.SEPARATOR + dpId + MDSALUtil.SEPARATOR + 0;
            childLowerLayerIfList.add(0, lowref);
        }
    }
    ifaceBuilder.setAdminStatus(adminStatus).setOperStatus(operStatus).setLowerLayerIf(childLowerLayerIfList);
    if (physAddress != null) {
        ifaceBuilder.setPhysAddress(physAddress);
    }
    ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
    ifaceBuilder.setStatistics(new StatisticsBuilder().setDiscontinuityTime(DateAndTime.getDefaultInstance(ZonedDateTime.now().format(DateTimeFormatter.ISO_INSTANT))).build());
    org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = ifaceBuilder.build();
    boolean isTunnelInterface = InterfaceManagerCommonUtils.isTunnelInterface(interfaceInfo);
    boolean isOfTunnelInterface = InterfaceManagerCommonUtils.isOfTunnelInterface(interfaceInfo);
    if (isTunnelInterface && !isOfTunnelInterface) {
        batchingUtils.write(ifStateId, ifState, BatchingUtils.EntityType.DEFAULT_OPERATIONAL);
    } else {
        transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifState, true);
    }
    if (nodeConnectorId != null) {
        BigInteger dpId = IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId);
        // Update the DpnToInterfaceList OpDS
        createOrUpdateDpnToInterface(dpId, interfaceName, interfaceType);
    }
    return ifState;
}
Also used : Collections(java.util.Collections) ArrayList(java.util.ArrayList) ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder) StatisticsBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state._interface.StatisticsBuilder) BigInteger(java.math.BigInteger) BigInteger(java.math.BigInteger) Interface(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface) DpnToInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface) Other(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other)

Aggregations

BigInteger (java.math.BigInteger)3 ArrayList (java.util.ArrayList)2 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)2 InterfaceBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder)2 StatisticsBuilder (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state._interface.StatisticsBuilder)2 DpnToInterface (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterface)2 Collections (java.util.Collections)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)1 Other (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Other)1 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)1 AdminStatus (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus)1 OperStatus (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus)1 PhysAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress)1 DpnToInterfaceKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.dpn.to._interface.list.DpnToInterfaceKey)1 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)1 GetDpnInterfaceListInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput)1 GetDpnInterfaceListInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder)1 Interfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces)1