use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspKey in project bgpcep by opendaylight.
the class NodeChangedListenerTest method createNode.
private void createNode(final NodeId nodeId, final String ipv4Address, final String lspName, final long lspId, final String dstIpv4Address) throws TransactionCommitFailedException {
final NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setKey(new NodeKey(nodeId));
nodeBuilder.setNodeId(nodeId);
final PathBuilder pathBuilder = new PathBuilder();
pathBuilder.setKey(new PathKey(new LspId(lspId)));
pathBuilder.setBandwidth(new BandwidthBuilder().setBandwidth(new Bandwidth(new byte[] { 0x00, 0x00, (byte) 0xff, (byte) 0xff })).build());
pathBuilder.addAugmentation(Path1.class, new Path1Builder().setLsp(new LspBuilder().setTlvs(new TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setAddressFamily(new Ipv4CaseBuilder().setIpv4(new Ipv4Builder().setIpv4TunnelSenderAddress(new Ipv4Address(ipv4Address)).setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(ipv4Address)).setIpv4TunnelEndpointAddress(new Ipv4Address(dstIpv4Address)).build()).build()).build()).build()).setAdministrative(true).setDelegate(true).build()).build());
final ReportedLsp reportedLps = new ReportedLspBuilder().setKey(new ReportedLspKey(lspName)).setPath(Collections.singletonList(pathBuilder.build())).build();
final Node1Builder node1Builder = new Node1Builder();
node1Builder.setPathComputationClient(new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).setReportedLsp(Lists.newArrayList(reportedLps)).setIpAddress(new IpAddress(new Ipv4Address(ipv4Address))).build());
nodeBuilder.addAugmentation(Node1.class, node1Builder.build());
final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID.builder().child(Node.class, new NodeKey(nodeId)).build(), nodeBuilder.build());
wTx.submit().checkedGet();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspKey in project bgpcep by opendaylight.
the class AbstractTopologySessionListener method updateLsp.
/**
* Update an LSP in the data store.
*
* @param ctx Message context
* @param id Revision-specific LSP identifier
* @param lspName LSP name
* @param rlb Reported LSP builder
* @param solicited True if the update was solicited
* @param remove True if this is an LSP path removal
*/
protected final synchronized void updateLsp(final MessageContext ctx, final L id, final String lspName, final ReportedLspBuilder rlb, final boolean solicited, final boolean remove) {
final String name;
if (lspName == null) {
name = this.lsps.get(id);
if (name == null) {
LOG.error("PLSPID {} seen for the first time, not reporting the LSP", id);
return;
}
} else {
name = lspName;
}
LOG.debug("Saved LSP {} with name {}", id, name);
this.lsps.put(id, name);
final ReportedLsp previous = this.lspData.get(name);
// if no previous report about the lsp exist, just proceed
if (previous != null) {
final Map<PathKey, Path> updatedPaths = makeBeforeBreak(rlb, previous, name, remove);
// if all paths or the last path were deleted, delete whole tunnel
if (updatedPaths.isEmpty()) {
LOG.debug("All paths were removed, removing LSP with {}.", id);
removeLsp(ctx, id);
return;
}
rlb.setPath(updatedPaths);
}
rlb.withKey(new ReportedLspKey(name));
rlb.setName(name);
// If this is an unsolicited update. We need to make sure we retain the metadata already present
if (solicited) {
this.nodeState.setLspMetadata(name, rlb.getMetadata());
} else {
rlb.setMetadata(this.nodeState.getLspMetadata(name));
}
final ReportedLsp rl = rlb.build();
ctx.trans.put(LogicalDatastoreType.OPERATIONAL, this.pccIdentifier.child(ReportedLsp.class, rlb.key()), rl);
LOG.debug("LSP {} updated to MD-SAL", name);
this.lspData.put(name, rl);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspKey in project bgpcep by opendaylight.
the class NodeChangedListenerTest method createNode.
private void createNode(final NodeId nodeId, final String ipv4Address, final String lspName, final Uint32 lspId, final String dstIpv4Address) throws InterruptedException, ExecutionException {
final NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.withKey(new NodeKey(nodeId));
nodeBuilder.setNodeId(nodeId);
final PathBuilder pathBuilder = new PathBuilder();
pathBuilder.withKey(new PathKey(new LspId(lspId)));
pathBuilder.setBandwidth(new BandwidthBuilder().setBandwidth(new Bandwidth(new byte[] { 0x00, 0x00, (byte) 0xff, (byte) 0xff })).build());
pathBuilder.addAugmentation(new Path1Builder().setLsp(new LspBuilder().setTlvs(new TlvsBuilder().setLspIdentifiers(new LspIdentifiersBuilder().setAddressFamily(new Ipv4CaseBuilder().setIpv4(new Ipv4Builder().setIpv4TunnelSenderAddress(new Ipv4AddressNoZone(ipv4Address)).setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(ipv4Address)).setIpv4TunnelEndpointAddress(new Ipv4AddressNoZone(dstIpv4Address)).build()).build()).build()).build()).setAdministrative(true).setDelegate(true).build()).build());
final ReportedLsp reportedLps = new ReportedLspBuilder().withKey(new ReportedLspKey(lspName)).setPath(BindingMap.of(pathBuilder.build())).build();
final Node1Builder node1Builder = new Node1Builder();
node1Builder.setPathComputationClient(new PathComputationClientBuilder().setStateSync(PccSyncState.Synchronized).setReportedLsp(BindingMap.of(reportedLps)).setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone(ipv4Address))).build());
nodeBuilder.addAugmentation(node1Builder.build());
final WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction();
wTx.put(LogicalDatastoreType.OPERATIONAL, PCEP_TOPO_IID.builder().child(Node.class, new NodeKey(nodeId)).build(), nodeBuilder.build());
wTx.commit().get();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev200120.pcep.client.attributes.path.computation.client.ReportedLspKey in project bgpcep by opendaylight.
the class TopologyProviderTest method testOnReportMessage.
@Test
public void testOnReportMessage() throws ExecutionException, InterruptedException {
listener.onSessionUp(session);
Pcrpt pcRptMsg = createSrPcRpt("1.1.1.1", "sr-path1", Uint32.ONE, true);
listener.onMessage(session, pcRptMsg);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check sr-path
final Map<ReportedLspKey, ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(1, reportedLsps.size());
final ReportedLsp lsp = reportedLsps.values().iterator().next();
assertEquals("sr-path1", lsp.getName());
final Map<PathKey, Path> paths = lsp.getPath();
assertNotNull(paths);
final Path path = paths.values().iterator().next();
assertEquals(1, path.augmentation(Path1.class).getPathSetupType().getPst().intValue());
final List<Subobject> subobjects = path.getEro().nonnullSubobject();
assertEquals(1, subobjects.size());
assertEquals("1.1.1.1", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4AddressNoZone().getValue());
return pcc;
});
pcRptMsg = createSrPcRpt("1.1.1.3", "sr-path2", Uint32.TWO, false);
listener.onMessage(session, pcRptMsg);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check second lsp sr-path
final Map<ReportedLspKey, ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(2, reportedLsps.size());
return pcc;
});
pcRptMsg = createSrPcRpt("1.1.1.2", "sr-path1", Uint32.ONE, true);
listener.onMessage(session, pcRptMsg);
readDataOperational(getDataBroker(), pathComputationClientIId, pcc -> {
// check updated sr-path
final Map<ReportedLspKey, ReportedLsp> reportedLsps = pcc.getReportedLsp();
assertNotNull(reportedLsps);
assertEquals(2, reportedLsps.size());
for (final ReportedLsp rlsp : reportedLsps.values()) {
if (rlsp.getName().equals("sr-path1")) {
final List<Subobject> subobjects = rlsp.nonnullPath().values().iterator().next().getEro().nonnullSubobject();
assertEquals(1, subobjects.size());
assertEquals("1.1.1.2", ((IpNodeId) ((SrEroType) subobjects.get(0).getSubobjectType()).getNai()).getIpAddress().getIpv4AddressNoZone().getValue());
}
}
return pcc;
});
}
Aggregations