import org.opendaylight.netconf.sal.connect.util.NetconfTopologyRPCProvider;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.spi.AbstractNetconfTopology;
+import org.opendaylight.netconf.topology.spi.NetconfConnectorDTO;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeTopologyService;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopologyBuilder;
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <properties>
- <!-- FIXME: Remove this -->
- <odlparent.modernizer.enforce>false</odlparent.modernizer.enforce>
- </properties>
-
<dependencies>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>sal-netconf-connector</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-topology</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-clustering-commons</artifactId>
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Lists;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.sal.connect.util.SslHandlerFactoryImpl;
import org.opendaylight.netconf.topology.singleton.api.RemoteDeviceConnector;
-import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfConnectorDTO;
import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils;
+import org.opendaylight.netconf.topology.spi.NetconfConnectorDTO;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Uri;
final NetconfDevice.SchemaResourcesDTO schemaResourcesDTO = netconfTopologyDeviceSetup.getSchemaResourcesDTO();
// pre register yang library sources as fallback schemas to schema registry
- // FIXME: this list not used anywhere. Should it be retained or discarded? (why?)
- // it would seem those registrations should be bound to NetconfConnectorDTO
- final List<SchemaSourceRegistration<YangTextSchemaSource>> registeredYangLibSources = Lists.newArrayList();
+ final List<SchemaSourceRegistration<?>> registeredYangLibSources = new ArrayList<>();
if (node.getYangLibrary() != null) {
final String yangLibURL = node.getYangLibrary().getYangLibraryUrl().getValue();
final String yangLibUsername = node.getYangLibrary().getUsername();
if (salFacade instanceof KeepaliveSalFacade) {
((KeepaliveSalFacade)salFacade).setListener(netconfDeviceCommunicator);
}
- return new NetconfConnectorDTO(netconfDeviceCommunicator, salFacade);
+ return new NetconfConnectorDTO(netconfDeviceCommunicator, salFacade, registeredYangLibSources);
}
private static Optional<NetconfSessionPreferences> getUserCapabilities(final NetconfNode node) {
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.netconf.topology.singleton.impl.utils;
import java.math.BigDecimal;
import org.opendaylight.yangtools.yang.binding.Identifier;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public final class NetconfTopologyUtils {
- private static final Logger LOG = LoggerFactory.getLogger(NetconfTopologyUtils.class);
-
public static final long DEFAULT_REQUEST_TIMEOUT_MILLIS = 60000L;
public static final int DEFAULT_KEEPALIVE_DELAY = 0;
public static final boolean DEFAULT_RECONNECT_ON_CHANGED_SCHEMA = false;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
-import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfConnectorDTO;
import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
+import org.opendaylight.netconf.topology.spi.NetconfConnectorDTO;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Host;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.netconf.topology.singleton.impl;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
+import java.util.List;
import org.opendaylight.netconf.sal.connect.api.DeviceActionFactory;
import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
-import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfConnectorDTO;
import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
+import org.opendaylight.netconf.topology.spi.NetconfConnectorDTO;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yangtools.util.concurrent.FluentFutures;
@Override
public NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId, final NetconfNode node,
- RemoteDeviceHandler<NetconfSessionPreferences> salFacade) {
- final NetconfConnectorDTO connectorDTO = new NetconfConnectorDTO(communicator, salFacade);
+ final RemoteDeviceHandler<NetconfSessionPreferences> salFacade) {
+ final NetconfConnectorDTO connectorDTO = new NetconfConnectorDTO(communicator, salFacade, List.of());
doReturn(FluentFutures.immediateNullFluentFuture()).when(communicator).initializeRemoteConnection(any(), any());
return connectorDTO;
}
return Optional.of(new UserPreferences(NetconfSessionPreferences
.fromStrings(capabilities, CapabilityOrigin.UserDefined), overrideYangModuleCaps, overrideNonModuleCaps));
}
-
- protected static class NetconfConnectorDTO implements AutoCloseable {
- private final List<SchemaSourceRegistration<?>> yanglibRegistrations;
- private final NetconfDeviceCommunicator communicator;
- private final RemoteDeviceHandler<NetconfSessionPreferences> facade;
-
- public NetconfConnectorDTO(final NetconfDeviceCommunicator communicator,
- final RemoteDeviceHandler<NetconfSessionPreferences> facade,
- final List<SchemaSourceRegistration<?>> yanglibRegistrations) {
- this.communicator = communicator;
- this.facade = facade;
- this.yanglibRegistrations = yanglibRegistrations;
- }
-
- public NetconfDeviceCommunicator getCommunicator() {
- return communicator;
- }
-
- public RemoteDeviceHandler<NetconfSessionPreferences> getFacade() {
- return facade;
- }
-
- public NetconfClientSessionListener getSessionListener() {
- return communicator;
- }
-
- @Override
- public void close() {
- communicator.close();
- facade.close();
- yanglibRegistrations.forEach(SchemaSourceRegistration::close);
- }
- }
}
/*
- * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
+package org.opendaylight.netconf.topology.spi;
-package org.opendaylight.netconf.topology.singleton.impl.utils;
-
+import java.util.List;
import org.opendaylight.netconf.client.NetconfClientSessionListener;
import org.opendaylight.netconf.sal.connect.api.RemoteDeviceHandler;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator;
import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
+import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistration;
-public class NetconfConnectorDTO implements AutoCloseable {
-
+public final class NetconfConnectorDTO implements AutoCloseable {
+ private final List<SchemaSourceRegistration<?>> yanglibRegistrations;
private final NetconfDeviceCommunicator communicator;
private final RemoteDeviceHandler<NetconfSessionPreferences> facade;
public NetconfConnectorDTO(final NetconfDeviceCommunicator communicator,
- final RemoteDeviceHandler<NetconfSessionPreferences> facade) {
+ final RemoteDeviceHandler<NetconfSessionPreferences> facade,
+ final List<SchemaSourceRegistration<?>> yanglibRegistrations) {
this.communicator = communicator;
this.facade = facade;
+ this.yanglibRegistrations = yanglibRegistrations;
}
public NetconfDeviceCommunicator getCommunicator() {
@Override
public void close() {
- if (communicator != null) {
- communicator.close();
- }
- if (facade != null) {
- facade.close();
- }
+ communicator.close();
+ facade.close();
+ yanglibRegistrations.forEach(SchemaSourceRegistration::close);
}
}
\ No newline at end of file