use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method validateLsp.
private static boolean validateLsp(final Object object, final boolean lspViaSR, final List<Message> errors, final ReportsBuilder builder) {
if (object instanceof Lsp) {
final Lsp lsp = (Lsp) object;
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.lsp.Tlvs tlvs = lsp.getTlvs();
if (!lspViaSR && lsp.getPlspId().getValue() != 0 && (tlvs == null || tlvs.getLspIdentifiers() == null)) {
final Message errorMsg = createErrorMsg(PCEPErrors.LSP_IDENTIFIERS_TLV_MISSING, Optional.absent());
errors.add(errorMsg);
return false;
}
builder.setLsp(lsp);
return true;
}
errors.add(createErrorMsg(PCEPErrors.LSP_MISSING, Optional.absent()));
return false;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp in project bgpcep by opendaylight.
the class CInitiated00LspObjectParser method serializeFlags.
@Override
protected BitArray serializeFlags(final Lsp specObj) {
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(DELEGATE, specObj.isDelegate());
flags.set(REMOVE, specObj.isRemove());
flags.set(SYNC, specObj.isSync());
flags.set(ADMINISTRATIVE, specObj.isAdministrative());
if (specObj.getAugmentation(Lsp1.class) != null) {
flags.set(CREATE_FLAG_OFFSET, specObj.getAugmentation(Lsp1.class).isCreate());
}
return flags;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp in project bgpcep by opendaylight.
the class RequiredAttributesObjectParser method localParseObject.
@Override
protected RsvpTeObject localParseObject(final ByteBuf byteBuf) throws RSVPParsingException {
final LspRequiredAttributesObjectBuilder builder = new LspRequiredAttributesObjectBuilder();
final List<SubobjectContainer> subObjectList = new ArrayList<>();
while (byteBuf.isReadable()) {
final int type = byteBuf.readUnsignedShort();
final int length = byteBuf.readUnsignedShort();
final ByteBuf value = byteBuf.readSlice(length);
final SubobjectContainerBuilder subObj = new SubobjectContainerBuilder();
if (type == AttributesObjectParser.FLAG_TLV_TYPE) {
subObj.setLspSubobject(new FlagsTlvBuilder().setFlagContainer(AttributesObjectParser.parseFlag(value)).build());
} else {
LOG.warn("Lsp Attributes Subobject type {} not supported", type);
}
subObjectList.add(subObj.build());
}
return builder.setLspAttributesObject(new LspAttributesObjectBuilder().setSubobjectContainer(subObjectList).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp in project bgpcep by opendaylight.
the class TunnelProgrammingTest method testTunnelProgramming.
@Test
public void testTunnelProgramming() throws TransactionCommitFailedException {
final Bandwidth bwd = new Bandwidth(new byte[] { 0x00, 0x00, 0x00, (byte) 0xff });
final ClassType classType = new ClassType((short) 1);
final String tunnelName = "create-tunnel";
final NetworkTopologyRef topologyRef = new NetworkTopologyRef(TOPO_IID);
// create tunnel
final PcepCreateP2pTunnelInputBuilder createInputBuilder = new PcepCreateP2pTunnelInputBuilder();
createInputBuilder.setDestination(new DestinationBuilder().setNode(NODE2_ID).setTp(TP2_ID).build());
createInputBuilder.setSource(new SourceBuilder().setNode(NODE1_ID).setTp(TP1_ID).build());
createInputBuilder.setNetworkTopologyRef(topologyRef);
createInputBuilder.setBandwidth(bwd);
createInputBuilder.setClassType(classType);
createInputBuilder.setSymbolicPathName(tunnelName);
createInputBuilder.setExplicitHops(Lists.newArrayList());
createInputBuilder.addAugmentation(PcepCreateP2pTunnelInput1.class, new PcepCreateP2pTunnelInput1Builder().setAdministrativeStatus(AdministrativeStatus.Active).build());
this.tunnelProgramming.pcepCreateP2pTunnel(createInputBuilder.build());
// check add-lsp input
Assert.assertNotNull(this.addLspInput);
Assert.assertEquals(tunnelName, this.addLspInput.getName());
final Arguments agrs = this.addLspInput.getArguments();
Assert.assertNotNull(agrs);
Assert.assertEquals(bwd, agrs.getBandwidth().getBandwidth());
Assert.assertEquals(classType, agrs.getClassType().getClassType());
final Ipv4 ipv4Endpoints = ((Ipv4Case) agrs.getEndpointsObj().getAddressFamily()).getIpv4();
Assert.assertEquals(NODE1_IPV4, ipv4Endpoints.getSourceIpv4Address().getValue());
Assert.assertEquals(NODE2_IPV4, ipv4Endpoints.getDestinationIpv4Address().getValue());
Assert.assertEquals(NODE1_ID.getValue(), this.addLspInput.getNode().getValue());
createLink();
// update tunnel
final PcepUpdateTunnelInputBuilder updateInputBuilder = new PcepUpdateTunnelInputBuilder();
updateInputBuilder.setNetworkTopologyRef(topologyRef);
updateInputBuilder.setBandwidth(bwd);
updateInputBuilder.setClassType(classType);
updateInputBuilder.setExplicitHops(Lists.newArrayList(createExplicitHop(IPV4_PREFIX1), createExplicitHop(IPV4_PREFIX2)));
updateInputBuilder.setLinkId(LINK1_ID);
updateInputBuilder.addAugmentation(PcepUpdateTunnelInput1.class, new PcepUpdateTunnelInput1Builder().setAdministrativeStatus(AdministrativeStatus.Active).build());
this.tunnelProgramming.pcepUpdateTunnel(updateInputBuilder.build());
// check update-lsp input
Assert.assertNotNull(this.updateLspInput);
Assert.assertEquals(LINK1_ID.getValue(), this.updateLspInput.getName());
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.update.lsp.args.Arguments updArgs = this.updateLspInput.getArguments();
Assert.assertEquals(2, updArgs.getEro().getSubobject().size());
final List<Subobject> subObjects = updArgs.getEro().getSubobject();
final IpPrefixCase prefix1 = (IpPrefixCase) subObjects.get(0).getSubobjectType();
final IpPrefixCase prefix2 = (IpPrefixCase) subObjects.get(1).getSubobjectType();
Assert.assertEquals(IPV4_PREFIX1, prefix1.getIpPrefix().getIpPrefix().getIpv4Prefix().getValue());
Assert.assertEquals(IPV4_PREFIX2, prefix2.getIpPrefix().getIpPrefix().getIpv4Prefix().getValue());
// delete tunnel
final PcepDestroyTunnelInputBuilder destroyInputBuilder = new PcepDestroyTunnelInputBuilder();
destroyInputBuilder.setLinkId(LINK1_ID);
destroyInputBuilder.setNetworkTopologyRef(topologyRef);
this.tunnelProgramming.pcepDestroyTunnel(destroyInputBuilder.build());
Assert.assertNotNull(this.removeLspInput);
Assert.assertEquals(LINK1_ID.getValue(), this.removeLspInput.getName());
Assert.assertEquals(NODE1_ID.getValue(), this.removeLspInput.getNode().getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.lsp.object.Lsp in project bgpcep by opendaylight.
the class NodeChangedListener method updateTransaction.
private void updateTransaction(final ReadWriteTransaction trans, final Set<InstanceIdentifier<ReportedLsp>> lsps, final Map<InstanceIdentifier<?>, ? extends DataObject> old, final Map<InstanceIdentifier<?>, DataObject> updated, final Map<InstanceIdentifier<?>, DataObject> created) {
for (final InstanceIdentifier<ReportedLsp> i : lsps) {
final ReportedLsp oldValue = (ReportedLsp) old.get(i);
ReportedLsp newValue = (ReportedLsp) updated.get(i);
if (newValue == null) {
newValue = (ReportedLsp) created.get(i);
}
LOG.debug("Updating lsp {} value {} -> {}", i, oldValue, newValue);
if (oldValue != null) {
try {
remove(trans, i, oldValue);
} catch (final ReadFailedException e) {
LOG.warn("Failed to remove LSP {}", i, e);
}
}
if (newValue != null) {
try {
create(trans, i, newValue);
} catch (final ReadFailedException e) {
LOG.warn("Failed to add LSP {}", i, e);
}
}
}
}
Aggregations