use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class ConnectionManagerImplTest method testOnSwitchConnected2.
/**
* Test method for
* {@link org.opendaylight.openflowplugin.impl.connection.ConnectionManagerImpl#onSwitchConnected(
* org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter)}.
* invoking onHelloMessage, scenario:
* <ol>
* <li>receive hello from device (notification)</li>
* <li>send hello to device (rpc with void output)</li>
* <li>send getFeature to device (rpc with getFeatureOutput)</li>
* <li>wait for rpc to finish with getFeatureOutput</li>
* </ol>
*
* @throws InterruptedException - interrupted exception
*/
@Test
public void testOnSwitchConnected2() throws Exception {
connectionManagerImpl.onSwitchConnected(connection);
Mockito.verify(connection).setConnectionReadyListener(connectionReadyListenerAC.capture());
Mockito.verify(connection).setMessageListener(ofpListenerAC.capture());
// prepare void reply (hello rpc output)
final SettableFuture<RpcResult<HelloOutput>> voidResponseFx = SettableFuture.create();
Mockito.when(connection.hello(any(HelloInput.class))).thenReturn(voidResponseFx);
// prepare getFeature reply (getFeture rpc output)
final SettableFuture<RpcResult<GetFeaturesOutput>> featureResponseFx = SettableFuture.create();
Mockito.when(connection.getFeatures(any(GetFeaturesInput.class))).thenReturn(featureResponseFx);
// set dpn last connected time to be before dpn hold time seconds from now
connectionManagerImpl.getDeviceConnectionStatusProvider().addDeviceLastConnectionTime(BigInteger.TEN, LocalDateTime.now().minusSeconds(DEVICE_CONNECTION_HOLD_TIME_IN_SECONDS.toJava()));
// fire handshake - send hello reply
final HelloMessage hello = new HelloMessageBuilder().setVersion(EncodeConstants.OF_VERSION_1_3).setXid(Uint32.ONE).build();
ofpListenerAC.getValue().onHelloMessage(hello);
// notify about connection ready
connectionReadyListenerAC.getValue().onConnectionReady();
// deliver hello send output (void)
Thread.sleep(100L);
final RpcResult<HelloOutput> helloResponse = RpcResultBuilder.success((HelloOutput) null).build();
voidResponseFx.set(helloResponse);
// deliver getFeature output
Thread.sleep(100L);
final GetFeaturesOutput getFeatureOutput = new GetFeaturesOutputBuilder().setDatapathId(Uint64.TEN).setVersion(EncodeConstants.OF_VERSION_1_3).setXid(Uint32.TWO).setTables(Uint8.valueOf(15)).build();
final RpcResult<GetFeaturesOutput> rpcFeaturesOutput = RpcResultBuilder.success(getFeatureOutput).build();
featureResponseFx.set(rpcFeaturesOutput);
Mockito.verify(deviceConnectedHandler, Mockito.timeout(FINAL_STEP_TIMEOUT)).deviceConnected(any(ConnectionContext.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class HandshakeListenerImplTest method testOnHandshakeFailure1.
@Test
public void testOnHandshakeFailure1() {
connectionContextSpy.setNodeId(new NodeId("ut-device:10"));
handshakeListener.onHandshakeFailure();
verify(handshakeContext).close();
verify(connectionContextSpy).closeConnection(false);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class BundleFlowForwarder method remove.
@Override
public void remove(final InstanceIdentifier<Flow> identifier, final Flow flow, final InstanceIdentifier<FlowCapableNode> nodeIdent, final BundleId bundleId) {
final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
nodeConfigurator.enqueueJob(nodeId, () -> {
final List<Message> messages = new ArrayList<>(1);
String node = nodeIdent.firstKeyOf(Node.class).getId().getValue();
BundleInnerMessage bundleInnerMessage = new BundleRemoveFlowCaseBuilder().setRemoveFlowCaseData(new RemoveFlowCaseDataBuilder(flow).build()).build();
Message message = new MessageBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleInnerMessage(bundleInnerMessage).build();
messages.add(message);
AddBundleMessagesInput addBundleMessagesInput = new AddBundleMessagesInputBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleId(bundleId).setFlags(BUNDLE_FLAGS).setMessages(new MessagesBuilder().setMessage(messages).build()).build();
final ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager.getSalBundleService().addBundleMessages(addBundleMessagesInput);
LOG.trace("Pushing flow remove message {} to bundle {} for device {}", addBundleMessagesInput, bundleId.getValue(), node);
LoggingFutures.addErrorLogging(resultFuture, LOG, "removeBundleFlow");
return resultFuture;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class BundleGroupForwarder method remove.
@Override
public void remove(final InstanceIdentifier<Group> identifier, final Group group, final InstanceIdentifier<FlowCapableNode> nodeIdent, final BundleId bundleId) {
final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
nodeConfigurator.enqueueJob(nodeId, () -> {
final List<Message> messages = new ArrayList<>(1);
BundleInnerMessage bundleInnerMessage = new BundleRemoveGroupCaseBuilder().setRemoveGroupCaseData(new RemoveGroupCaseDataBuilder(group).build()).build();
Message message = new MessageBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleInnerMessage(bundleInnerMessage).build();
messages.add(message);
AddBundleMessagesInput addBundleMessagesInput = new AddBundleMessagesInputBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleId(bundleId).setFlags(BUNDLE_FLAGS).setMessages(new MessagesBuilder().setMessage(messages).build()).build();
LOG.trace("Pushing group remove message {} to bundle {} for device {}", addBundleMessagesInput, bundleId.getValue(), nodeId);
final ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager.getSalBundleService().addBundleMessages(addBundleMessagesInput);
Futures.addCallback(resultFuture, new BundleRemoveGroupCallBack(group.getGroupId().getValue(), nodeId), MoreExecutors.directExecutor());
LoggingFutures.addErrorLogging(resultFuture, LOG, "removeBundleGroup");
return resultFuture;
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.Device in project openflowplugin by opendaylight.
the class BundleGroupForwarder method add.
@Override
public ListenableFuture<RpcResult<AddBundleMessagesOutput>> add(final InstanceIdentifier<Group> identifier, final Group group, final InstanceIdentifier<FlowCapableNode> nodeIdent, final BundleId bundleId) {
final String nodeId = getNodeIdValueFromNodeIdentifier(nodeIdent);
final Uint32 groupId = group.getGroupId().getValue();
return nodeConfigurator.enqueueJob(nodeId, () -> {
if (isGroupExistsOnDevice(nodeIdent, groupId, forwardingRulesManager)) {
LOG.debug("Group {} already exists in the device. Ignoring the add DTCN", groupId);
return Futures.immediateFuture(RpcResultBuilder.<AddBundleMessagesOutput>success().build());
}
final List<Message> messages = new ArrayList<>(1);
BundleInnerMessage bundleInnerMessage = new BundleAddGroupCaseBuilder().setAddGroupCaseData(new AddGroupCaseDataBuilder(group).build()).build();
Message message = new MessageBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleInnerMessage(bundleInnerMessage).build();
messages.add(message);
AddBundleMessagesInput addBundleMessagesInput = new AddBundleMessagesInputBuilder().setNode(new NodeRef(nodeIdent.firstIdentifierOf(Node.class))).setBundleId(bundleId).setFlags(BUNDLE_FLAGS).setMessages(new MessagesBuilder().setMessage(messages).build()).build();
LOG.trace("Pushing group add message {} to bundle {} for device {}", addBundleMessagesInput, bundleId.getValue(), nodeId);
ListenableFuture<RpcResult<AddBundleMessagesOutput>> resultFuture = forwardingRulesManager.getSalBundleService().addBundleMessages(addBundleMessagesInput);
Futures.addCallback(resultFuture, new BundleAddGroupCallBack(groupId, nodeId), MoreExecutors.directExecutor());
return resultFuture;
});
}
Aggregations