use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.PcepEntityIdRpcAugBuilder in project bgpcep by opendaylight.
the class TopologyStatsRpcServiceImpl method transformStatefulAugmentation.
/*
* Replace stateful topology augmentations with ones for rpc in PCEP session
* stats data
*/
private static PcepSessionState transformStatefulAugmentation(final PcepSessionState pcepSessionState) {
if (pcepSessionState == null) {
return null;
}
final PcepSessionStateBuilder sb = new PcepSessionStateBuilder(pcepSessionState);
final Messages topoMessage = pcepSessionState.getMessages();
if (topoMessage != null) {
final StatefulMessagesStatsAug messageStatsAug = topoMessage.augmentation(StatefulMessagesStatsAug.class);
if (messageStatsAug != null) {
sb.setMessages(new MessagesBuilder(topoMessage).removeAugmentation(StatefulMessagesStatsAug.class).addAugmentation(new StatefulMessagesRpcAugBuilder().setLastReceivedRptMsgTimestamp(messageStatsAug.getLastReceivedRptMsgTimestamp()).setReceivedRptMsgCount(messageStatsAug.getReceivedRptMsgCount()).setSentInitMsgCount(messageStatsAug.getSentInitMsgCount()).setSentUpdMsgCount(messageStatsAug.getSentUpdMsgCount()).build()).build());
}
}
final PeerCapabilities topoPeerCapability = pcepSessionState.getPeerCapabilities();
if (topoPeerCapability != null) {
final StatefulCapabilitiesStatsAug capabilityStatsAug = topoPeerCapability.augmentation(StatefulCapabilitiesStatsAug.class);
if (capabilityStatsAug != null) {
sb.setPeerCapabilities(new PeerCapabilitiesBuilder(topoPeerCapability).removeAugmentation(StatefulCapabilitiesStatsAug.class).addAugmentation(new StatefulCapabilitiesRpcAugBuilder().setActive(capabilityStatsAug.getActive()).setInstantiation(capabilityStatsAug.getInstantiation()).setStateful(capabilityStatsAug.getStateful()).build()).build());
}
}
final LocalPref topoLocalPref = pcepSessionState.getLocalPref();
if (topoLocalPref != null) {
final PcepEntityIdStatsAug entityStatsAug = topoLocalPref.augmentation(PcepEntityIdStatsAug.class);
if (entityStatsAug != null) {
sb.setLocalPref(new LocalPrefBuilder(topoLocalPref).removeAugmentation(PcepEntityIdStatsAug.class).addAugmentation(new PcepEntityIdRpcAugBuilder().setSpeakerEntityIdValue(entityStatsAug.getSpeakerEntityIdValue()).build()).build());
}
}
return sb.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stateful.stats.rev181109.PcepEntityIdRpcAugBuilder in project bgpcep by opendaylight.
the class TopologyStatsRpcServiceImplTest method createRpcSessionState.
private static PcepSessionState createRpcSessionState() {
final ReplyTime replyTime = new ReplyTimeBuilder().setAverageTime(Uint32.ONE).setMaxTime(Uint32.valueOf(3)).setMinTime(Uint32.TWO).build();
final ErrorMessages errorMsg = new ErrorMessagesBuilder().setReceivedErrorMsgCount(Uint32.ONE).setSentErrorMsgCount(Uint32.TWO).build();
final StatefulMessagesRpcAug statefulMsg = new StatefulMessagesRpcAugBuilder().setLastReceivedRptMsgTimestamp(Uint32.valueOf(1553183614L)).setSentUpdMsgCount(Uint32.ONE).setReceivedRptMsgCount(Uint32.TWO).setSentInitMsgCount(Uint32.valueOf(3)).build();
final Messages messages = new MessagesBuilder().setLastSentMsgTimestamp(Uint32.valueOf(1553183734L)).setUnknownMsgReceived(Uint16.ONE).setSentMsgCount(Uint32.valueOf(5)).setReceivedMsgCount(Uint32.valueOf(4)).setReplyTime(replyTime).setErrorMessages(errorMsg).addAugmentation(statefulMsg).build();
final PeerCapabilities capabilities = new PeerCapabilitiesBuilder().addAugmentation(new StatefulCapabilitiesRpcAugBuilder().setStateful(true).setInstantiation(true).setActive(true).build()).build();
final LocalPref localPref = new LocalPrefBuilder().setKeepalive(Uint8.valueOf(30)).setDeadtimer(Uint8.valueOf(120)).setIpAddress("127.0.0.1").setSessionId(Uint16.ZERO).addAugmentation(new PcepEntityIdRpcAugBuilder().setSpeakerEntityIdValue(new byte[] { 0x01, 0x02, 0x03, 0x04 }).build()).build();
return new PcepSessionStateBuilder().setSynchronized(true).setSessionDuration("0:00:05:18").setDelegatedLspsCount(Uint16.ONE).setLocalPref(localPref).setPeerPref(new PeerPrefBuilder(localPref).build()).setPeerCapabilities(capabilities).setMessages(messages).build();
}
Aggregations