Reuse bindingTopologyPath key 71/103871/2
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 1 Jan 2023 18:45:47 +0000 (19:45 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Sun, 1 Jan 2023 20:32:00 +0000 (21:32 +0100)
Since we are accessing the path, we really can just use the key created
therein.

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

index bfc124fab28a8d1d7e386e7288d7b708c046b044..55fffb3b1eee373002144f50d242ad39d6cb8e17 100644 (file)
@@ -33,9 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.co
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.device.rev221225.connection.oper.unavailable.capabilities.UnavailableCapabilityBuilder;
 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.NetconfNodeBuilder;
-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.network.topology.topology.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
 import org.opendaylight.yangtools.yang.common.Empty;
 import org.opendaylight.yangtools.yang.common.Uint16;
 import org.slf4j.Logger;
@@ -58,7 +56,9 @@ public final class NetconfDeviceTopologyAdapter implements TransactionChainListe
         final WriteTransaction writeTx = txChain.newWriteOnlyTransaction();
         LOG.trace("{}: Init device state transaction {} putting if absent operational data started.", id,
             writeTx.getIdentifier());
-        writeTx.put(LogicalDatastoreType.OPERATIONAL, id.getTopologyBindingPath(), getNodeIdBuilder(id)
+        final var nodePath = id.getTopologyBindingPath();
+        writeTx.put(LogicalDatastoreType.OPERATIONAL, nodePath, new NodeBuilder()
+            .withKey(nodePath.getKey())
             .addAugmentation(new NetconfNodeBuilder()
                 .setConnectionStatus(ConnectionStatus.Connecting)
                 .setHost(id.getHost())
@@ -178,10 +178,6 @@ public final class NetconfDeviceTopologyAdapter implements TransactionChainListe
         }, MoreExecutors.directExecutor());
     }
 
-    private static NodeBuilder getNodeIdBuilder(final RemoteDeviceId id) {
-        return new NodeBuilder().withKey(new NodeKey(new NodeId(id.getName())));
-    }
-
     @Override
     public void close() {
         final WriteTransaction writeTx = txChain.newWriteOnlyTransaction();