use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.MessagesBuilder in project bgpcep by opendaylight.
the class NeighborStateCliUtilsTest method testFullNeighborStateCli.
@Test
public void testFullNeighborStateCli() throws IOException {
final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder builder = new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder();
builder.addAugmentation(NeighborAfiSafiStateAugmentation.class, new NeighborAfiSafiStateAugmentationBuilder().setActive(true).setPrefixes(new PrefixesBuilder().setInstalled(1L).setReceived(1L).setSent(2L).build()).build());
final AfiSafi afiSafi = new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).setState(builder.build()).build();
final StateBuilder stateBuilder = new StateBuilder();
stateBuilder.addAugmentation(NeighborStateAugmentation.class, new NeighborStateAugmentationBuilder().setSupportedCapabilities(Collections.singletonList(ADDPATHS.class)).setSessionState(BgpNeighborState.SessionState.ACTIVE).build());
final Received received = new ReceivedBuilder().setNOTIFICATION(BigInteger.ONE).setUPDATE(BigInteger.TEN).build();
final Sent sent = new SentBuilder().setNOTIFICATION(BigInteger.TEN).setUPDATE(BigInteger.ONE).build();
stateBuilder.addAugmentation(BgpNeighborStateAugmentation.class, new BgpNeighborStateAugmentationBuilder().setMessages(new MessagesBuilder().setReceived(received).setSent(sent).build()).build());
final Transport transport = new TransportBuilder().setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.transport.StateBuilder().addAugmentation(NeighborTransportStateAugmentation.class, new NeighborTransportStateAugmentationBuilder().setRemoteAddress(NEIGHBOR_IP_ADDRESS).setLocalPort(new PortNumber(1234)).setRemotePort(new PortNumber(4321)).build()).build()).build();
final Timers timers = new TimersBuilder().setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers.StateBuilder().addAugmentation(NeighborTimersStateAugmentation.class, new NeighborTimersStateAugmentationBuilder().setNegotiatedHoldTime(BigDecimal.TEN).setUptime(new Timeticks(600L)).build()).build()).build();
final Neighbor neighbor = new NeighborBuilder().setState(stateBuilder.build()).setAfiSafis(new AfiSafisBuilder().setAfiSafi(Collections.singletonList(afiSafi)).build()).setTransport(transport).setTimers(timers).build();
NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS, neighbor, this.stream);
final String expected = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("neighbor.txt"), UTF8);
assertEquals(expected, this.output.toString());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.MessagesBuilder in project bgpcep by opendaylight.
the class PcepStateUtilsTest method createPcepSessionState.
private PcepSessionState createPcepSessionState() {
final LocalPref pref = new LocalPrefBuilder().setKeepalive((short) 30).setDeadtimer((short) 120).setIpAddress(IP_ADDRESS).setSessionId(0).addAugmentation(PcepEntityIdStatsAug.class, new PcepEntityIdStatsAugBuilder().setSpeakerEntityIdValue(SPEAKER_ID).build()).build();
final PeerCapabilities capa = new PeerCapabilitiesBuilder().addAugmentation(StatefulCapabilitiesStatsAug.class, new StatefulCapabilitiesStatsAugBuilder().setStateful(true).setInstantiation(true).setActive(true).build()).build();
final ReplyTime reply = new ReplyTimeBuilder().setAverageTime(1L).setMaxTime(3L).setMinTime(2L).build();
final ErrorMessages errorMsg = new ErrorMessagesBuilder().setReceivedErrorMsgCount(1L).setSentErrorMsgCount(2L).build();
final StatefulMessagesStatsAug statefulMsg = new StatefulMessagesStatsAugBuilder().setLastReceivedRptMsgTimestamp(1512043769L).setSentUpdMsgCount(1L).setReceivedRptMsgCount(2L).setSentInitMsgCount(3L).build();
final Messages messages = new MessagesBuilder().setLastSentMsgTimestamp(1512043828L).setUnknownMsgReceived(1).setSentMsgCount(5L).setReceivedMsgCount(4L).setReplyTime(reply).setErrorMessages(errorMsg).addAugmentation(StatefulMessagesStatsAug.class, statefulMsg).build();
return new PcepSessionStateBuilder().setSynchronized(true).setSessionDuration("0:00:01:26").setDelegatedLspsCount(1).setLocalPref(pref).setPeerPref(new PeerPrefBuilder(pref).build()).setPeerCapabilities(capa).setMessages(messages).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.MessagesBuilder in project openflowplugin by opendaylight.
the class FlowNodeReconciliationImpl method createMessages.
private Messages createMessages(final NodeRef nodeRef, final Optional<FlowCapableNode> flowNode) {
final List<Message> messages = new ArrayList<>();
messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleRemoveFlowCaseBuilder().setRemoveFlowCaseData(new RemoveFlowCaseDataBuilder(getDeleteAllFlow()).build()).build()).build());
messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleRemoveGroupCaseBuilder().setRemoveGroupCaseData(new RemoveGroupCaseDataBuilder(getDeleteAllGroup()).build()).build()).build());
if (flowNode.get().getGroup() != null) {
for (Group gr : flowNode.get().getGroup()) {
messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleAddGroupCaseBuilder().setAddGroupCaseData(new AddGroupCaseDataBuilder(gr).build()).build()).build());
}
}
if (flowNode.get().getTable() != null) {
for (Table table : flowNode.get().getTable()) {
for (Flow flow : table.getFlow()) {
messages.add(new MessageBuilder().setNode(nodeRef).setBundleInnerMessage(new BundleAddFlowCaseBuilder().setAddFlowCaseData(new AddFlowCaseDataBuilder(flow).build()).build()).build());
}
}
}
LOG.debug("The size of the flows and group messages created in createMessage() {}", messages.size());
return new MessagesBuilder().setMessage(messages).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.MessagesBuilder in project openflowplugin by opendaylight.
the class SalBundleServiceImplTest method testAddBundleMessages.
@Test
public void testAddBundleMessages() throws Exception {
final List<Message> innerMessages = createMessages();
final Messages messages = new MessagesBuilder().setMessage(innerMessages).build();
final AddBundleMessagesInput input = new AddBundleMessagesInputBuilder().setNode(NODE_REF).setBundleId(BUNDLE_ID).setFlags(BUNDLE_FLAGS).setBundleProperty(properties).setMessages(messages).build();
final SalAddMessageDataBuilder dataBuilder = new SalAddMessageDataBuilder();
dataBuilder.setBundleId(BUNDLE_ID).setFlags(BUNDLE_FLAGS).setBundleProperty(properties);
final BundleAddMessageSalBuilder addMessageBuilder = new BundleAddMessageSalBuilder();
final SendExperimenterInputBuilder experimenterBuilder = new SendExperimenterInputBuilder().setNode(NODE_REF);
Mockito.when(experimenterMessageService.sendExperimenter(Matchers.any())).thenReturn(SettableFuture.create());
service.addBundleMessages(input);
for (Message msg : innerMessages) {
Mockito.verify(experimenterMessageService).sendExperimenter(experimenterBuilder.setExperimenterMessageOfChoice(addMessageBuilder.setSalAddMessageData(dataBuilder.setNode(NODE_REF).setBundleInnerMessage(msg.getBundleInnerMessage()).build()).build()).build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.stats.rev171113.pcep.session.state.MessagesBuilder in project openflowplugin by opendaylight.
the class Activator method onDataTreeChanged.
@Override
public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<FlowCapableNode>> modifications) {
for (DataTreeModification modification : modifications) {
if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
LOG.info("Node connected: {}", modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class));
final NodeRef nodeRef = new NodeRef(modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class));
final ControlBundleInput openBundleInput = new ControlBundleInputBuilder().setNode(nodeRef).setBundleId(BUNDLE_ID).setFlags(BUNDLE_FLAGS).setType(BundleControlType.ONFBCTOPENREQUEST).build();
final ControlBundleInput commitBundleInput = new ControlBundleInputBuilder().setNode(nodeRef).setBundleId(BUNDLE_ID).setFlags(BUNDLE_FLAGS).setType(BundleControlType.ONFBCTCOMMITREQUEST).build();
final List<Message> innerMessages = createMessages(nodeRef);
final Messages messages = new MessagesBuilder().setMessage(innerMessages).build();
final AddBundleMessagesInput addBundleMessagesInput = new AddBundleMessagesInputBuilder().setNode(nodeRef).setBundleId(BUNDLE_ID).setFlags(BUNDLE_FLAGS).setMessages(messages).build();
makeCompletableFuture(bundleService.controlBundle(openBundleInput)).thenComposeAsync(voidRpcResult -> {
LOG.debug("Open successful: {}, msg: {}", voidRpcResult.isSuccessful(), voidRpcResult.getErrors());
final CompletableFuture<RpcResult<Void>> addFuture = makeCompletableFuture(bundleService.addBundleMessages(addBundleMessagesInput));
return addFuture;
}).thenComposeAsync(voidRpcResult -> {
LOG.debug("AddBundleMessages successful: {}, msg: {}", voidRpcResult.isSuccessful(), voidRpcResult.getErrors());
final CompletableFuture<RpcResult<Void>> controlCommitFuture = makeCompletableFuture(bundleService.controlBundle(commitBundleInput));
return controlCommitFuture;
}).thenAccept(voidRpcResult -> {
LOG.debug("Commit successful: {}, msg: {}", voidRpcResult.isSuccessful(), voidRpcResult.getErrors());
});
}
}
}
Aggregations