Search in sources :

Example 16 with NetconfDeviceCommunicator

use of org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator in project netconf by opendaylight.

the class RemoteDeviceConnectorImpl method startRemoteDeviceConnection.

@Override
public void startRemoteDeviceConnection(final RemoteDeviceHandler<NetconfSessionPreferences> deviceHandler) {
    final NetconfNode netconfNode = netconfTopologyDeviceSetup.getNode().augmentation(NetconfNode.class);
    final NodeId nodeId = netconfTopologyDeviceSetup.getNode().getNodeId();
    requireNonNull(netconfNode.getHost());
    requireNonNull(netconfNode.getPort());
    this.deviceCommunicatorDTO = createDeviceCommunicator(nodeId, netconfNode, deviceHandler);
    final NetconfDeviceCommunicator deviceCommunicator = deviceCommunicatorDTO.getCommunicator();
    final NetconfClientSessionListener netconfClientSessionListener = deviceCommunicatorDTO.getSessionListener();
    final NetconfReconnectingClientConfiguration clientConfig = getClientConfig(netconfClientSessionListener, netconfNode);
    final ListenableFuture<NetconfDeviceCapabilities> future = deviceCommunicator.initializeRemoteConnection(netconfTopologyDeviceSetup.getNetconfClientDispatcher(), clientConfig);
    Futures.addCallback(future, new FutureCallback<NetconfDeviceCapabilities>() {

        @Override
        public void onSuccess(final NetconfDeviceCapabilities result) {
            LOG.debug("{}: Connector started successfully", remoteDeviceId);
        }

        @Override
        public void onFailure(final Throwable throwable) {
            LOG.error("{}: Connector failed", remoteDeviceId, throwable);
        }
    }, MoreExecutors.directExecutor());
}
Also used : NetconfClientSessionListener(org.opendaylight.netconf.client.NetconfClientSessionListener) NetconfDeviceCommunicator(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator) NetconfDeviceCapabilities(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities) NodeId(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId) NetconfNode(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode) NetconfReconnectingClientConfiguration(org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration)

Aggregations

NetconfDeviceCommunicator (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator)16 NetconfSessionPreferences (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences)14 Test (org.junit.Test)12 EffectiveModelContextFactory (org.opendaylight.yangtools.yang.model.repo.api.EffectiveModelContextFactory)10 Collection (java.util.Collection)8 ArgumentMatchers.anyCollection (org.mockito.ArgumentMatchers.anyCollection)8 DOMRpcService (org.opendaylight.mdsal.dom.api.DOMRpcService)8 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)8 NetconfDeviceCapabilities (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities)8 MountPointContext (org.opendaylight.yangtools.rfc8528.data.api.MountPointContext)8 RemoteDeviceId (org.opendaylight.netconf.sal.connect.util.RemoteDeviceId)7 InetSocketAddress (java.net.InetSocketAddress)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 HashMultimap (com.google.common.collect.HashMultimap)5 Iterables (com.google.common.collect.Iterables)5 Lists (com.google.common.collect.Lists)5 Sets (com.google.common.collect.Sets)5 Futures (com.google.common.util.concurrent.Futures)5