use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project bgpcep by opendaylight.
the class AbstractLabeledUnicastRIBSupport method extractCLabeledUnicastDestination.
/**
* Conversion from DataContainer to LabeledUnicastDestination Object
*
* @param route DataContainer
* @return LabeledUnicastDestination Object
*/
private CLabeledUnicastDestination extractCLabeledUnicastDestination(final DataContainerNode<? extends PathArgument> route) {
final CLabeledUnicastDestinationBuilder builder = new CLabeledUnicastDestinationBuilder();
builder.setPrefix(extractPrefix(route, PREFIX_TYPE_NID));
builder.setLabelStack(extractLabel(route, LABEL_STACK_NID, LV_NID));
builder.setPathId(PathIdUtil.buildPathId(route, routePathIdNid()));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project bgpcep by opendaylight.
the class LinkstateNlriParser method extractLinkstateDestination.
public static CLinkstateDestination extractLinkstateDestination(final DataContainerNode<? extends PathArgument> linkstate) {
final CLinkstateDestinationBuilder builder = new CLinkstateDestinationBuilder();
serializeCommonParts(builder, linkstate);
final ChoiceNode objectType = (ChoiceNode) linkstate.getChild(OBJECT_TYPE_NID).get();
if (objectType.getChild(ADVERTISING_NODE_DESCRIPTORS_NID).isPresent()) {
serializeAdvertisedNodeDescriptor(builder, objectType);
} else if (objectType.getChild(LOCAL_NODE_DESCRIPTORS_NID).isPresent()) {
serializeLocalNodeDescriptor(builder, objectType);
} else if (objectType.getChild(NODE_DESCRIPTORS_NID).isPresent()) {
serializeNodeDescriptor(builder, objectType);
} else if (AbstractTeLspNlriCodec.isTeLsp(objectType)) {
builder.setObjectType(AbstractTeLspNlriCodec.serializeTeLsp(objectType));
} else {
LOG.warn("Unknown Object Type: {}.", objectType);
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testLspaObject.
@Test
public void testLspaObject() throws IOException, PCEPDeserializerException {
final Stateful07LspaObjectParser parser = new Stateful07LspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
final LspaBuilder builder = new LspaBuilder();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject3RandVals.bin"));
final SymbolicPathName tlv = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.SymbolicPathName(new byte[] { (byte) 0x4d, (byte) 0x65, (byte) 0x64, (byte) 0x20, (byte) 0x74, (byte) 0x65, (byte) 0x73, (byte) 0x74, (byte) 0x20, (byte) 0x6f, (byte) 0x66, (byte) 0x20, (byte) 0x73, (byte) 0x79, (byte) 0x6d, (byte) 0x62, (byte) 0x6f, (byte) 0x6c, (byte) 0x69, (byte) 0x63, (byte) 0x20, (byte) 0x6e, (byte) 0x61, (byte) 0x6d, (byte) 0x65 })).build();
builder.setIgnore(false);
builder.setProcessingRule(false);
builder.setExcludeAny(new AttributeFilter(0x20A1FEE3L));
builder.setIncludeAny(new AttributeFilter(0x1A025CC7L));
builder.setIncludeAll(new AttributeFilter(0x2BB66532L));
builder.setHoldPriority((short) 0x02);
builder.setSetupPriority((short) 0x03);
builder.setLocalProtectionDesired(true);
builder.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.lspa.TlvsBuilder().addAugmentation(Tlvs2.class, new Tlvs2Builder().setSymbolicPathName(tlv).build()).build());
// Tlvs container does not contain toString
final Object o = parser.parseObject(new ObjectHeaderImpl(true, true), result.slice(4, result.readableBytes() - 4));
assertEquals(tlv, ((Lspa) o).getTlvs().getAugmentation(Tlvs2.class).getSymbolicPathName());
// assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, true), ByteArray.cutBytes(result,
// 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project bgpcep by opendaylight.
the class Stateful07ErrorMessageParser method insertObject.
private static State insertObject(final State state, final Object obj, final List<Errors> errorObjects, final List<Rps> requestParameters, final List<Srps> srps, final PcerrMessageBuilder b) {
switch(state) {
case ERROR_IN:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR_IN;
}
case RP_IN:
if (obj instanceof Rp) {
final Rp o = (Rp) obj;
requestParameters.add(new RpsBuilder().setRp(o).build());
return State.RP_IN;
}
case SRP_IN:
if (obj instanceof Srp) {
final Srp o = (Srp) obj;
srps.add(new SrpsBuilder().setSrp(o).build());
return State.SRP_IN;
}
case OPEN:
if (obj instanceof Open) {
b.setErrorType(new SessionCaseBuilder().setSession(new SessionBuilder().setOpen((Open) obj).build()).build());
return State.OPEN_IN;
}
case ERROR:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR;
}
case OPEN_IN:
case END:
return State.END;
default:
return state;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method validate.
@Override
public Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty()) {
throw new PCEPDeserializerException("Pcrpt message cannot be empty.");
}
final List<Reports> reports = Lists.newArrayList();
while (!objects.isEmpty()) {
final Reports report = getValidReports(objects, errors);
if (report != null) {
reports.add(report);
}
}
return new PcrptBuilder().setPcrptMessage(new PcrptMessageBuilder().setReports(reports).build()).build();
}
Aggregations