use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.
the class ContextChainHolderImpl method deviceConnected.
@Override
public ConnectionStatus deviceConnected(final ConnectionContext connectionContext) throws Exception {
final DeviceInfo deviceInfo = connectionContext.getDeviceInfo();
final ContextChain contextChain = contextChainMap.get(deviceInfo);
final FeaturesReply featuresReply = connectionContext.getFeatures();
final Short auxiliaryId = featuresReply != null ? featuresReply.getAuxiliaryId() : null;
if (auxiliaryId != null && auxiliaryId != 0) {
if (contextChain == null) {
LOG.warn("An auxiliary connection for device {}, but no primary connection. Refusing connection.", deviceInfo);
return ConnectionStatus.REFUSING_AUXILIARY_CONNECTION;
} else {
if (contextChain.addAuxiliaryConnection(connectionContext)) {
LOG.info("An auxiliary connection was added to device: {}", deviceInfo);
return ConnectionStatus.MAY_CONTINUE;
} else {
LOG.warn("Not able to add auxiliary connection to the device {}", deviceInfo);
return ConnectionStatus.REFUSING_AUXILIARY_CONNECTION;
}
}
} else {
LOG.info("Device {} connected.", deviceInfo);
final boolean contextExists = contextChain != null;
final boolean isClosing = contextExists && contextChain.isClosing();
if (!isClosing && connectingDevices.putIfAbsent(deviceInfo, connectionContext) != null) {
LOG.warn("Device {} is already trying to connect, wait until succeeded or disconnected.", deviceInfo);
return ConnectionStatus.ALREADY_CONNECTED;
}
if (contextExists) {
if (isClosing) {
LOG.warn("Device {} is already in termination state, closing all incoming connections.", deviceInfo);
return ConnectionStatus.CLOSING;
}
LOG.warn("Device {} already connected. Closing previous connection", deviceInfo);
destroyContextChain(deviceInfo);
LOG.info("Old connection dropped, creating new context chain for device {}", deviceInfo);
createContextChain(connectionContext);
} else {
LOG.info("No context chain found for device: {}, creating new.", deviceInfo);
createContextChain(connectionContext);
}
return ConnectionStatus.MAY_CONTINUE;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply in project openflowplugin by opendaylight.
the class OF13DeviceInitializerTest method initializeMultiLayer.
@Test
public void initializeMultiLayer() throws Exception {
when(deviceContext.canUseSingleLayerSerialization()).thenReturn(false);
when(requestContext.getFuture()).thenReturn(RpcResultBuilder.success(Collections.singletonList(new MultipartReplyMessageBuilder().setType(MultipartType.OFPMPDESC).setMultipartReplyBody(new MultipartReplyDescCaseBuilder().setMultipartReplyDesc(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDescBuilder().build()).build()).build())).buildFuture());
final Future<Void> initialize = deviceInitializer.initialize(deviceContext, true, false, multipartWriterProvider, convertorExecutor);
initialize.get();
verify(messageSpy, times(5)).spyMessage(eq(MultipartType.class), any());
verify(requestContext, times(5)).getFuture();
verify(featuresReply).getCapabilities();
verify(deviceContext).writeToTransaction(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
}
Aggregations