Search in sources :

Example 11 with NetconfBaseOps

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

the class ReadOnlyTxTest method testRead.

@Test
public void testRead() throws Exception {
    final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(MountPointContext.class));
    final ReadOnlyTx readOnlyTx = new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)));
    readOnlyTx.read(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
    verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME), any(ContainerNode.class));
    readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
    verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_QNAME), any(ContainerNode.class));
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfBaseOps(org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps) InetSocketAddress(java.net.InetSocketAddress) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) MountPointContext(org.opendaylight.yangtools.rfc8528.data.api.MountPointContext) Test(org.junit.Test)

Example 12 with NetconfBaseOps

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

the class WriteCandidateRunningTxTest method setUp.

@Before
public void setUp() {
    doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(rpc).invokeRpc(any(), any());
    netconfOps = new NetconfBaseOps(rpc, new EmptyMountPointContext(SCHEMA_CONTEXT));
    id = new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830));
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) NetconfBaseOps(org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps) EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) Before(org.junit.Before)

Example 13 with NetconfBaseOps

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

the class WriteCandidateTxTest method setUp.

@Before
public void setUp() {
    doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(rpc).invokeRpc(any(), any());
    netconfOps = new NetconfBaseOps(rpc, new EmptyMountPointContext(SCHEMA_CONTEXT));
    id = new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830));
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) NetconfBaseOps(org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps) EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) Before(org.junit.Before)

Example 14 with NetconfBaseOps

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

the class WriteRunningTxTest method setUp.

@Before
public void setUp() {
    doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(rpc).invokeRpc(any(), any());
    netconfOps = new NetconfBaseOps(rpc, new EmptyMountPointContext(SCHEMA_CONTEXT));
    id = new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830));
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) NetconfBaseOps(org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps) EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) Before(org.junit.Before)

Example 15 with NetconfBaseOps

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

the class AbstractNetconfDataTreeService method of.

@NonNull
public static AbstractNetconfDataTreeService of(final RemoteDeviceId id, final MountPointContext mountContext, final DOMRpcService rpc, final NetconfSessionPreferences netconfSessionPreferences) {
    final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mountContext);
    final boolean rollbackSupport = netconfSessionPreferences.isRollbackSupported();
    // Examine preferences and decide which implementation to use
    if (netconfSessionPreferences.isCandidateSupported()) {
        return netconfSessionPreferences.isRunningWritable() ? new CandidateWithRunning(id, netconfOps, rollbackSupport) : new Candidate(id, netconfOps, rollbackSupport);
    } else if (netconfSessionPreferences.isRunningWritable()) {
        return new Running(id, netconfOps, rollbackSupport);
    } else {
        throw new IllegalArgumentException("Device " + id.getName() + " has advertised neither :writable-running " + "nor :candidate capability. Failed to establish session, as at least one of these must be " + "advertised.");
    }
}
Also used : NetconfBaseOps(org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps) Objects.requireNonNull(java.util.Objects.requireNonNull) NonNull(org.eclipse.jdt.annotation.NonNull)

Aggregations

NetconfBaseOps (org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps)15 Test (org.junit.Test)11 DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)9 QName (org.opendaylight.yangtools.yang.common.QName)8 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)8 AbstractBaseSchemasTest (org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest)7 RemoteDeviceId (org.opendaylight.netconf.sal.connect.util.RemoteDeviceId)7 InetSocketAddress (java.net.InetSocketAddress)4 MountPointContext (org.opendaylight.yangtools.rfc8528.data.api.MountPointContext)4 ExecutionException (java.util.concurrent.ExecutionException)3 Before (org.junit.Before)3 EmptyMountPointContext (org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext)3 InOrder (org.mockito.InOrder)2 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)2 Objects.requireNonNull (java.util.Objects.requireNonNull)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)1