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());
}
}
}
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();
}
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;
}
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);
}
}
Aggregations