Search in sources :

Example 6 with RemoteDeviceId

use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.

the class YangLibrarySchemaYangSourceProviderTest method setUp.

@Before
public void setUp() throws Exception {
    final URL url = getClass().getResource("/schemas/config-test-rpc.yang");
    workingSid = RevisionSourceIdentifier.create("abc", Optional.empty());
    final Map<SourceIdentifier, URL> sourceIdentifierURLMap = Collections.singletonMap(workingSid, url);
    final RemoteDeviceId id = new RemoteDeviceId("id", new InetSocketAddress("localhost", 22));
    yangLibrarySchemaYangSourceProvider = new YangLibrarySchemaYangSourceProvider(id, sourceIdentifierURLMap);
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) InetSocketAddress(java.net.InetSocketAddress) SourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier) RevisionSourceIdentifier(org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier) URL(java.net.URL) Before(org.junit.Before)

Example 7 with RemoteDeviceId

use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.

the class SchemalessNetconfDeviceTest method testSessionOnMethods.

@Test
public void testSessionOnMethods() throws Exception {
    final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
    final NetconfDeviceCommunicator listener = mockCloseableClass(NetconfDeviceCommunicator.class);
    final SchemalessMessageTransformer messageTransformer = mock(SchemalessMessageTransformer.class);
    final RemoteDeviceId remoteDeviceId = new RemoteDeviceId("test-D", InetSocketAddress.createUnresolved("localhost", 22));
    final Throwable throwable = new Throwable();
    final SchemalessNetconfDevice device = new SchemalessNetconfDevice(BASE_SCHEMAS, remoteDeviceId, facade, messageTransformer);
    final NetconfSessionPreferences sessionCaps = getSessionCaps(true, Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&amp;revision=" + TEST_REVISION));
    final NetconfMessage netconfMessage = mock(NetconfMessage.class);
    device.onRemoteSessionUp(sessionCaps, listener);
    verify(facade).onDeviceConnected(any(MountPointContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class));
    device.onNotification(netconfMessage);
    verify(facade).onNotification(isNull());
    device.onRemoteSessionDown();
    verify(facade).onDeviceDisconnected();
    device.onRemoteSessionFailed(throwable);
    verify(facade).onDeviceFailed(throwable);
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfDeviceCommunicator(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator) DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) SchemalessMessageTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer) NetconfSessionPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences) MountPointContext(org.opendaylight.yangtools.rfc8528.data.api.MountPointContext) Test(org.junit.Test)

Example 8 with RemoteDeviceId

use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.

the class NetconfDeviceCommunicatorTest method testNetconfDeviceReconnectInCommunicator.

/**
 * Test whether reconnect is scheduled properly.
 */
@Test
public void testNetconfDeviceReconnectInCommunicator() {
    final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> device = mock(RemoteDevice.class);
    final TimedReconnectStrategy timedReconnectStrategy = new TimedReconnectStrategy(GlobalEventExecutor.INSTANCE, 10000, 0, 1.0, null, 100L, null);
    final ReconnectStrategy reconnectStrategy = spy(new ReconnectStrategy() {

        @Override
        @Deprecated
        public int getConnectTimeout() throws Exception {
            return timedReconnectStrategy.getConnectTimeout();
        }

        @Override
        @Deprecated
        public Future<Void> scheduleReconnect(final Throwable cause) {
            return timedReconnectStrategy.scheduleReconnect(cause);
        }

        @Override
        @Deprecated
        public void reconnectSuccessful() {
            timedReconnectStrategy.reconnectSuccessful();
        }
    });
    final EventLoopGroup group = new NioEventLoopGroup();
    final Timer time = new HashedWheelTimer();
    try {
        final NetconfDeviceCommunicator listener = new NetconfDeviceCommunicator(new RemoteDeviceId("test", InetSocketAddress.createUnresolved("localhost", 22)), device, 10);
        final NetconfReconnectingClientConfiguration cfg = NetconfReconnectingClientConfigurationBuilder.create().withAddress(new InetSocketAddress("localhost", 65000)).withReconnectStrategy(reconnectStrategy).withConnectStrategyFactory(() -> reconnectStrategy).withAuthHandler(new LoginPasswordHandler("admin", "admin")).withConnectionTimeoutMillis(10000).withProtocol(NetconfClientConfiguration.NetconfClientProtocol.SSH).withSessionListener(listener).build();
        listener.initializeRemoteConnection(new NetconfClientDispatcherImpl(group, group, time), cfg);
        verify(reconnectStrategy, timeout(TimeUnit.MINUTES.toMillis(4)).times(101)).scheduleReconnect(any(Throwable.class));
    } finally {
        time.stop();
        group.shutdownGracefully();
    }
}
Also used : TimedReconnectStrategy(org.opendaylight.netconf.nettyutil.TimedReconnectStrategy) ReconnectStrategy(org.opendaylight.netconf.nettyutil.ReconnectStrategy) InetSocketAddress(java.net.InetSocketAddress) HashedWheelTimer(io.netty.util.HashedWheelTimer) NetconfClientDispatcherImpl(org.opendaylight.netconf.client.NetconfClientDispatcherImpl) TimeoutException(java.util.concurrent.TimeoutException) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) EventLoopGroup(io.netty.channel.EventLoopGroup) LoginPasswordHandler(org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswordHandler) HashedWheelTimer(io.netty.util.HashedWheelTimer) Timer(io.netty.util.Timer) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) TimedReconnectStrategy(org.opendaylight.netconf.nettyutil.TimedReconnectStrategy) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) ChannelFuture(io.netty.channel.ChannelFuture) Future(io.netty.util.concurrent.Future) NetconfReconnectingClientConfiguration(org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) Test(org.junit.Test)

Example 9 with RemoteDeviceId

use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.

the class NetconfDataTreeServiceImplTest method getNetconService.

private AbstractNetconfDataTreeService getNetconService() {
    NetconfSessionPreferences prefs = NetconfSessionPreferences.fromStrings(Collections.singletonList(NetconfMessageTransformUtil.NETCONF_CANDIDATE_URI.toString()));
    final RemoteDeviceId id = new RemoteDeviceId("device-1", InetSocketAddress.createUnresolved("localhost", 17830));
    return AbstractNetconfDataTreeService.of(id, new EmptyMountPointContext(SCHEMA_CONTEXT), rpcService, prefs);
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) NetconfSessionPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences)

Example 10 with RemoteDeviceId

use of org.opendaylight.netconf.sal.connect.util.RemoteDeviceId in project netconf by opendaylight.

the class NetconfDeviceSalFacadeTest method setUp.

@Before
public void setUp() throws Exception {
    final InetSocketAddress address = new InetSocketAddress("127.0.0.1", 8000);
    final RemoteDeviceId remoteDeviceId = new RemoteDeviceId("test", address);
    deviceFacade = new NetconfDeviceSalFacade(remoteDeviceId, salProvider, dataBroker, "mockTopo");
    doReturn(netconfDeviceTopologyAdapter).when(salProvider).getTopologyDatastoreAdapter();
    doNothing().when(netconfDeviceTopologyAdapter).updateDeviceData(any(Boolean.class), any(NetconfDeviceCapabilities.class));
    doReturn(mountInstance).when(salProvider).getMountInstance();
    doNothing().when(mountInstance).onTopologyDeviceDisconnected();
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) InetSocketAddress(java.net.InetSocketAddress) NetconfDeviceCapabilities(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities) Before(org.junit.Before)

Aggregations

RemoteDeviceId (org.opendaylight.netconf.sal.connect.util.RemoteDeviceId)26 InetSocketAddress (java.net.InetSocketAddress)15 Test (org.junit.Test)11 Before (org.junit.Before)10 NetconfBaseOps (org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps)7 EmptyMountPointContext (org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext)6 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)5 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)5 MountPointContext (org.opendaylight.yangtools.rfc8528.data.api.MountPointContext)5 NetconfSessionPreferences (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences)4 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)4 NetconfTopologySetup (org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)3 URL (java.net.URL)2 DOMRpcService (org.opendaylight.mdsal.dom.api.DOMRpcService)2 NetconfDeviceCommunicator (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator)2 SchemalessMessageTransformer (org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer)2 Host (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host)2 NetconfNode (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode)2 QName (org.opendaylight.yangtools.yang.common.QName)2