Require parent topology to have been created 13/107713/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 5 Sep 2023 13:27:16 +0000 (15:27 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 6 Sep 2023 08:21:10 +0000 (10:21 +0200)
There is no point in re-issuing empty merges for topology, just require
it to have been created beforehand (which we already require in the
constructor).

JIRA: NETCONF-1148
Change-Id: Icd804e6d7f95651d2adbfb080171a9f264e21e79
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
apps/netconf-topology/src/main/java/org/opendaylight/netconf/topology/spi/NetconfDeviceTopologyAdapter.java
apps/netconf-topology/src/test/java/org/opendaylight/netconf/topology/spi/NetconfDeviceTopologyAdapterTest.java

index 3da668f8f1d5dbb7dc3005248b10a27f4a641569..26fac465621259b49ecfe2fa03213554a1a7651e 100644 (file)
@@ -86,9 +86,7 @@ public final class NetconfDeviceTopologyAdapter implements TransactionChainListe
             final SessionIdType sessionId) {
         final var tx = txChain.newWriteOnlyTransaction();
         LOG.trace("{}: Update device state transaction {} merging operational data started.", id, tx.getIdentifier());
-
-        // FIXME: this needs to be tied together with node's operational existence
-        tx.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, netconfNodePath(),
+        tx.put(LogicalDatastoreType.OPERATIONAL, netconfNodePath(),
             newNetconfNodeBuilder(up, capabilities, sessionId).build());
         LOG.trace("{}: Update device state transaction {} merging operational data ended.", id, tx.getIdentifier());
         commitTransaction(tx, "update");
@@ -98,14 +96,12 @@ public final class NetconfDeviceTopologyAdapter implements TransactionChainListe
             final NetconfDeviceCapabilities capabilities, final SessionIdType sessionId) {
         final var tx = txChain.newWriteOnlyTransaction();
         LOG.trace("{}: Update device state transaction {} merging operational data started.", id, tx.getIdentifier());
-        tx.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, netconfNodePath(),
-            newNetconfNodeBuilder(up, capabilities, sessionId)
-                .setClusteredConnectionStatus(new ClusteredConnectionStatusBuilder()
-                    .setNetconfMasterNode(masterAddress)
-                    .build())
-                .build());
+        tx.put(LogicalDatastoreType.OPERATIONAL, netconfNodePath(), newNetconfNodeBuilder(up, capabilities, sessionId)
+            .setClusteredConnectionStatus(new ClusteredConnectionStatusBuilder()
+                .setNetconfMasterNode(masterAddress)
+                .build())
+            .build());
         LOG.trace("{}: Update device state transaction {} merging operational data ended.", id, tx.getIdentifier());
-
         commitTransaction(tx, "update");
     }
 
@@ -119,7 +115,7 @@ public final class NetconfDeviceTopologyAdapter implements TransactionChainListe
 
         final var tx = txChain.newWriteOnlyTransaction();
         LOG.trace("{}: Setting device state as failed {} putting operational data started.", id, tx.getIdentifier());
-        tx.mergeParentStructurePut(LogicalDatastoreType.OPERATIONAL, netconfNodePath(), data);
+        tx.put(LogicalDatastoreType.OPERATIONAL, netconfNodePath(), data);
         LOG.trace("{}: Setting device state as failed {} putting operational data ended.", id, tx.getIdentifier());
         commitTransaction(tx, "update-failed-device");
     }
index 488ef954df4354dfa98f31d5afb7797706ad7fc8..38dcac2ceb3179a1c0cda78feef0eed4439c50f0 100644 (file)
@@ -89,8 +89,8 @@ public class NetconfDeviceTopologyAdapterTest {
     @Test
     public void testFailedDevice() {
         // FIXME: exact match
-        doNothing().when(mockTx).mergeParentStructurePut(eq(LogicalDatastoreType.OPERATIONAL),
-            any(InstanceIdentifier.class), any(NetconfNode.class));
+        doNothing().when(mockTx).put(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class),
+            any(NetconfNode.class));
 
         adapter.setDeviceAsFailed(null);
 
@@ -102,8 +102,9 @@ public class NetconfDeviceTopologyAdapterTest {
 
     @Test
     public void testDeviceUpdate() throws Exception {
-        doNothing().when(mockTx).mergeParentStructurePut(eq(LogicalDatastoreType.OPERATIONAL),
-            any(InstanceIdentifier.class), any(NetconfNode.class));
+        // FIXME: exact match
+        doNothing().when(mockTx).put(eq(LogicalDatastoreType.OPERATIONAL), any(InstanceIdentifier.class),
+            any(NetconfNode.class));
         adapter.updateDeviceData(true, NetconfDeviceCapabilities.empty(), new SessionIdType(Uint32.ONE));
 
         verify(mockChain, times(2)).newWriteOnlyTransaction();
@@ -134,7 +135,6 @@ public class NetconfDeviceTopologyAdapterTest {
         assertSame(Empty.value(), Futures.getDone(future));
     }
 
-
     @Test
     public void testShutdownCompletion() throws Exception {
         // FIXME: exact match