use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder in project bgpcep by opendaylight.
the class UpdateTunnelInstructionExecutor method buildUpdateInput.
private UpdateLspInput buildUpdateInput(final Link link, final Node node) {
final UpdateLspInputBuilder ab = new UpdateLspInputBuilder();
ab.setName(link.getAugmentation(Link1.class).getSymbolicPathName());
ab.setNode(requireNonNull(TunelProgrammingUtil.supportingNode(node)));
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.update.lsp.args.ArgumentsBuilder args = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.update.lsp.args.ArgumentsBuilder();
args.setBandwidth(new BandwidthBuilder().setBandwidth(this.updateTunnelInput.getBandwidth()).build());
args.setClassType(new ClassTypeBuilder().setClassType(this.updateTunnelInput.getClassType()).build());
args.setEro(TunelProgrammingUtil.buildEro(this.updateTunnelInput.getExplicitHops()));
args.setLspa(new LspaBuilder(this.updateTunnelInput).build());
final AdministrativeStatus adminStatus = this.updateTunnelInput.getAugmentation(PcepUpdateTunnelInput1.class).getAdministrativeStatus();
if (adminStatus != null) {
args.addAugmentation(Arguments3.class, new Arguments3Builder().setLsp(new LspBuilder().setAdministrative(adminStatus == AdministrativeStatus.Active).build()).build());
}
ab.setArguments(args.build());
return ab.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder in project bgpcep by opendaylight.
the class CreateTunnelInstructionExecutor method buildArguments.
private Arguments buildArguments(final TerminationPoint sp, final TerminationPoint dp) {
final ArgumentsBuilder args = new ArgumentsBuilder();
if (this.p2pTunnelInput.getBandwidth() != null) {
args.setBandwidth(new BandwidthBuilder().setBandwidth(this.p2pTunnelInput.getBandwidth()).build());
}
if (this.p2pTunnelInput.getClassType() != null) {
args.setClassType(new ClassTypeBuilder().setClassType(this.p2pTunnelInput.getClassType()).build());
}
args.setEndpointsObj(new EndpointsObjBuilder().setAddressFamily(buildAddressFamily(sp, dp)).build());
args.setEro(TunelProgrammingUtil.buildEro(this.p2pTunnelInput.getExplicitHops()));
args.setLspa(new LspaBuilder(this.p2pTunnelInput).build());
final AdministrativeStatus adminStatus = this.p2pTunnelInput.getAugmentation(PcepCreateP2pTunnelInput1.class).getAdministrativeStatus();
if (adminStatus != null) {
args.addAugmentation(Arguments2.class, new Arguments2Builder().setLsp(new LspBuilder().setAdministrative(adminStatus == AdministrativeStatus.Active).build()).build());
}
return args.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.LspaBuilder 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.rev131005.lspa.object.LspaBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testLspaObjectSerializerDefence.
@Test
public void testLspaObjectSerializerDefence() throws IOException, PCEPDeserializerException {
final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
final LspaBuilder builder = new LspaBuilder();
builder.setProcessingRule(true);
builder.setIgnore(true);
builder.setLocalProtectionDesired(false);
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
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.rev131005.lspa.object.LspaBuilder in project bgpcep by opendaylight.
the class PCEPLspaObjectParser method parseObject.
@Override
public Lspa parseObject(final ObjectHeader header, final ByteBuf bytes) throws PCEPDeserializerException {
Preconditions.checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
final LspaBuilder builder = new LspaBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
builder.setExcludeAny(new AttributeFilter(bytes.readUnsignedInt()));
builder.setIncludeAll(new AttributeFilter(bytes.readUnsignedInt()));
builder.setIncludeAny(new AttributeFilter(bytes.readUnsignedInt()));
builder.setSetupPriority(bytes.readUnsignedByte());
builder.setHoldPriority(bytes.readUnsignedByte());
final BitArray flags = BitArray.valueOf(bytes.readByte());
builder.setLocalProtectionDesired(flags.get(L_FLAG_OFFSET));
final TlvsBuilder tbuilder = new TlvsBuilder();
bytes.skipBytes(RESERVED);
parseTlvs(tbuilder, bytes.slice());
builder.setTlvs(tbuilder.build());
return builder.build();
}
Aggregations