use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project bgpcep by opendaylight.
the class AbstractLabeledUnicastRIBSupport method extractLabel.
public static List<LabelStack> extractLabel(final DataContainerNode<? extends PathArgument> route, final NodeIdentifier labelStackNid, final NodeIdentifier labelValueNid) {
final List<LabelStack> labels = new ArrayList<>();
final Optional<DataContainerChild<? extends PathArgument, ?>> labelStacks = route.getChild(labelStackNid);
if (labelStacks.isPresent()) {
for (final UnkeyedListEntryNode label : ((UnkeyedListNode) labelStacks.get()).getValue()) {
final Optional<DataContainerChild<? extends PathArgument, ?>> labelStack = label.getChild(labelValueNid);
if (labelStack.isPresent()) {
final LabelStackBuilder labelStackbuilder = new LabelStackBuilder();
labelStackbuilder.setLabelValue(new MplsLabel((Long) labelStack.get().getValue()));
labels.add(labelStackbuilder.build());
}
}
}
return labels;
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project bgpcep by opendaylight.
the class LinkstateNlriParser method serializeLocalNodeDescriptor.
private static void serializeLocalNodeDescriptor(final CLinkstateDestinationBuilder builder, final ChoiceNode objectType) {
// link local node descriptors
final LinkCaseBuilder linkBuilder = new LinkCaseBuilder();
linkBuilder.setLocalNodeDescriptors(NodeNlriParser.serializeLocalNodeDescriptors((ContainerNode) objectType.getChild(LOCAL_NODE_DESCRIPTORS_NID).get()));
// link remote node descriptors
if (objectType.getChild(REMOTE_NODE_DESCRIPTORS_NID).isPresent()) {
linkBuilder.setRemoteNodeDescriptors(NodeNlriParser.serializeRemoteNodeDescriptors((ContainerNode) objectType.getChild(REMOTE_NODE_DESCRIPTORS_NID).get()));
}
// link descriptors
final Optional<DataContainerChild<? extends PathArgument, ?>> linkDescriptors = objectType.getChild(LINK_DESCRIPTORS_NID);
if (linkDescriptors.isPresent()) {
linkBuilder.setLinkDescriptors(LinkNlriParser.serializeLinkDescriptors((ContainerNode) linkDescriptors.get()));
}
builder.setObjectType(linkBuilder.build());
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project bgpcep by opendaylight.
the class LinkstateNlriParser method serializeCommonParts.
private static void serializeCommonParts(final CLinkstateDestinationBuilder builder, final DataContainerNode<? extends PathArgument> linkstate) {
// serialize common parts
final Optional<DataContainerChild<? extends PathArgument, ?>> distinguisher = linkstate.getChild(DISTINGUISHER_NID);
if (distinguisher.isPresent()) {
builder.setDistinguisher(new RouteDistinguisher((BigInteger) distinguisher.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> protocolId = linkstate.getChild(PROTOCOL_ID_NID);
// DOM representation contains values as are in the model, not as are in generated enum
if (protocolId.isPresent()) {
builder.setProtocolId(ProtocolId.forValue(domProtocolIdValue((String) protocolId.get().getValue())));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> identifier = linkstate.getChild(IDENTIFIER_NID);
if (identifier.isPresent()) {
builder.setIdentifier(new Identifier((BigInteger) identifier.get().getValue()));
}
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createDscpsLengths.
private static List<Dscps> createDscpsLengths(final UnkeyedListNode dscpLengthsData) {
final List<Dscps> dscpsLengths = new ArrayList<>();
for (final UnkeyedListEntryNode node : dscpLengthsData.getValue()) {
final DscpsBuilder dscpsLengthsBuilder = new DscpsBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
if (opValue.isPresent()) {
dscpsLengthsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
if (valueNode.isPresent()) {
dscpsLengthsBuilder.setValue(new Dscp((Short) valueNode.get().getValue()));
}
dscpsLengths.add(dscpsLengthsBuilder.build());
}
return dscpsLengths;
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createSourcePorts.
private static List<SourcePorts> createSourcePorts(final UnkeyedListNode sourcePortsData) {
final List<SourcePorts> sourcePorts = new ArrayList<>();
for (final UnkeyedListEntryNode node : sourcePortsData.getValue()) {
final SourcePortsBuilder sourcePortsBuilder = new SourcePortsBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
if (opValue.isPresent()) {
sourcePortsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
if (valueNode.isPresent()) {
sourcePortsBuilder.setValue((Integer) valueNode.get().getValue());
}
sourcePorts.add(sourcePortsBuilder.build());
}
return sourcePorts;
}
Aggregations