Search in sources :

Example 1 with NetconfNodeAugmentedOptional

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.optional.rev190614.NetconfNodeAugmentedOptional in project netconf by opendaylight.

the class AbstractNetconfTopology method setupConnection.

protected ListenableFuture<NetconfDeviceCapabilities> setupConnection(final NodeId nodeId, final Node configNode) {
    final NetconfNode netconfNode = configNode.augmentation(NetconfNode.class);
    final NetconfNodeAugmentedOptional nodeOptional = configNode.augmentation(NetconfNodeAugmentedOptional.class);
    requireNonNull(netconfNode.getHost());
    requireNonNull(netconfNode.getPort());
    final NetconfConnectorDTO deviceCommunicatorDTO = createDeviceCommunicator(nodeId, netconfNode, nodeOptional);
    final NetconfDeviceCommunicator deviceCommunicator = deviceCommunicatorDTO.getCommunicator();
    final NetconfClientSessionListener netconfClientSessionListener = deviceCommunicatorDTO.getSessionListener();
    final NetconfReconnectingClientConfiguration clientConfig = getClientConfig(netconfClientSessionListener, netconfNode);
    final ListenableFuture<NetconfDeviceCapabilities> future = deviceCommunicator.initializeRemoteConnection(clientDispatcher, clientConfig);
    activeConnectors.put(nodeId, deviceCommunicatorDTO);
    Futures.addCallback(future, new FutureCallback<NetconfDeviceCapabilities>() {

        @Override
        public void onSuccess(final NetconfDeviceCapabilities result) {
            LOG.debug("Connector for {} started succesfully", nodeId.getValue());
        }

        @Override
        public void onFailure(final Throwable throwable) {
            LOG.error("Connector for {} failed", nodeId.getValue(), throwable);
        // remove this node from active connectors?
        }
    }, MoreExecutors.directExecutor());
    return future;
}
Also used : NetconfClientSessionListener(org.opendaylight.netconf.client.NetconfClientSessionListener) NetconfNodeAugmentedOptional(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.optional.rev190614.NetconfNodeAugmentedOptional) NetconfDeviceCommunicator(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator) NetconfDeviceCapabilities(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities) NetconfNode(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode) NetconfReconnectingClientConfiguration(org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration)

Example 2 with NetconfNodeAugmentedOptional

use of org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.optional.rev190614.NetconfNodeAugmentedOptional 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)

Aggregations

NetconfDeviceCommunicator (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator)2 InetSocketAddress (java.net.InetSocketAddress)1 NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)1 NetconfClientSessionListener (org.opendaylight.netconf.client.NetconfClientSessionListener)1 NetconfReconnectingClientConfiguration (org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration)1 SchemaResourcesDTO (org.opendaylight.netconf.sal.connect.netconf.NetconfDevice.SchemaResourcesDTO)1 NetconfDeviceBuilder (org.opendaylight.netconf.sal.connect.netconf.NetconfDeviceBuilder)1 SchemalessNetconfDevice (org.opendaylight.netconf.sal.connect.netconf.SchemalessNetconfDevice)1 NetconfDeviceCapabilities (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities)1 NetconfSessionPreferences (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences)1 UserPreferences (org.opendaylight.netconf.sal.connect.netconf.listener.UserPreferences)1 KeepaliveSalFacade (org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade)1 RemoteDeviceId (org.opendaylight.netconf.sal.connect.util.RemoteDeviceId)1 Host (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 NetconfNodeAugmentedOptional (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.optional.rev190614.NetconfNodeAugmentedOptional)1 NetconfNode (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode)1 SchemaSourceRegistration (org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration)1