Search in sources :

Example 1 with PathArgument

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument in project controller by opendaylight.

the class DsbenchmarkListener method logDataTreeChangeEvent.

private static synchronized void logDataTreeChangeEvent(final int eventNum, final Collection<DataTreeModification<TestExec>> changes) {
    LOG.debug("DsbenchmarkListener-onDataTreeChanged: Event {}", eventNum);
    for (DataTreeModification<TestExec> change : changes) {
        final DataObjectModification<TestExec> rootNode = change.getRootNode();
        final ModificationType modType = rootNode.getModificationType();
        final PathArgument changeId = rootNode.getIdentifier();
        final Collection<DataObjectModification<? extends DataObject>> modifications = rootNode.getModifiedChildren();
        LOG.debug("    changeId {}, modType {}, mods: {}", changeId, modType, modifications.size());
        for (DataObjectModification<? extends DataObject> mod : modifications) {
            LOG.debug("      mod-getDataAfter: {}", mod.getDataAfter());
        }
    }
}
Also used : DataObject(org.opendaylight.yangtools.yang.binding.DataObject) ModificationType(org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType) DataObjectModification(org.opendaylight.controller.md.sal.binding.api.DataObjectModification) TestExec(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec) PathArgument(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument)

Example 2 with PathArgument

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument in project openflowplugin by opendaylight.

the class PacketOutConvertor method convert.

@Override
public PacketOutInput convert(TransmitPacketInput source, PacketOutConvertorData data) {
    LOG.trace("toPacketOutInput for datapathId:{}, xid:{}", data.getDatapathId(), data.getXid());
    // Build Port ID from TransmitPacketInput.Ingress
    PortNumber inPortNr;
    Long bufferId = OFConstants.OFP_NO_BUFFER;
    Iterable<PathArgument> inArgs = null;
    if (source.getIngress() != null) {
        inArgs = source.getIngress().getValue().getPathArguments();
    }
    if (inArgs != null && Iterables.size(inArgs) >= 3) {
        inPortNr = getPortNumber(Iterables.get(inArgs, 2), data.getVersion());
    } else {
        // The packetOut originated from the controller
        inPortNr = new PortNumber(0xfffffffdL);
    }
    // Build Buffer ID to be NO_OFP_NO_BUFFER
    if (source.getBufferId() != null) {
        bufferId = source.getBufferId();
    }
    PortNumber outPort = null;
    NodeConnectorRef outRef = source.getEgress();
    Iterable<PathArgument> outArgs = outRef.getValue().getPathArguments();
    if (Iterables.size(outArgs) >= 3) {
        outPort = getPortNumber(Iterables.get(outArgs, 2), data.getVersion());
    } else {
        // TODO : P4 search for some normal exception
        // new Exception("PORT NR not exist in Egress");
        LOG.error("PORT NR not exist in Egress");
    }
    List<Action> actions = new ArrayList<>();
    List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> inputActions = source.getAction();
    if (inputActions != null) {
        final ActionConvertorData actionConvertorData = new ActionConvertorData(data.getVersion());
        actionConvertorData.setDatapathId(data.getDatapathId());
        final Optional<List<Action>> convertedActions = getConvertorExecutor().convert(inputActions, actionConvertorData);
        actions = convertedActions.orElse(Collections.emptyList());
    } else {
        // TODO VD P! wait for way to move Actions (e.g. augmentation)
        OutputActionCaseBuilder outputActionCaseBuilder = new OutputActionCaseBuilder();
        OutputActionBuilder outputActionBuilder = new OutputActionBuilder();
        outputActionBuilder.setPort(outPort);
        outputActionBuilder.setMaxLength(OFConstants.OFPCML_NO_BUFFER);
        outputActionCaseBuilder.setOutputAction(outputActionBuilder.build());
        ActionBuilder actionBuild = new ActionBuilder();
        actionBuild.setActionChoice(outputActionCaseBuilder.build());
        actions.add(actionBuild.build());
    }
    PacketOutInputBuilder builder = new PacketOutInputBuilder();
    builder.setAction(actions);
    builder.setData(source.getPayload());
    builder.setVersion(data.getVersion());
    builder.setXid(data.getXid());
    builder.setInPort(inPortNr);
    builder.setBufferId(bufferId);
    return builder.build();
}
Also used : OutputActionCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder) NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder) ArrayList(java.util.ArrayList) ActionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData) PacketOutInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder) OutputActionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder) ArrayList(java.util.ArrayList) List(java.util.List) PathArgument(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)

Example 3 with PathArgument

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument in project controller by opendaylight.

the class LazyDataObjectModification method getModifiedChild.

@Override
public DataObjectModification<? extends DataObject> getModifiedChild(final PathArgument arg) {
    final List<YangInstanceIdentifier.PathArgument> domArgumentList = new ArrayList<>();
    final BindingCodecTreeNode<?> childCodec = codec.bindingPathArgumentChild(arg, domArgumentList);
    final Iterator<YangInstanceIdentifier.PathArgument> toEnter = domArgumentList.iterator();
    DataTreeCandidateNode current = domData;
    while (toEnter.hasNext() && current != null) {
        current = current.getModifiedChild(toEnter.next());
    }
    if (current != null) {
        return create(childCodec, current);
    }
    return null;
}
Also used : DataTreeCandidateNode(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode) ArrayList(java.util.ArrayList) PathArgument(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument)

Example 4 with PathArgument

use of org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument in project bgpcep by opendaylight.

the class NodeChangedListener method handleChangedNode.

private void handleChangedNode(final DataObjectModification<?> changedNode, final InstanceIdentifier<?> iid, final Set<InstanceIdentifier<ReportedLsp>> lsps, final Set<InstanceIdentifier<Node>> nodes, final Map<InstanceIdentifier<?>, DataObject> original, final Map<InstanceIdentifier<?>, DataObject> updated, final Map<InstanceIdentifier<?>, DataObject> created) {
    // Categorize reported identifiers
    categorizeIdentifier(iid, lsps, nodes);
    // Get the subtrees
    switch(changedNode.getModificationType()) {
        case DELETE:
            original.put(iid, changedNode.getDataBefore());
            break;
        case SUBTREE_MODIFIED:
            original.put(iid, changedNode.getDataBefore());
            updated.put(iid, changedNode.getDataAfter());
            break;
        case WRITE:
            created.put(iid, changedNode.getDataAfter());
            break;
        default:
            throw new IllegalArgumentException("Unhandled modification type " + changedNode.getModificationType());
    }
    for (DataObjectModification<? extends DataObject> child : changedNode.getModifiedChildren()) {
        final List<PathArgument> pathArguments = new ArrayList<>();
        for (PathArgument pathArgument : iid.getPathArguments()) {
            pathArguments.add(pathArgument);
        }
        pathArguments.add(child.getIdentifier());
        final InstanceIdentifier<?> childIID = InstanceIdentifier.create(pathArguments);
        handleChangedNode(child, childIID, lsps, nodes, original, updated, created);
    }
}
Also used : ArrayList(java.util.ArrayList) PathArgument(org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument)

Aggregations

PathArgument (org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument)4 ArrayList (java.util.ArrayList)3 List (java.util.List)1 DataObjectModification (org.opendaylight.controller.md.sal.binding.api.DataObjectModification)1 ModificationType (org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType)1 ActionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.action.data.ActionConvertorData)1 NodeConnectorRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef)1 OutputActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCaseBuilder)1 OutputActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.output.action._case.OutputActionBuilder)1 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action)1 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.ActionBuilder)1 PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)1 PacketOutInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInputBuilder)1 TestExec (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchmark.rev150105.TestExec)1 DataObject (org.opendaylight.yangtools.yang.binding.DataObject)1 DataTreeCandidateNode (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode)1