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;
}
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);
}
Aggregations