Merge changes I0f752636,Idd154499,Ic35fa3e8
authorEd Warnicke <eaw@cisco.com>
Tue, 26 Nov 2013 14:35:34 +0000 (14:35 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 26 Nov 2013 14:35:34 +0000 (14:35 +0000)
* changes:
  Updated xml generated by get netconf operation to conform to yang schema in config-api
  Add logback as a default config module.
  Fix logging of yang parsing problems in yang-parser-impl

opendaylight/config/logback-config/src/main/java/org/opendaylight/controller/config/yang/logback/config/LogbackModuleFactory.java
opendaylight/config/logback-config/src/test/java/org/opendaylight/controller/config/yang/logback/config/LogbackModuleTest.java
opendaylight/config/logback-config/src/test/java/org/opendaylight/controller/config/yang/logback/config/LogbackModuleWithInitialConfigurationTest.java
opendaylight/config/logback-config/src/test/java/org/opendaylight/controller/config/yang/logback/config/LogbackWithXmlConfigModuleTest.java
opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTracker.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/runtime/InstanceRuntime.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/runtime/ModuleRuntime.java
opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/mapping/runtime/Runtime.java
opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java

index a157e1e..5e8612f 100644 (file)
@@ -8,6 +8,22 @@
  */
 package org.opendaylight.controller.config.yang.logback.config;
 
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.commons.lang3.StringUtils;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DependencyResolverFactory;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.osgi.framework.BundleContext;
+import org.slf4j.LoggerFactory;
+
 import ch.qos.logback.classic.Logger;
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
@@ -17,21 +33,10 @@ import ch.qos.logback.core.Appender;
 import ch.qos.logback.core.rolling.FixedWindowRollingPolicy;
 import ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy;
 import ch.qos.logback.core.rolling.TimeBasedRollingPolicy;
+
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
-import org.apache.commons.lang3.StringUtils;
-import org.opendaylight.controller.config.api.DependencyResolver;
-import org.opendaylight.controller.config.api.ModuleIdentifier;
-import org.osgi.framework.BundleContext;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
+import com.google.common.collect.Sets;
 
 /**
 *
@@ -39,15 +44,15 @@ import java.util.Map.Entry;
 public class LogbackModuleFactory extends
         org.opendaylight.controller.config.yang.logback.config.AbstractLogbackModuleFactory {
 
-    private static final String INSTANCE_NAME = "singleton";
+    public static final String INSTANCE_NAME = "singleton";
     private Map<String, LoggerTO> loggersDTOs;
     private Map<String, RollingFileAppenderTO> rollingDTOs;
     private Map<String, ConsoleAppenderTO> consoleDTOs;
     private Map<String, FileAppenderTO> fileDTOs;
 
     @Override
-    public LogbackModule instantiateModule(String instanceName,
-            DependencyResolver dependencyResolver, BundleContext bundleContext) {
+    public LogbackModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+            BundleContext bundleContext) {
         Preconditions.checkArgument(instanceName.equals(INSTANCE_NAME),
                 "There should be just one instance of logback, named " + INSTANCE_NAME);
         prepareDTOs();
@@ -61,9 +66,8 @@ public class LogbackModuleFactory extends
     }
 
     @Override
-    public LogbackModule instantiateModule(String instanceName,
-            DependencyResolver dependencyResolver, LogbackModule oldModule,
-            AutoCloseable oldInstance, BundleContext bundleContext) {
+    public LogbackModule instantiateModule(String instanceName, DependencyResolver dependencyResolver,
+            LogbackModule oldModule, AutoCloseable oldInstance, BundleContext bundleContext) {
         Preconditions.checkArgument(instanceName.equals(INSTANCE_NAME),
                 "There should be just one instance of logback, named " + INSTANCE_NAME);
         prepareDTOs();
@@ -220,4 +224,14 @@ public class LogbackModuleFactory extends
         return Lists.newArrayList(loggersToReturn.values());
     }
 
+    @Override
+    public Set<LogbackModule> getDefaultModules(DependencyResolverFactory dependencyResolverFactory,
+            BundleContext bundleContext) {
+        DependencyResolver resolver = dependencyResolverFactory.createDependencyResolver(new ModuleIdentifier(
+                getImplementationName(), INSTANCE_NAME));
+        LogbackModule defaultLogback = instantiateModule(INSTANCE_NAME, resolver, bundleContext);
+        Set<LogbackModule> defaultModules = Sets.newHashSet(defaultLogback);
+        return defaultModules;
+    }
+
 }
index 846b9cd..296ce79 100644 (file)
@@ -7,29 +7,24 @@
  */
 package org.opendaylight.controller.config.yang.logback.config;
 
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.junit.matchers.JUnitMatchers.containsString;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.ObjectName;
-
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.opendaylight.controller.config.api.ConflictingVersionException;
 import org.opendaylight.controller.config.api.ValidationException;
 import org.opendaylight.controller.config.api.jmx.CommitStatus;
 import org.opendaylight.controller.config.manager.impl.AbstractConfigTest;
 import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver;
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 
+import javax.management.ObjectName;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+import static org.junit.matchers.JUnitMatchers.containsString;
+
 public class LogbackModuleTest extends AbstractConfigTest {
 
     private static final String INSTANCE_NAME = "singleton";
@@ -37,14 +32,14 @@ public class LogbackModuleTest extends AbstractConfigTest {
     private LogbackModuleFactory factory;
 
     @Before
-    public void setUp() throws IOException, ClassNotFoundException, InterruptedException {
+    public void setUp() throws Exception {
 
         factory = new LogbackModuleFactory();
         super.initConfigTransactionManagerImpl(new HardcodedModuleFactoriesResolver(factory));
     }
 
     @Test
-    public void testCreateBean() throws InstanceAlreadyExistsException {
+    public void testCreateBean() throws Exception {
 
         CommitStatus status = createBeans(true, "target/rollingApp",
                 "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1, 5, "target/%i.log", "rolling",
@@ -55,7 +50,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testReusingInstance() throws InstanceAlreadyExistsException {
+    public void testReusingInstance() throws Exception {
         createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1, 5,
                 "target/%i.log", "rolling", "consoleName", "ALL", "logger1", "DEBUG", "FixedWindowRollingPolicy", 0,
                 "FileAppender").commit();
@@ -70,8 +65,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testRecreateInstance() throws InstanceAlreadyExistsException, ValidationException,
-            ConflictingVersionException, InstanceNotFoundException {
+    public void testRecreateInstance() throws Exception {
         createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1, 5,
                 "target/%i.log", "rolling", "consoleName", "ALL", "logger1", "DEBUG", "FixedWindowRollingPolicy", 0,
                 "FileAppender").commit();
@@ -88,7 +82,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testDestroyInstance() throws InstanceNotFoundException, InstanceAlreadyExistsException {
+    public void testDestroyInstance() throws Exception {
         createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1, 5,
                 "target/%i.log", "rolling", "consoleName", "ALL", "logger1", "DEBUG", "FixedWindowRollingPolicy", 0,
                 "FileAppender").commit();
@@ -104,7 +98,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
 
     @Ignore
     @Test
-    public void testValidation1() throws InstanceAlreadyExistsException {
+    public void testValidation1() throws Exception {
         try {
             createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1, 5,
                     "target/%i.log", "rolling", "consoleName", "ALL", "logger1", "DEBUG", "FixedWindowRollingPolicy",
@@ -116,7 +110,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testValidation2() throws InstanceAlreadyExistsException {
+    public void testValidation2() throws Exception {
         try {
             createBeans(true, "target/rollingApp", null, "30MB", 1, 5, "target/%i.log", "rolling", "consoleName",
                     "ALL", "logger1", "DEBUG", "FixedWindowRollingPolicy", 0, "FileAppender").commit();
@@ -127,7 +121,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testValidation4() throws InstanceAlreadyExistsException {
+    public void testValidation4() throws Exception {
         try {
             createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", null, 1, 5,
                     "target/%i.log", "rolling", "consoleName", "ALL", "logger1", "DEBUG", "FixedWindowRollingPolicy",
@@ -139,7 +133,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testValidation6() throws InstanceAlreadyExistsException {
+    public void testValidation6() throws Exception {
         try {
             createBeans(true, "", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1, 5, "target/%i.log",
                     "rolling", "consoleName", "ALL", "logger1", "DEBUG", "FixedWindowRollingPolicy", 0, "FileAppender")
@@ -151,7 +145,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testValidation7() throws InstanceAlreadyExistsException {
+    public void testValidation7() throws Exception {
         try {
             createBeans(
 
@@ -164,7 +158,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testValidation8() throws InstanceAlreadyExistsException {
+    public void testValidation8() throws Exception {
         try {
             createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1, 5,
                     "target/%i.log", "rolling", "consoleName", "ALL", null, "DEBUG", "FixedWindowRollingPolicy", 0,
@@ -176,7 +170,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testValidation9() throws InstanceAlreadyExistsException {
+    public void testValidation9() throws Exception {
         try {
             createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1, 5,
                     "target/%i.log", "rolling", "consoleName", "ALL", "", "DEBUG", "FixedWindowRollingPolicy", 0,
@@ -188,7 +182,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testValidation10() throws InstanceAlreadyExistsException {
+    public void testValidation10() throws Exception {
         try {
             createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", null,
                     5, "target/%i.log", "rolling", "consoleName", "ALL", "logger1", "DEBUG",
@@ -200,7 +194,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testValidation11() throws InstanceAlreadyExistsException {
+    public void testValidation11() throws Exception {
         try {
             createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1,
                     null, "target/%i.log", "rolling", "consoleName", "ALL", "logger1", "DEBUG",
@@ -212,7 +206,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testValidation12() throws InstanceAlreadyExistsException {
+    public void testValidation12() throws Exception {
         try {
             createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1,
                     null, "target/%i.log", "rolling", "consoleName", "ALL", "logger1", "DEBUG", null, 1, "FileAppender")
@@ -224,7 +218,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testValidation13() throws InstanceAlreadyExistsException {
+    public void testValidation13() throws Exception {
         try {
             createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1,
                     null, "target/%i.log", "rolling", "consoleName", "ALL", "logger1", "DEBUG", "", 1, "FileAppender")
@@ -236,7 +230,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testValidation14() throws InstanceAlreadyExistsException {
+    public void testValidation14() throws Exception {
         try {
             createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", 1,
                     null, "target/%i.log", "rolling", "consoleName", "ALL", "logger1", "DEBUG", "RollingPolicy", 1,
@@ -248,7 +242,7 @@ public class LogbackModuleTest extends AbstractConfigTest {
     }
 
     @Test
-    public void testTimeBasedRollingPolicy() throws InstanceAlreadyExistsException {
+    public void testTimeBasedRollingPolicy() throws Exception {
         createBeans(true, "target/rollingApp", "%-4relative [%thread] %-5level %logger{35} - %msg%n", "30MB", null,
                 null, "target/%d.log", "rolling", "consoleName", "ALL", "logger1", "DEBUG", "TimeBasedRollingPolicy",
                 1, "FileAppender").commit();
@@ -257,10 +251,10 @@ public class LogbackModuleTest extends AbstractConfigTest {
     private ConfigTransactionJMXClient createBeans(Boolean isAppend, String rollingFileName, String encoderPattern,
             String maxFileSize, Integer minIndex, Integer maxIndex, String fileNamePattern, String rollingName,
             String consoleName, String thresholdFilter, String loggerName, String level, String rollingPolicyType,
-            int maxHistory, String fileAppName) throws InstanceAlreadyExistsException {
+            int maxHistory, String fileAppName) throws Exception {
         ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), INSTANCE_NAME);
-        LogbackModuleMXBean bean = transaction.newMXBeanProxy(nameCreated, LogbackModuleMXBean.class);
+        ObjectName nameRetrieved = transaction.lookupConfigBean(factory.getImplementationName(), INSTANCE_NAME);
+        LogbackModuleMXBean bean = transaction.newMXBeanProxy(nameRetrieved, LogbackModuleMXBean.class);
 
         List<RollingFileAppenderTO> rollingAppenders = new ArrayList<>();
         RollingFileAppenderTO rollingAppender = new RollingFileAppenderTO();
index 79e46ae..eeb8289 100644 (file)
@@ -17,7 +17,9 @@ import java.util.Arrays;
 import java.util.List;
 
 import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
 import javax.management.JMX;
+import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
 import org.apache.commons.io.FileUtils;
@@ -142,7 +144,8 @@ public class LogbackModuleWithInitialConfigurationTest extends AbstractConfigTes
 
     }
 
-    public ObjectName createBeans() throws JoranException, InstanceAlreadyExistsException, IOException {
+    public ObjectName createBeans() throws JoranException, InstanceAlreadyExistsException, IOException,
+            MalformedObjectNameException, InstanceNotFoundException {
 
         LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
 
@@ -200,8 +203,8 @@ public class LogbackModuleWithInitialConfigurationTest extends AbstractConfigTes
         loggersDTOs.add(log);
 
         ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), "singleton");
-        LogbackModuleMXBean bean = transaction.newMXBeanProxy(nameCreated, LogbackModuleMXBean.class);
+        ObjectName nameRetrieved = transaction.lookupConfigBean(factory.getImplementationName(), LogbackModuleFactory.INSTANCE_NAME);
+        LogbackModuleMXBean bean = transaction.newMXBeanProxy(nameRetrieved, LogbackModuleMXBean.class);
 
         bean.setLoggerTO(loggersDTOs);
         bean.setRollingFileAppenderTO(rollingAppenders);
@@ -210,6 +213,6 @@ public class LogbackModuleWithInitialConfigurationTest extends AbstractConfigTes
 
         transaction.commit();
 
-        return nameCreated;
+        return nameRetrieved;
     }
 }
index 004c18c..8718f8a 100644 (file)
@@ -17,6 +17,7 @@ import java.util.List;
 import javax.management.InstanceAlreadyExistsException;
 import javax.management.InstanceNotFoundException;
 import javax.management.JMX;
+import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
 import org.apache.commons.io.FileUtils;
@@ -27,12 +28,12 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod
 import org.opendaylight.controller.config.util.ConfigTransactionJMXClient;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.Lists;
-
 import ch.qos.logback.classic.LoggerContext;
 import ch.qos.logback.classic.joran.JoranConfigurator;
 import ch.qos.logback.core.joran.spi.JoranException;
 
+import com.google.common.collect.Lists;
+
 public class LogbackWithXmlConfigModuleTest extends AbstractConfigTest {
 
     private LogbackModuleFactory factory;
@@ -56,14 +57,16 @@ public class LogbackWithXmlConfigModuleTest extends AbstractConfigTest {
 
     /**
      * Tests configuration of Logger factory.
+     *
+     * @throws MalformedObjectNameException
      */
     @Test
-    public void test() throws InstanceAlreadyExistsException, InstanceNotFoundException {
+    public void test() throws InstanceAlreadyExistsException, InstanceNotFoundException, MalformedObjectNameException {
 
         ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), "singleton");
+        ObjectName nameRetrieved = transaction.lookupConfigBean(factory.getImplementationName(), LogbackModuleFactory.INSTANCE_NAME);
 
-        LogbackModuleMXBean bean = transaction.newMXBeanProxy(nameCreated, LogbackModuleMXBean.class);
+        LogbackModuleMXBean bean = transaction.newMXBeanProxy(nameRetrieved, LogbackModuleMXBean.class);
 
         assertEquals(1, bean.getConsoleAppenderTO().size());
 
@@ -73,9 +76,9 @@ public class LogbackWithXmlConfigModuleTest extends AbstractConfigTest {
 
         transaction = configRegistryClient.createTransaction();
 
-        nameCreated = transaction.lookupConfigBean(factory.getImplementationName(), "singleton");
+        nameRetrieved = transaction.lookupConfigBean(factory.getImplementationName(), "singleton");
 
-        bean = JMX.newMXBeanProxy(platformMBeanServer, nameCreated, LogbackModuleMXBean.class);
+        bean = JMX.newMXBeanProxy(platformMBeanServer, nameRetrieved, LogbackModuleMXBean.class);
 
         assertEquals(1, bean.getConsoleAppenderTO().size());
         assertEquals(1, bean.getRollingFileAppenderTO().size());
@@ -89,11 +92,6 @@ public class LogbackWithXmlConfigModuleTest extends AbstractConfigTest {
     @Test
     public void testAllLoggers() throws InstanceAlreadyExistsException, InstanceNotFoundException {
         ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        transaction.createModule(factory.getImplementationName(), "singleton");
-
-        transaction.commit();
-
-        transaction = configRegistryClient.createTransaction();
 
         LogbackModuleMXBean bean = JMX.newMXBeanProxy(ManagementFactory.getPlatformMBeanServer(),
                 transaction.lookupConfigBean("logback", "singleton"), LogbackModuleMXBean.class);
@@ -103,13 +101,16 @@ public class LogbackWithXmlConfigModuleTest extends AbstractConfigTest {
 
     /**
      * Add new logger using FileAppender
+     *
+     * @throws MalformedObjectNameException
      */
     @Test
-    public void testAddNewLogger() throws InstanceAlreadyExistsException, InstanceNotFoundException {
+    public void testAddNewLogger() throws InstanceAlreadyExistsException, InstanceNotFoundException,
+            MalformedObjectNameException {
 
         ConfigTransactionJMXClient transaction = configRegistryClient.createTransaction();
-        ObjectName nameCreated = transaction.createModule(factory.getImplementationName(), "singleton");
-        LogbackModuleMXBean bean = transaction.newMXBeanProxy(nameCreated, LogbackModuleMXBean.class);
+        ObjectName nameRetrieved = transaction.lookupConfigBean(factory.getImplementationName(), LogbackModuleFactory.INSTANCE_NAME);
+        LogbackModuleMXBean bean = transaction.newMXBeanProxy(nameRetrieved, LogbackModuleMXBean.class);
 
         assertEquals(5, bean.getLoggerTO().size());
 
@@ -124,8 +125,8 @@ public class LogbackWithXmlConfigModuleTest extends AbstractConfigTest {
         transaction.commit();
 
         transaction = configRegistryClient.createTransaction();
-        nameCreated = transaction.lookupConfigBean(factory.getImplementationName(), "singleton");
-        bean = JMX.newMXBeanProxy(platformMBeanServer, nameCreated, LogbackModuleMXBean.class);
+        nameRetrieved = transaction.lookupConfigBean(factory.getImplementationName(), "singleton");
+        bean = JMX.newMXBeanProxy(platformMBeanServer, nameRetrieved, LogbackModuleMXBean.class);
 
         assertEquals(6, bean.getLoggerTO().size());
     }
index fcdc10f..9356dd3 100644 (file)
@@ -125,7 +125,7 @@ public class ExtenderYangTracker extends BundleTracker<Object> implements YangSt
         // inconsistent state
         inconsistentBundlesToYangURLs.putAll(bundle, addedURLs);
 
-        logger.debug("Yang store is falling back on last consistent state containing {}, inconsistent yang files {}, reason {}",
+        logger.debug("Yang store is falling back on last consistent state containing {}, inconsistent yang files {}",
                 consistentBundlesToYangURLs, inconsistentBundlesToYangURLs, failureReason);
         logger.warn("Yang store is falling back on last consistent state containing {} files, inconsistent yang files size is {}, reason {}",
                 consistentBundlesToYangURLs.size(), inconsistentBundlesToYangURLs.size(), failureReason.toString());
index 9d348d0..70b10d0 100644 (file)
@@ -12,7 +12,6 @@ import com.google.common.base.Predicate;
 import com.google.common.collect.Collections2;
 import com.google.common.collect.Sets;
 import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.InstanceConfig;
-import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
@@ -83,15 +82,14 @@ public class InstanceRuntime {
         }));
     }
 
-    public Element toXml(ObjectName rootOn, Set<ObjectName> childRbeOns, Document document) {
-        return toXml(rootOn, childRbeOns, document, null, null);
+    public Element toXml(ObjectName rootOn, Set<ObjectName> childRbeOns, Document document, Element parentElement, String namespace) {
+        return toXml(rootOn, childRbeOns, document, null, parentElement, namespace);
     }
 
     public Element toXml(ObjectName rootOn, Set<ObjectName> childRbeOns, Document document, String instanceIndex,
-            String keyName) {
-        Element xml = document.createElement(keyName == null ? XmlNetconfConstants.DATA_KEY : keyName);
+                         Element parentElement, String namespace) {
         // TODO namespace
-        xml = instanceMapping.toXml(rootOn, null, "namespace", document, xml);
+        Element xml = instanceMapping.toXml(rootOn, null, namespace, document, parentElement);
 
         if (instanceIndex != null) {
             xml.setAttribute(KEY_ATTRIBUTE_KEY, instanceIndex);
@@ -106,8 +104,11 @@ public class InstanceRuntime {
                 String runtimeInstanceIndex = objectName.getKeyProperty(childMappingEntry.getKey());
 
                 String elementName = jmxToYangChildRbeMapping.get(childMappingEntry.getKey());
-                xml.appendChild(childMappingEntry.getValue().toXml(objectName, innerChildRbeOns, document,
-                        runtimeInstanceIndex, elementName));
+
+                Element innerXml = document.createElement(elementName);
+                childMappingEntry.getValue().toXml(objectName, innerChildRbeOns, document,
+                        runtimeInstanceIndex, innerXml, namespace);
+                xml.appendChild(innerXml);
             }
         }
 
index 07da65e..4dbfba1 100644 (file)
@@ -8,7 +8,6 @@
 
 package org.opendaylight.controller.netconf.confignetconfconnector.mapping.runtime;
 
-import com.google.common.collect.Multimap;
 import com.google.common.collect.Sets;
 import org.opendaylight.controller.netconf.util.xml.XmlNetconfConstants;
 import org.opendaylight.controller.netconf.util.xml.XmlUtil;
@@ -41,31 +40,30 @@ public class ModuleRuntime {
         throw new IllegalStateException("Root runtime bean not found among " + runtimeBeanOns);
     }
 
-    public Element toXml(String namespace, Multimap<String, ObjectName> instances, Document document) {
-        Element root = document.createElement(XmlNetconfConstants.MODULE_KEY);
-        XmlUtil.addNamespaceAttr(root, namespace);
+    public Element toXml(String namespace, String instanceName, Collection<ObjectName> runtimeBeanOns, Document document) {
+        Element moduleElement = document.createElement(XmlNetconfConstants.MODULE_KEY);
 
-        Element nameElement = XmlUtil.createTextElement(document, XmlNetconfConstants.NAME_KEY, moduleName);
-        root.appendChild(nameElement);
+        final String prefix = getPrefix(namespace);
+        Element typeElement = XmlUtil.createPrefixedTextElement(document, XmlNetconfConstants.TYPE_KEY, prefix,
+                moduleName);
+        XmlUtil.addPrefixedNamespaceAttr(typeElement, prefix, namespace);
+        moduleElement.appendChild(typeElement);
 
-        for (String instanceName : instances.keySet()) {
-            Element instance = document.createElement(XmlNetconfConstants.INSTANCE_KEY);
+        Element nameElement = XmlUtil.createTextElement(document, XmlNetconfConstants.NAME_KEY, instanceName);
+        moduleElement.appendChild(nameElement);
 
-            Element innerNameElement = XmlUtil.createTextElement(document, XmlNetconfConstants.NAME_KEY, instanceName);
-            instance.appendChild(innerNameElement);
+        ObjectName rootName = findRoot(runtimeBeanOns);
 
-            Collection<ObjectName> runtimeBeanOns = instances.get(instanceName);
-            ObjectName rootName = findRoot(runtimeBeanOns);
+        Set<ObjectName> childrenRuntimeBeans = Sets.newHashSet(runtimeBeanOns);
+        childrenRuntimeBeans.remove(rootName);
 
-            Set<ObjectName> childrenRuntimeBeans = Sets.newHashSet(runtimeBeanOns);
-            childrenRuntimeBeans.remove(rootName);
+        instanceRuntime.toXml(rootName, childrenRuntimeBeans, document, moduleElement, namespace);
 
-            instance.appendChild(instanceRuntime.toXml(rootName, childrenRuntimeBeans, document));
-
-            root.appendChild(instance);
-        }
+        return moduleElement;
+    }
 
-        return root;
+    private String getPrefix(String namespace) {
+        return XmlNetconfConstants.PREFIX;
     }
 
 }
index da28126..8af1e0e 100644 (file)
@@ -66,9 +66,12 @@ public class Runtime {
                 if (instanceToRbe == null)
                     continue;
 
-                ModuleRuntime moduleRuntime = moduleRuntimes.get(localNamespace).get(moduleName);
-                Element innerXml = moduleRuntime.toXml(localNamespace, instanceToRbe, document);
-                modulesElement.appendChild(innerXml);
+                for (String instanceName : instanceToRbe.keySet()) {
+                    ModuleRuntime moduleRuntime = moduleRuntimes.get(localNamespace).get(moduleName);
+                    Element innerXml = moduleRuntime.toXml(localNamespace, instanceName, instanceToRbe.get(instanceName), document);
+                    modulesElement.appendChild(innerXml);
+                }
+
             }
         }
 
index de0ecdb..296b224 100644 (file)
@@ -441,7 +441,9 @@ public class NetconfMappingTest extends AbstractConfigTest {
 
         Element response = get();
 
-        assertEquals(2, getElementsSize(response, "instance"));
+        System.err.println(XmlUtil.toString(response));
+
+        assertEquals(2, getElementsSize(response, "module"));
         assertEquals(2, getElementsSize(response, "asdf"));
         assertEquals(5, getElementsSize(response, "inner-running-data"));
         assertEquals(5, getElementsSize(response, "deep2"));

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.