use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.classtype.object.ClassTypeBuilder 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.classtype.object.ClassTypeBuilder 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.classtype.object.ClassTypeBuilder in project bgpcep by opendaylight.
the class PCEPObjectParserTest method testClassTypeObject.
@Test
public void testClassTypeObject() throws PCEPDeserializerException {
final PCEPClassTypeObjectParser parser = new PCEPClassTypeObjectParser();
final ByteBuf result = Unpooled.wrappedBuffer(new byte[] { (byte) 0x16, (byte) 0x12, (byte) 0x00, (byte) 0x08, 0, 0, 0, (byte) 0x04 });
final ClassTypeBuilder builder = new ClassTypeBuilder();
builder.setProcessingRule(true);
builder.setIgnore(false);
builder.setClassType(new ClassType((short) 4));
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer();
parser.serializeObject(builder.build(), buf);
assertArrayEquals(result.array(), ByteArray.getAllBytes(buf));
try {
parser.parseObject(new ObjectHeaderImpl(true, true), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
try {
parser.parseObject(new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Array of bytes is mandatory. Can't be null or empty.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.classtype.object.ClassTypeBuilder in project bgpcep by opendaylight.
the class PCEPClassTypeObjectParser method parseObject.
@Override
public Object 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.");
if (!header.isProcessingRule()) {
LOG.debug("Processed bit not set on CLASS TYPE OBJECT, ignoring it");
return null;
}
if (bytes.readableBytes() != SIZE) {
throw new PCEPDeserializerException("Size of byte array doesn't match defined size. Expected: " + SIZE + "; Passed: " + bytes.readableBytes());
}
final ClassTypeBuilder builder = new ClassTypeBuilder();
builder.setIgnore(header.isIgnore());
builder.setProcessingRule(header.isProcessingRule());
final short ct = (short) bytes.readUnsignedInt();
builder.setClassType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ClassType(ct));
final Object obj = builder.build();
if (ct < 0 || ct > Byte.SIZE) {
LOG.debug("Invalid class type {}", ct);
return new UnknownObject(PCEPErrors.INVALID_CT, obj);
}
return obj;
}
Aggregations