Move DEFAULT_TOPOLOGY_NAME 77/103877/2
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 1 Jan 2023 21:54:48 +0000 (22:54 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 1 Jan 2023 22:09:13 +0000 (23:09 +0100)
RemoteDeviceId has no connection to topology, move DEFAULT_TOPOLOGY_NAME
and related constants to a better place.

JIRA: NETCONF-913
Change-Id: Ic54f8484c052a74579f9c35751f3e31478de557c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/MasterSalFacade.java
netconf/netconf-topology-singleton/src/main/java/org/opendaylight/netconf/topology/singleton/impl/SlaveSalFacade.java
netconf/netconf-topology-singleton/src/test/java/org/opendaylight/netconf/topology/singleton/impl/NetconfNodeManagerTest.java
netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/AbstractNetconfTopology.java
netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfNodeUtils.java
netconf/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfTopologyDeviceSalFacade.java
netconf/netconf-topology/src/test/java/org/opendaylight/netconf/topology/spi/NetconfDeficeTopologyAdapterIntegrationTest.java
netconf/netconf-topology/src/test/java/org/opendaylight/netconf/topology/spi/NetconfDeviceTopologyAdapterTest.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/api/RemoteDeviceId.java
netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/sal/NetconfDeviceMount.java

index f40cc264ca8206c749bd3a0d28c1831127be88ab..517a0d22e0e95f129cd95a89c34a264b1906fabc 100644 (file)
@@ -31,8 +31,8 @@ import org.opendaylight.netconf.sal.connect.netconf.sal.AbstractNetconfDataTreeS
 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceDataBroker;
 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceMount;
 import org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData;
-import org.opendaylight.netconf.topology.spi.AbstractNetconfTopology;
 import org.opendaylight.netconf.topology.spi.NetconfDeviceTopologyAdapter;
+import org.opendaylight.netconf.topology.spi.NetconfNodeUtils;
 import org.opendaylight.yangtools.rfc8528.data.api.MountPointContext;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
@@ -65,14 +65,13 @@ class MasterSalFacade implements RemoteDeviceHandler, AutoCloseable {
                     final DataBroker dataBroker,
                     final boolean lockDatastore) {
         this.id = id;
-        mount = new NetconfDeviceMount(id, mountService, NetconfDeviceMount.defaultTopologyMountPath(id));
+        mount = new NetconfDeviceMount(id, mountService, NetconfNodeUtils.defaultTopologyMountPath(id));
         this.actorSystem = actorSystem;
         this.masterActorRef = masterActorRef;
         this.actorResponseWaitTime = actorResponseWaitTime;
         this.lockDatastore = lockDatastore;
 
-        datastoreAdapter = new NetconfDeviceTopologyAdapter(dataBroker, AbstractNetconfTopology.DEFAULT_TOPOLOGY_IID,
-            id);
+        datastoreAdapter = new NetconfDeviceTopologyAdapter(dataBroker, NetconfNodeUtils.DEFAULT_TOPOLOGY_IID, id);
     }
 
     @Override
index 9f4ae7ac8424a225952f09cd12ad047ca34b8b7f..ad2f52be2efab3476d18b1a2bada22c1f8975db5 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.mdsal.dom.api.DOMMountPointService;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceId;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices;
 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceMount;
+import org.opendaylight.netconf.topology.spi.NetconfNodeUtils;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -35,7 +36,7 @@ public class SlaveSalFacade {
         this.id = id;
         this.actorSystem = actorSystem;
         this.actorResponseWaitTime = actorResponseWaitTime;
-        mount = new NetconfDeviceMount(id, mountPointService, NetconfDeviceMount.defaultTopologyMountPath(id));
+        mount = new NetconfDeviceMount(id, mountPointService, NetconfNodeUtils.defaultTopologyMountPath(id));
     }
 
     public void registerSlaveMountPoint(final EffectiveModelContext remoteSchemaContext, final ActorRef masterActorRef,
index 95411714eca03ba068124449e5810dd7f68d1ab0..35fd0b21c63173cabade337855441cb10777430c 100644 (file)
@@ -64,7 +64,6 @@ import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices.Actions;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices.Rpcs;
 import org.opendaylight.netconf.sal.connect.netconf.NetconfDevice;
-import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceMount;
 import org.opendaylight.netconf.topology.singleton.impl.actors.NetconfNodeActor;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
 import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils;
@@ -72,6 +71,7 @@ import org.opendaylight.netconf.topology.singleton.messages.AskForMasterMountPoi
 import org.opendaylight.netconf.topology.singleton.messages.CreateInitialMasterActorData;
 import org.opendaylight.netconf.topology.singleton.messages.MasterActorDataInitialized;
 import org.opendaylight.netconf.topology.singleton.messages.YangTextSchemaSourceRequest;
+import org.opendaylight.netconf.topology.spi.NetconfNodeUtils;
 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;
@@ -234,7 +234,7 @@ public class NetconfNodeManagerTest extends AbstractBaseSchemasTest {
         verify(mockMountPointBuilder).addService(eq(DOMDataBroker.class), any());
         verify(mockMountPointBuilder).addService(eq(DOMRpcService.class), any());
         verify(mockMountPointBuilder).addService(eq(DOMNotificationService.class), any());
-        verify(mockMountPointService).createMountPoint(NetconfDeviceMount.defaultTopologyMountPath(DEVICE_ID));
+        verify(mockMountPointService).createMountPoint(NetconfNodeUtils.defaultTopologyMountPath(DEVICE_ID));
 
         // Notify that the NetconfNode operational state was deleted. Expect the slave mount point closed.
 
index eef613eb9ad7e2229672848cd694e12c6293344f..ed4d598b3c0c7802f07292f36925c28250bdcb5e 100644 (file)
@@ -71,7 +71,6 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
@@ -84,12 +83,6 @@ import org.slf4j.LoggerFactory;
 public abstract class AbstractNetconfTopology implements NetconfTopology {
     private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfTopology.class);
 
-    // FIXME: extract this into caller and pass to constructor
-    @Deprecated(forRemoval = true)
-    public static final KeyedInstanceIdentifier<Topology, TopologyKey> DEFAULT_TOPOLOGY_IID =
-        InstanceIdentifier.create(NetworkTopology.class)
-        .child(Topology.class, new TopologyKey(new TopologyId(RemoteDeviceId.DEFAULT_TOPOLOGY_NAME)));
-
     private final NetconfClientDispatcher clientDispatcher;
     private final EventExecutor eventExecutor;
     private final DeviceActionFactory deviceActionFactory;
index 7cba2e6d2f87e371e7a649ce19119646add13601..3218a40ab03550e7eda18f5b722a5ee87fffe90d 100644 (file)
@@ -17,12 +17,41 @@ import org.opendaylight.netconf.sal.connect.netconf.listener.UserPreferences;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.connection.oper.available.capabilities.AvailableCapability.CapabilityOrigin;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.NetconfNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.network.topology.topology.topology.types.TopologyNetconf;
+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.NodeId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 
 /**
  * Utility methods to work with {@link NetconfNode} information.
  */
 public final class NetconfNodeUtils {
+    // FIXME: extract all of this to users, as they are in control of topology-id
+    @Deprecated(forRemoval = true)
+    public static final String DEFAULT_TOPOLOGY_NAME = TopologyNetconf.QNAME.getLocalName();
+
+    // FIXME: extract this into caller and pass to constructor
+    @Deprecated(forRemoval = true)
+    public static final KeyedInstanceIdentifier<Topology, TopologyKey> DEFAULT_TOPOLOGY_IID =
+        InstanceIdentifier.create(NetworkTopology.class)
+        .child(Topology.class, new TopologyKey(new TopologyId(DEFAULT_TOPOLOGY_NAME)));
+
+    private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "node-id").intern();
+    // FIXME: push this out to callers
+    private static final YangInstanceIdentifier DEFAULT_TOPOLOGY_NODE = YangInstanceIdentifier.builder()
+        .node(NetworkTopology.QNAME).node(Topology.QNAME)
+        .nodeWithKey(Topology.QNAME, QName.create(Topology.QNAME, "topology-id"), DEFAULT_TOPOLOGY_NAME)
+        .node(Node.QNAME)
+        .build();
+
     private NetconfNodeUtils() {
         // Hidden on purpose
     }
@@ -91,4 +120,9 @@ public final class NetconfNodeUtils {
         return new UserPreferences(NetconfSessionPreferences.fromStrings(capabilities, CapabilityOrigin.UserDefined),
             overrideYangModuleCaps, overrideNonModuleCaps);
     }
+
+    @Deprecated(forRemoval = true)
+    public static @NonNull YangInstanceIdentifier defaultTopologyMountPath(final RemoteDeviceId id) {
+        return DEFAULT_TOPOLOGY_NODE.node(NodeIdentifierWithPredicates.of(Node.QNAME, NODE_ID_QNAME, id.name()));
+    }
 }
index 5ab27d161093bf1d49ce96130358ced34413a5e9..5c7f11870382cc1bca5233bedfaee5330ce47619 100644 (file)
@@ -14,7 +14,6 @@ import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices;
 import org.opendaylight.netconf.sal.connect.netconf.NetconfDeviceSchema;
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCapabilities;
 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
-import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceMount;
 import org.opendaylight.netconf.sal.connect.netconf.sal.NetconfDeviceSalFacade;
 
 /**
@@ -25,9 +24,8 @@ public class NetconfTopologyDeviceSalFacade extends NetconfDeviceSalFacade {
 
     public NetconfTopologyDeviceSalFacade(final RemoteDeviceId id, final DOMMountPointService mountPointService,
             final boolean lockDatastore, final DataBroker dataBroker) {
-        super(id, mountPointService, NetconfDeviceMount.defaultTopologyMountPath(id), lockDatastore);
-        datastoreAdapter = new NetconfDeviceTopologyAdapter(dataBroker, AbstractNetconfTopology.DEFAULT_TOPOLOGY_IID,
-            id);
+        super(id, mountPointService, NetconfNodeUtils.defaultTopologyMountPath(id), lockDatastore);
+        datastoreAdapter = new NetconfDeviceTopologyAdapter(dataBroker, NetconfNodeUtils.DEFAULT_TOPOLOGY_IID, id);
     }
 
     @Override
index 033cfe267a31d27e6c43fcede4b152ff54e6045c..d3677ceaddd1134dd1da6cff652a330115ac54e9 100644 (file)
@@ -47,7 +47,7 @@ public class NetconfDeficeTopologyAdapterIntegrationTest {
     private static final RemoteDeviceId ID = new RemoteDeviceId("test", new InetSocketAddress("localhost", 22));
     private static final KeyedInstanceIdentifier<Topology, TopologyKey> TEST_TOPOLOGY_ID =
         // FIXME: do not use this constant
-        AbstractNetconfTopology.DEFAULT_TOPOLOGY_IID;
+        NetconfNodeUtils.DEFAULT_TOPOLOGY_IID;
 
     private static BindingRuntimeContext RUNTIME_CONTEXT;
 
index 5afa1406f0b601008efdc0fd5cdaf2ece6f49029..c86bb3c8e62b26a935eb2766b2b5a746133d9f33 100644 (file)
@@ -40,7 +40,8 @@ import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 @RunWith(MockitoJUnitRunner.StrictStubs.class)
 public class NetconfDeviceTopologyAdapterTest {
     private static final KeyedInstanceIdentifier<Topology, TopologyKey> TEST_TOPOLOGY_ID =
-        AbstractNetconfTopology.DEFAULT_TOPOLOGY_IID;
+        // FIXME: do not use this constant
+        NetconfNodeUtils.DEFAULT_TOPOLOGY_IID;
     private final RemoteDeviceId id = new RemoteDeviceId("test", new InetSocketAddress("localhost", 22));
 
     @Mock
index 5af5dea17738b54dedfaf52ca4187bc189f9b817..155bf76864411418b423f4823ae5919ce0ab4ca7 100644 (file)
@@ -14,13 +14,8 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.DomainName;
 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.IetfInetUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev221225.network.topology.topology.topology.types.TopologyNetconf;
 
 public record RemoteDeviceId(@NonNull String name, @NonNull InetSocketAddress address) {
-    // FIXME: extract all of this to users, as they are in control of topology-id
-    @Deprecated(since = "5.0.0", forRemoval = true)
-    public static final String DEFAULT_TOPOLOGY_NAME = TopologyNetconf.QNAME.getLocalName();
-
     public RemoteDeviceId {
         requireNonNull(name);
         requireNonNull(address);
index 0023c409d7f659d7d80d96e1ba824dba0f4ae2a9..af72963feca0cb6e8f1c47f505190015a5e8ca66 100644 (file)
@@ -11,7 +11,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 import static java.util.Objects.requireNonNull;
 
-import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.dom.api.DOMActionService;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
@@ -28,13 +27,8 @@ import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices.Actions;
 import org.opendaylight.netconf.sal.connect.api.RemoteDeviceServices.Rpcs;
 import org.opendaylight.netconf.sal.connect.api.SchemalessRpcService;
-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.network.topology.Topology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.opendaylight.yangtools.concepts.ObjectRegistration;
-import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -42,13 +36,6 @@ import org.slf4j.LoggerFactory;
 // Non-final for mocking
 public class NetconfDeviceMount implements AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceMount.class);
-    private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "node-id").intern();
-    // FIXME: push this out to callers
-    private static final YangInstanceIdentifier DEFAULT_TOPOLOGY_NODE = YangInstanceIdentifier.builder()
-        .node(NetworkTopology.QNAME).node(Topology.QNAME)
-        .nodeWithKey(Topology.QNAME, QName.create(Topology.QNAME, "topology-id"), RemoteDeviceId.DEFAULT_TOPOLOGY_NAME)
-        .node(Node.QNAME)
-        .build();
 
     private final DOMMountPointService mountService;
     private final YangInstanceIdentifier mountPath;
@@ -64,11 +51,6 @@ public class NetconfDeviceMount implements AutoCloseable {
         this.mountPath = requireNonNull(mountPath);
     }
 
-    @Deprecated(forRemoval = true)
-    public static @NonNull YangInstanceIdentifier defaultTopologyMountPath(final RemoteDeviceId id) {
-        return DEFAULT_TOPOLOGY_NODE.node(NodeIdentifierWithPredicates.of(Node.QNAME, NODE_ID_QNAME, id.name()));
-    }
-
     public void onDeviceConnected(final EffectiveModelContext initialCtx,
             final RemoteDeviceServices services, final DOMDataBroker broker,
             final NetconfDataTreeService dataTreeService) {