import java.util.Map;
import java.util.Optional;
import org.opendaylight.aaa.encrypt.AAAEncryptionService;
-import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.client.NetconfClientSessionListener;
import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
import org.slf4j.LoggerFactory;
public class RemoteDeviceConnectorImpl implements RemoteDeviceConnector {
-
private static final Logger LOG = LoggerFactory.getLogger(RemoteDeviceConnectorImpl.class);
// Initializes default constant instances for the case when the default schema repository
}
}
- final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> device;
+ final RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> device;
if (node.getSchemaless()) {
device = new SchemalessNetconfDevice(netconfTopologyDeviceSetup.getBaseSchemas(), remoteDeviceId,
salFacade);
}
private AuthenticationHandler getHandlerFromCredentials(final Credentials credentials) {
- if (credentials instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology
- .rev150114.netconf.node.credentials.credentials.LoginPassword) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology
- .rev150114.netconf.node.credentials.credentials.LoginPassword loginPassword
- = (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology
- .rev150114.netconf.node.credentials.credentials.LoginPassword) credentials;
+ if (credentials
+ instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node
+ .credentials.credentials.LoginPassword loginPassword) {
return new LoginPasswordHandler(loginPassword.getUsername(), loginPassword.getPassword());
}
if (credentials instanceof LoginPwUnencrypted) {
import org.opendaylight.controller.config.threadpool.ThreadPool;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.dom.api.DOMMountPointService;
-import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.netconf.client.NetconfClientDispatcher;
import org.opendaylight.netconf.client.NetconfClientSessionListener;
import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
this.encryptionService = encryptionService;
this.baseSchemas = requireNonNull(baseSchemas);
- this.keystoreAdapter = new NetconfKeystoreAdapter(dataBroker);
+ keystoreAdapter = new NetconfKeystoreAdapter(dataBroker);
}
@Override
RemoteDeviceHandler<NetconfSessionPreferences> salFacade = createSalFacade(remoteDeviceId);
if (keepaliveDelay > 0) {
LOG.info("Adding keepalive facade, for device {}", nodeId);
- salFacade = new KeepaliveSalFacade(remoteDeviceId, salFacade, this.keepaliveExecutor.getExecutor(),
+ salFacade = new KeepaliveSalFacade(remoteDeviceId, salFacade, keepaliveExecutor.getExecutor(),
keepaliveDelay, node.requireDefaultRequestTimeoutMillis().toJava());
}
- final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> device;
+ final RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> device;
final List<SchemaSourceRegistration<?>> yanglibRegistrations;
if (node.requireSchemaless()) {
device = new SchemalessNetconfDevice(baseSchemas, remoteDeviceId, salFacade);
device = new NetconfDeviceBuilder()
.setReconnectOnSchemasChange(reconnectOnChangedSchema)
.setSchemaResourcesDTO(resources)
- .setGlobalProcessingExecutor(this.processingExecutor)
+ .setGlobalProcessingExecutor(processingExecutor)
.setId(remoteDeviceId)
.setSalFacade(salFacade)
.setNode(node)
}
private AuthenticationHandler getHandlerFromCredentials(final Credentials credentials) {
- if (credentials instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology
- .rev150114.netconf.node.credentials.credentials.LoginPassword) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology
- .rev150114.netconf.node.credentials.credentials.LoginPassword loginPassword
- = (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology
- .rev150114.netconf.node.credentials.credentials.LoginPassword) credentials;
+ if (credentials
+ instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology
+ .rev150114.netconf.node.credentials.credentials.LoginPassword loginPassword) {
return new LoginPasswordHandler(loginPassword.getUsername(), loginPassword.getPassword());
}
if (credentials instanceof LoginPwUnencrypted) {
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public interface DeviceActionFactory {
-
/**
* Allows user to create DOMActionService for specific device.
*
* @return {@link DOMActionService} of specific device
*/
default DOMActionService createDeviceAction(final MessageTransformer<NetconfMessage> messageTransformer,
- final RemoteDeviceCommunicator<NetconfMessage> listener, final SchemaContext schemaContext) {
+ final RemoteDeviceCommunicator listener, final SchemaContext schemaContext) {
return null;
}
}
*/
package org.opendaylight.netconf.sal.connect.api;
+import org.opendaylight.netconf.api.NetconfMessage;
+
/**
* Remote device.
*/
-public interface RemoteDevice<PREF, M, LISTENER extends RemoteDeviceCommunicator<M>> {
+public interface RemoteDevice<PREF, LISTENER extends RemoteDeviceCommunicator> {
void onRemoteSessionUp(PREF remoteSessionCapabilities, LISTENER listener);
void onRemoteSessionFailed(Throwable throwable);
- void onNotification(M notification);
+ void onNotification(NetconfMessage notification);
}
package org.opendaylight.netconf.sal.connect.api;
import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.netconf.api.NetconfMessage;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcResult;
-public interface RemoteDeviceCommunicator<M> extends AutoCloseable {
+public interface RemoteDeviceCommunicator extends AutoCloseable {
- ListenableFuture<RpcResult<M>> sendRequest(M message, QName rpc);
+ ListenableFuture<RpcResult<NetconfMessage>> sendRequest(NetconfMessage message, QName rpc);
@Override
void close();
@Override
public DOMActionService createDeviceAction(final MessageTransformer<NetconfMessage> messageTransformer,
- final RemoteDeviceCommunicator<NetconfMessage> listener, final SchemaContext schemaContext) {
+ final RemoteDeviceCommunicator listener, final SchemaContext schemaContext) {
return (schemaPath, dataTreeIdentifier, input) -> {
requireNonNull(schemaPath);
requireNonNull(dataTreeIdentifier);
/**
* This is a mediator between NetconfDeviceCommunicator and NetconfDeviceSalFacade.
*/
-public class NetconfDevice
- implements RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> {
+public class NetconfDevice implements RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> {
private static final Logger LOG = LoggerFactory.getLogger(NetconfDevice.class);
private static final QName RFC8528_SCHEMA_MOUNTS_QNAME = QName.create(
}
private synchronized void handleSalInitializationSuccess(final MountPointContext result,
- final NetconfSessionPreferences remoteSessionCapabilities,
- final DOMRpcService deviceRpc,
- final RemoteDeviceCommunicator<NetconfMessage> listener) {
+ final NetconfSessionPreferences remoteSessionCapabilities, final DOMRpcService deviceRpc,
+ final RemoteDeviceCommunicator listener) {
//NetconfDevice.SchemaSetup can complete after NetconfDeviceCommunicator was closed. In that case do nothing,
//since salFacade.onDeviceDisconnected was already called.
if (connected) {
}
}
- private void handleSalInitializationFailure(final Throwable throwable,
- final RemoteDeviceCommunicator<NetconfMessage> listener) {
+ private void handleSalInitializationFailure(final Throwable throwable, final RemoteDeviceCommunicator listener) {
LOG.error("{}: Initialization in sal failed, disconnecting from device", id, throwable);
listener.close();
onRemoteSessionDown();
}
protected NetconfDeviceRpc getDeviceSpecificRpc(final MountPointContext result,
- final RemoteDeviceCommunicator<NetconfMessage> listener, final BaseSchema schema) {
+ final RemoteDeviceCommunicator listener, final BaseSchema schema) {
return new NetconfDeviceRpc(result.getEffectiveModelContext(), listener,
new NetconfMessageTransformer(result, true, schema));
}
import org.opendaylight.netconf.sal.connect.util.MessageCounter;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
-public class SchemalessNetconfDevice
- implements RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> {
+public class SchemalessNetconfDevice implements RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> {
private final BaseNetconfSchemas baseSchemas;
private final RemoteDeviceId id;
private final RemoteDeviceHandler<NetconfSessionPreferences> salFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NetconfDeviceCommunicator
- implements NetconfClientSessionListener, RemoteDeviceCommunicator<NetconfMessage> {
-
+public class NetconfDeviceCommunicator implements NetconfClientSessionListener, RemoteDeviceCommunicator {
private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceCommunicator.class);
- protected final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> remoteDevice;
+ protected final RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> remoteDevice;
private final Optional<UserPreferences> overrideNetconfCapabilities;
protected final RemoteDeviceId id;
private final Lock sessionLock = new ReentrantLock();
public NetconfDeviceCommunicator(
final RemoteDeviceId id,
- final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> remoteDevice,
+ final RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> remoteDevice,
final UserPreferences netconfSessionPreferences, final int rpcMessageLimit) {
this(id, remoteDevice, Optional.of(netconfSessionPreferences), rpcMessageLimit);
}
public NetconfDeviceCommunicator(
final RemoteDeviceId id,
- final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> remoteDevice,
+ final RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> remoteDevice,
final int rpcMessageLimit) {
this(id, remoteDevice, Optional.empty(), rpcMessageLimit);
}
private NetconfDeviceCommunicator(
final RemoteDeviceId id,
- final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> remoteDevice,
+ final RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> remoteDevice,
final Optional<UserPreferences> overrideNetconfCapabilities, final int rpcMessageLimit) {
concurentRpcMsgs = rpcMessageLimit;
this.id = id;
* Invokes RPC by sending netconf message via listener. Also transforms result from NetconfMessage to CompositeNode.
*/
public final class NetconfDeviceRpc implements DOMRpcService {
- private final RemoteDeviceCommunicator<NetconfMessage> communicator;
+ private final RemoteDeviceCommunicator communicator;
private final MessageTransformer<NetconfMessage> transformer;
private final SchemaContext schemaContext;
- public NetconfDeviceRpc(final SchemaContext schemaContext,
- final RemoteDeviceCommunicator<NetconfMessage> communicator,
+ public NetconfDeviceRpc(final SchemaContext schemaContext, final RemoteDeviceCommunicator communicator,
final MessageTransformer<NetconfMessage> transformer) {
this.communicator = communicator;
this.transformer = transformer;
*/
public final class SchemalessNetconfDeviceRpc implements DOMRpcService {
- private final RemoteDeviceCommunicator<NetconfMessage> listener;
+ private final RemoteDeviceCommunicator listener;
private final BaseRpcSchemalessTransformer baseRpcTransformer;
private final SchemalessMessageTransformer schemalessTransformer;
private final RemoteDeviceId deviceId;
- public SchemalessNetconfDeviceRpc(final RemoteDeviceId deviceId,
- final RemoteDeviceCommunicator<NetconfMessage> listener,
- final BaseRpcSchemalessTransformer baseRpcTransformer,
- final SchemalessMessageTransformer messageTransformer) {
+ public SchemalessNetconfDeviceRpc(final RemoteDeviceId deviceId, final RemoteDeviceCommunicator listener,
+ final BaseRpcSchemalessTransformer baseRpcTransformer,
+ final SchemalessMessageTransformer messageTransformer) {
this.deviceId = deviceId;
this.listener = listener;
this.baseRpcTransformer = baseRpcTransformer;
- this.schemalessTransformer = messageTransformer;
+ schemalessTransformer = messageTransformer;
}
@Override
NetconfClientSession mockSession;
@Mock
- RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> mockDevice;
+ RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> mockDevice;
NetconfDeviceCommunicator communicator;
*/
@Test
public void testNetconfDeviceReconnectInCommunicator() {
- final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> device =
- mock(RemoteDevice.class);
+ final RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> device = mock(RemoteDevice.class);
final TimedReconnectStrategy timedReconnectStrategy =
new TimedReconnectStrategy(GlobalEventExecutor.INSTANCE, 10000, 0, 1.0, null, 100L, null);
@Mock
private DOMRpcAvailabilityListener listener;
@Mock
- private RemoteDeviceCommunicator<NetconfMessage> communicator;
+ private RemoteDeviceCommunicator communicator;
private NetconfDeviceRpc rpc;
private QName type;
public void testDeadlock() throws Exception {
// when rpc is successful, but transformer fails for some reason
final MessageTransformer<NetconfMessage> failingTransformer = mock(MessageTransformer.class);
- final RemoteDeviceCommunicator<NetconfMessage> communicatorMock = mock(RemoteDeviceCommunicator.class);
+ final RemoteDeviceCommunicator communicatorMock = mock(RemoteDeviceCommunicator.class);
final NetconfMessage msg = null;
final RpcResult<NetconfMessage> result = RpcResultBuilder.success(msg).build();
when(communicatorMock.sendRequest(any(), any())).thenReturn(Futures.immediateFuture(result));
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class SchemalessNetconfDeviceRpcTest extends AbstractBaseSchemasTest {
-
private static final Logger LOG = LoggerFactory.getLogger(SchemalessNetconfDeviceRpcTest.class);
@Mock
- private RemoteDeviceCommunicator<NetconfMessage> listener;
+ private RemoteDeviceCommunicator listener;
private SchemalessNetconfDeviceRpc deviceRpc;
}
@Mock
- private RemoteDeviceCommunicator<NetconfMessage> listener;
+ private RemoteDeviceCommunicator listener;
private NetconfRpcFutureCallback callback;
private NetconfBaseOps baseOps;
return null;
}
- static class LoggingRemoteDevice
- implements RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> {
+ static class LoggingRemoteDevice implements RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> {
@Override
public void onRemoteSessionUp(final NetconfSessionPreferences remoteSessionCapabilities,
final NetconfDeviceCommunicator netconfDeviceCommunicator) {
LOG.info("Notification received: {}", notification.toString());
}
}
-
}
private static NetconfDeviceCommunicator getSessionListener(
final InetSocketAddress inetAddress, final int messageLimit) {
- final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> loggingRemoteDevice =
+ final RemoteDevice<NetconfSessionPreferences, NetconfDeviceCommunicator> loggingRemoteDevice =
new StressClient.LoggingRemoteDevice();
return new NetconfDeviceCommunicator(
new RemoteDeviceId("secure-test", inetAddress), loggingRemoteDevice, messageLimit);