Search in sources :

Example 1 with RemoteDeviceId

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

the class NetconfTopologyUtilTest method testCreateRemoteDeviceId.

@Test
public void testCreateRemoteDeviceId() {
    final Host host = new Host(new IpAddress(new Ipv4Address("127.0.0.1")));
    final NetconfNode netconfNode = new NetconfNodeBuilder().setHost(host).setPort(new PortNumber(Uint16.valueOf(9999))).build();
    final NodeId nodeId = new NodeId("testing-node");
    final RemoteDeviceId id = NetconfTopologyUtils.createRemoteDeviceId(nodeId, netconfNode);
    assertEquals("testing-node", id.getName());
    assertEquals(host, id.getHost());
    assertEquals(9999, id.getAddress().getPort());
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder) 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) Host(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) PortNumber(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber) Ipv4Address(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address) Test(org.junit.Test)

Example 2 with RemoteDeviceId

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

the class FieldsAwareReadOnlyTxTest method testReadWithFields.

@Test
public void testReadWithFields() {
    doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(mockedNode))).when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class));
    final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(MountPointContext.class));
    try (FieldsAwareReadOnlyTx readOnlyTx = new FieldsAwareReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)))) {
        readOnlyTx.read(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty(), List.of(YangInstanceIdentifier.empty()));
        verify(rpc).invokeRpc(eq(NETCONF_GET_CONFIG_QNAME), any(ContainerNode.class));
        readOnlyTx.read(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
        verify(rpc).invokeRpc(eq(NETCONF_GET_QNAME), any(ContainerNode.class));
    }
}
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) QName(org.opendaylight.yangtools.yang.common.QName) 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 3 with RemoteDeviceId

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

the class NetconfBaseOpsTest method setUp.

@Before
public void setUp() throws Exception {
    final InputStream okStream = getClass().getResourceAsStream("/netconfMessages/rpc-reply_ok.xml");
    final InputStream dataStream = getClass().getResourceAsStream("/netconfMessages/rpc-reply_get.xml");
    final NetconfMessage ok = new NetconfMessage(XmlUtil.readXmlToDocument(okStream));
    final NetconfMessage data = new NetconfMessage(XmlUtil.readXmlToDocument(dataStream));
    when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME))).thenReturn(RpcResultBuilder.success(data).buildFuture());
    when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_GET_QNAME))).thenReturn(RpcResultBuilder.success(data).buildFuture());
    when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
    when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_COPY_CONFIG_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
    when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_DISCARD_CHANGES_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
    when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_VALIDATE_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
    when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
    when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
    when(listener.sendRequest(any(), eq(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME))).thenReturn(RpcResultBuilder.success(ok).buildFuture());
    final MessageTransformer<NetconfMessage> transformer = new NetconfMessageTransformer(new EmptyMountPointContext(SCHEMA_CONTEXT), true, BASE_SCHEMAS.getBaseSchema());
    final DOMRpcService rpc = new NetconfDeviceRpc(SCHEMA_CONTEXT, listener, transformer);
    final RemoteDeviceId id = new RemoteDeviceId("device-1", InetSocketAddress.createUnresolved("localhost", 17830));
    callback = new NetconfRpcFutureCallback("prefix", id);
    baseOps = new NetconfBaseOps(rpc, new EmptyMountPointContext(SCHEMA_CONTEXT));
}
Also used : NetconfDeviceRpc(org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceRpc) RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) InputStream(java.io.InputStream) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) NetconfMessageTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer) Before(org.junit.Before)

Example 4 with RemoteDeviceId

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

the class RemoteDeviceIdTest method testEquals.

@Test
public void testEquals() {
    final InetSocketAddress address = new InetSocketAddress("127.0.0.1", 8000);
    final RemoteDeviceId remoteDeviceId = new RemoteDeviceId("test", address);
    final RemoteDeviceId remoteDeviceIdEqualName = new RemoteDeviceId("test", address);
    final RemoteDeviceId remoteDeviceIdDiffName = new RemoteDeviceId("test-diff", address);
    assertEquals(true, remoteDeviceId.equals(remoteDeviceId));
    assertEquals(false, remoteDeviceId.equals(this));
    assertEquals(false, remoteDeviceId.equals(remoteDeviceIdDiffName));
    assertEquals(true, remoteDeviceId.equals(remoteDeviceIdEqualName));
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) InetSocketAddress(java.net.InetSocketAddress) Test(org.junit.Test)

Example 5 with RemoteDeviceId

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

the class NetconfDeviceDataBrokerTest method getDataBroker.

private NetconfDeviceDataBroker getDataBroker(final String... caps) {
    NetconfSessionPreferences prefs = NetconfSessionPreferences.fromStrings(Arrays.asList(caps));
    final RemoteDeviceId id = new RemoteDeviceId("device-1", InetSocketAddress.createUnresolved("localhost", 17830));
    return new NetconfDeviceDataBroker(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)

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