Added cache for YANG models downloaded from Netconf devices 31/4331/1
authorTony Tkacik <ttkacik@cisco.com>
Thu, 16 Jan 2014 18:44:35 +0000 (19:44 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Thu, 16 Jan 2014 18:45:03 +0000 (19:45 +0100)
Change-Id: I43653e3d42169ca578ec6daaab991a3eb03a5e85
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/config/yang/md/sal/connector/netconf/NetconfConnectorModule.java
opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTwoPhaseCommitTransaction.java

index f5d592c..2403027 100644 (file)
@@ -118,7 +118,8 @@ public final class NetconfConnectorModule extends org.opendaylight.controller.co
     private synchronized AbstractCachingSchemaSourceProvider<String, InputStream> getGlobalNetconfSchemaProvider(BundleContext bundleContext) {
         if(GLOBAL_NETCONF_SOURCE_PROVIDER == null) {
             String storageFile = "cache/schema";
-            File directory = bundleContext.getDataFile(storageFile);
+//            File directory = bundleContext.getDataFile(storageFile);
+            File directory = new File("cache/schema");
             SchemaSourceProvider<String> defaultProvider = SchemaSourceProviders.noopProvider();
             GLOBAL_NETCONF_SOURCE_PROVIDER = FilesystemSchemaCachingProvider.createFromStringSourceProvider(defaultProvider, directory);
         }
index 216a27a..6df34cd 100644 (file)
@@ -1,6 +1,8 @@
 package org.opendaylight.controller.sal.connect.netconf;
 
+import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
 
@@ -90,19 +92,26 @@ public class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransac
         for (PathArgument arg : reversed) {
             CompositeNodeBuilder<ImmutableCompositeNode> builder = ImmutableCompositeNode.builder();
             builder.setQName(arg.getNodeType());
-
+            Map<QName, Object> predicates = Collections.emptyMap();
             if (arg instanceof NodeIdentifierWithPredicates) {
-                for (Entry<QName, Object> entry : ((NodeIdentifierWithPredicates) arg).getKeyValues().entrySet()) {
-                    builder.addLeaf(entry.getKey(), entry.getValue());
-                }
+                predicates = ((NodeIdentifierWithPredicates) arg).getKeyValues();
+            }
+            for (Entry<QName, Object> entry : predicates.entrySet()) {
+                builder.addLeaf(entry.getKey(), entry.getValue());
             }
+            
             if (isLast) {
                 if (action.isPresent()) {
                     builder.setAttribute(NETCONF_ACTION_QNAME, action.get());
                 }
                 if (lastChildOverride.isPresent()) {
                     List<Node<?>> children = lastChildOverride.get().getChildren();
-                    builder.addAll(children);
+                    for(Node<?> child : children) {
+                        if(!predicates.containsKey(child.getKey())) {
+                            builder.add(child);
+                        }
+                    }
+                    
                 }
             } else {
                 builder.add(previous);