Search in sources :

Example 21 with RemoteDeviceId

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

the class NetconfNodeActorTest method testInitializeAndRefreshMasterData.

@Test
public void testInitializeAndRefreshMasterData() {
    // Test CreateInitialMasterActorData.
    initializeMaster(new ArrayList<>());
    // Test RefreshSetupMasterActorData.
    final RemoteDeviceId newRemoteDeviceId = new RemoteDeviceId("netconf-topology2", new InetSocketAddress(InetAddresses.forString("127.0.0.2"), 9999));
    final NetconfTopologySetup newSetup = NetconfTopologySetupBuilder.create().setBaseSchemas(BASE_SCHEMAS).setSchemaResourceDTO(schemaResourceDTO).setActorSystem(system).build();
    masterRef.tell(new RefreshSetupMasterActorData(newSetup, newRemoteDeviceId), testKit.getRef());
    testKit.expectMsgClass(MasterActorDataInitialized.class);
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) InetSocketAddress(java.net.InetSocketAddress) RefreshSetupMasterActorData(org.opendaylight.netconf.topology.singleton.messages.RefreshSetupMasterActorData) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) Test(org.junit.Test)

Example 22 with RemoteDeviceId

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

the class NetconfNodeActorTest method setup.

@Before
public void setup() {
    remoteDeviceId = new RemoteDeviceId("netconf-topology", new InetSocketAddress(InetAddresses.forString("127.0.0.1"), 9999));
    masterSchemaRepository.registerSchemaSourceListener(TextToIRTransformer.create(masterSchemaRepository, masterSchemaRepository));
    doReturn(masterSchemaRepository).when(schemaResourceDTO).getSchemaRepository();
    doReturn(mockRegistry).when(schemaResourceDTO).getSchemaRegistry();
    final NetconfTopologySetup setup = NetconfTopologySetupBuilder.create().setActorSystem(system).setIdleTimeout(Duration.apply(1, TimeUnit.SECONDS)).setSchemaResourceDTO(schemaResourceDTO).setBaseSchemas(BASE_SCHEMAS).build();
    final Props props = NetconfNodeActor.props(setup, remoteDeviceId, TIMEOUT, mockMountPointService);
    masterRef = TestActorRef.create(system, props, "master_messages");
    resetMountPointMocks();
    doReturn(mockMountPointBuilder).when(mockMountPointService).createMountPoint(any());
    doReturn(mockSchemaSourceReg1).when(mockRegistry).registerSchemaSource(any(), withSourceId(SOURCE_IDENTIFIER1));
    doReturn(mockSchemaSourceReg2).when(mockRegistry).registerSchemaSource(any(), withSourceId(SOURCE_IDENTIFIER2));
    doReturn(mockSchemaContextFactory).when(mockSchemaRepository).createEffectiveModelContextFactory();
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) InetSocketAddress(java.net.InetSocketAddress) Props(akka.actor.Props) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) Before(org.junit.Before)

Example 23 with RemoteDeviceId

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

the class AbstractNetconfTopology method createDeviceCommunicator.

protected NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId, final NetconfNode node, final NetconfNodeAugmentedOptional nodeOptional) {
    final Host host = node.getHost();
    final IpAddress ipAddress = host.getIpAddress();
    final InetSocketAddress address;
    if (ipAddress != null) {
        address = new InetSocketAddress(IetfInetUtil.INSTANCE.inetAddressFor(ipAddress), node.getPort().getValue().toJava());
    } else {
        address = new InetSocketAddress(host.getDomainName().getValue(), node.getPort().getValue().toJava());
    }
    final RemoteDeviceId remoteDeviceId = new RemoteDeviceId(nodeId.getValue(), address);
    final long keepaliveDelay = node.requireKeepaliveDelay().toJava();
    RemoteDeviceHandler<NetconfSessionPreferences> salFacade = createSalFacade(remoteDeviceId);
    if (keepaliveDelay > 0) {
        LOG.info("Adding keepalive facade, for device {}", nodeId);
        salFacade = new KeepaliveSalFacade(remoteDeviceId, salFacade, this.keepaliveExecutor.getExecutor(), keepaliveDelay, node.requireDefaultRequestTimeoutMillis().toJava());
    }
    final RemoteDevice<NetconfSessionPreferences, NetconfMessage, NetconfDeviceCommunicator> device;
    final List<SchemaSourceRegistration<?>> yanglibRegistrations;
    if (node.requireSchemaless()) {
        device = new SchemalessNetconfDevice(baseSchemas, remoteDeviceId, salFacade);
        yanglibRegistrations = List.of();
    } else {
        final boolean reconnectOnChangedSchema = node.requireReconnectOnChangedSchema();
        final SchemaResourcesDTO resources = schemaManager.getSchemaResources(node, nodeId.getValue());
        device = new NetconfDeviceBuilder().setReconnectOnSchemasChange(reconnectOnChangedSchema).setSchemaResourcesDTO(resources).setGlobalProcessingExecutor(this.processingExecutor).setId(remoteDeviceId).setSalFacade(salFacade).setNode(node).setEventExecutor(eventExecutor).setNodeOptional(nodeOptional).setDeviceActionFactory(deviceActionFactory).setBaseSchemas(baseSchemas).build();
        yanglibRegistrations = registerDeviceSchemaSources(remoteDeviceId, node, resources);
    }
    final Optional<UserPreferences> userCapabilities = getUserCapabilities(node);
    final int rpcMessageLimit = node.requireConcurrentRpcLimit().toJava();
    if (rpcMessageLimit < 1) {
        LOG.info("Concurrent rpc limit is smaller than 1, no limit will be enforced for device {}", remoteDeviceId);
    }
    final NetconfDeviceCommunicator netconfDeviceCommunicator = userCapabilities.isPresent() ? new NetconfDeviceCommunicator(remoteDeviceId, device, userCapabilities.get(), rpcMessageLimit) : new NetconfDeviceCommunicator(remoteDeviceId, device, rpcMessageLimit);
    if (salFacade instanceof KeepaliveSalFacade) {
        ((KeepaliveSalFacade) salFacade).setListener(netconfDeviceCommunicator);
    }
    return new NetconfConnectorDTO(netconfDeviceCommunicator, salFacade, yanglibRegistrations);
}
Also used : UserPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.UserPreferences) NetconfDeviceCommunicator(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator) InetSocketAddress(java.net.InetSocketAddress) KeepaliveSalFacade(org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade) Host(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host) NetconfSessionPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences) SchemaResourcesDTO(org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO) RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfDeviceBuilder(org.opendaylight.netconf.sal.connect.netconf.NetconfDeviceBuilder) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) SchemaSourceRegistration(org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) SchemalessNetconfDevice(org.opendaylight.netconf.sal.connect.netconf.SchemalessNetconfDevice)

Example 24 with RemoteDeviceId

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

the class RemoteDeviceConnectorImplTest method setUp.

@Before
public void setUp() {
    remoteDeviceId = new RemoteDeviceId(TOPOLOGY_ID, new InetSocketAddress(InetAddresses.forString("127.0.0.1"), 9999));
    builder = new NetconfTopologySetup.NetconfTopologySetupBuilder().setBaseSchemas(BASE_SCHEMAS).setDataBroker(dataBroker).setRpcProviderRegistry(rpcProviderRegistry).setClusterSingletonServiceProvider(clusterSingletonServiceProvider).setKeepaliveExecutor(keepaliveExecutor).setProcessingExecutor(processingExecutor).setActorSystem(actorSystem).setEventExecutor(eventExecutor).setNetconfClientDispatcher(clientDispatcher).setTopologyId(TOPOLOGY_ID);
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) InetSocketAddress(java.net.InetSocketAddress) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup) Before(org.junit.Before)

Example 25 with RemoteDeviceId

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

the class NetconfTopologyUtils method createRemoteDeviceId.

public static RemoteDeviceId createRemoteDeviceId(final NodeId nodeId, final NetconfNode node) {
    final IpAddress ipAddress = node.getHost().getIpAddress();
    final InetSocketAddress address = new InetSocketAddress(ipAddress.getIpv4Address() != null ? ipAddress.getIpv4Address().getValue() : ipAddress.getIpv6Address().getValue(), node.getPort().getValue().toJava());
    return new RemoteDeviceId(nodeId.getValue(), address);
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) InetSocketAddress(java.net.InetSocketAddress) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

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