import org.opendaylight.yangtools.sal.binding.model.api.type.builder.MethodSignatureBuilder;
import org.opendaylight.yangtools.sal.binding.yang.types.GroupingDefinitionDependencySort;
import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
+import org.opendaylight.yangtools.yang.binding.DataRoot;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.binding.RpcService;
import org.opendaylight.yangtools.yang.common.QName;
final Set<Module> modules = context.getModules();
genTypeBuilders = new HashMap<>();
for (final Module module : modules) {
+
generatedTypes.addAll(allGroupingsToGenTypes(module));
- generatedTypes.add(moduleToDataType(module));
+
+ if(false == module.getChildNodes().isEmpty()) {
+ generatedTypes.add(moduleToDataType(module));
+ }
generatedTypes.addAll(allTypeDefinitionsToGenTypes(module));
generatedTypes.addAll(allContainersToGenTypes(module));
generatedTypes.addAll(allListsToGenTypes(module));
final List<Type> generatedTypes = new ArrayList<>();
generatedTypes.addAll(allGroupingsToGenTypes(contextModule));
- generatedTypes.add(moduleToDataType(contextModule));
+ if(false == contextModule.getChildNodes().isEmpty()) {
+ generatedTypes.add(moduleToDataType(contextModule));
+ }
generatedTypes.addAll(allTypeDefinitionsToGenTypes(contextModule));
generatedTypes.addAll(allContainersToGenTypes(contextModule));
generatedTypes.addAll(allListsToGenTypes(contextModule));
final GeneratedTypeBuilder moduleDataTypeBuilder = moduleTypeBuilder(module, "Data");
addInterfaceDefinition(module, moduleDataTypeBuilder);
+ moduleDataTypeBuilder.addImplementsType(Types.typeForClass(DataRoot.class));
final String basePackageName = moduleNamespaceToPackageName(module);
if (moduleDataTypeBuilder != null) {
final String basePackageName = moduleNamespaceToPackageName(module);
final Set<RpcDefinition> rpcDefinitions = module.getRpcs();
+
+ if(rpcDefinitions.isEmpty()) {
+ return Collections.emptyList();
+ }
+
final List<Type> genRPCTypes = new ArrayList<>();
final GeneratedTypeBuilder interfaceBuilder = moduleTypeBuilder(module, "Service");
interfaceBuilder.addImplementsType(Types.typeForClass(RpcService.class));
for (UsesNode usesNode : dataNodeContainer.getUses()) {
if (usesNode.getGroupingPath() != null) {
GeneratedType genType = allGroupings.get(usesNode.getGroupingPath());
+ if(genType == null) {
+ throw new IllegalStateException("Grouping " +usesNode.getGroupingPath() + "is not resolved for " + builder.getName());
+ }
builder.addImplementsType(genType);
}
}
package org.opendaylight.yangtools.sal.binding.yang.types;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.model.api.ChoiceNode;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.yang.model.api.UsesNode;
final GroupingNode groupingNode = (GroupingNode) node;
final GroupingDefinition groupingDefinition = groupingNode.getGroupingDefinition();
- Set<UsesNode> usesNodes = groupingDefinition.getUses();
+ Set<UsesNode> usesNodes =getAllUsesNodes(groupingDefinition);
for (UsesNode usesNode : usesNodes) {
SchemaPath schemaPath = usesNode.getGroupingPath();
if (schemaPath != null) {
return resultNodes;
}
+ private static Set<UsesNode> getAllUsesNodes(DataNodeContainer container) {
+ Set<UsesNode> ret = new HashSet<>();
+ ret.addAll(container.getUses());
+
+ Set<GroupingDefinition> groupings = container.getGroupings();
+ for (GroupingDefinition groupingDefinition : groupings) {
+ ret.addAll(getAllUsesNodes(groupingDefinition));
+ }
+ Set<DataSchemaNode> children = container.getChildNodes();
+ for (DataSchemaNode dataSchemaNode : children) {
+ if(dataSchemaNode instanceof DataNodeContainer) {
+ ret.addAll(getAllUsesNodes((DataNodeContainer) dataSchemaNode));
+ } else if (dataSchemaNode instanceof ChoiceNode) {
+ Set<ChoiceCaseNode> cases = ((ChoiceNode) dataSchemaNode).getCases();
+ for (ChoiceCaseNode choiceCaseNode : cases) {
+ ret.addAll(getAllUsesNodes(choiceCaseNode));
+ }
+
+ }
+ }
+
+ return ret;
+
+ }
+
+
private static final class GroupingNode extends NodeImpl {
private final GroupingDefinition groupingDefinition;
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.sal.binding.generator.impl;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.Test;
-import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
-import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-
-public class GenEnumResolvingTest {
-
- private SchemaContext resolveSchemaContextFromFiles(
- final String... yangFiles) {
- final YangModelParser parser = new YangParserImpl();
-
- final List<File> inputFiles = new ArrayList<File>();
- for (int i = 0; i < yangFiles.length; ++i) {
- inputFiles.add(new File(yangFiles[i]));
- }
-
- final Set<Module> modules = parser.parseYangModels(inputFiles);
- return parser.resolveSchemaContext(modules);
- }
-
- @Test
- public void testLeafEnumResolving() {
- final String ietfInterfacesPath = getClass().getResource(
- "/enum-test-models/ietf-interfaces@2012-11-15.yang").getPath();
- final String ifTypePath = getClass().getResource(
- "/enum-test-models/iana-if-type@2012-06-05.yang").getPath();
- final String yangTypesPath = getClass().getResource(
- "/enum-test-models/ietf-yang-types@2010-09-24.yang").getPath();
-
- final SchemaContext context = resolveSchemaContextFromFiles(
- ietfInterfacesPath, ifTypePath, yangTypesPath);
- assertTrue(context != null);
-
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context);
- assertTrue(genTypes != null);
-
- assertEquals("Expected count of all Generated Types from yang models " +
- "is 22", 25, genTypes.size());
-
- GeneratedType genInterface = null;
- for (final Type type : genTypes) {
- if (type instanceof GeneratedType) {
- if (type.getName().equals("Interface")) {
- genInterface = (GeneratedType) type;
- }
- }
- }
- assertNotNull("Generated Type Interface is not present in list of " +
- "Generated Types", genInterface);
-
- Enumeration linkUpDownTrapEnable = null;
- Enumeration operStatus = null;
- final List<Enumeration> enums = genInterface.getEnumerations();
- assertNotNull("Generated Type Interface cannot contain NULL reference" +
- " to Enumeration types!", enums);
- assertEquals("Generated Type Interface MUST contain 2 Enumeration " +
- "Types", 2, enums.size());
- for (final Enumeration e : enums) {
- if (e.getName().equals("LinkUpDownTrapEnable")) {
- linkUpDownTrapEnable = e;
- } else if (e.getName().equals("OperStatus")) {
- operStatus = e;
- }
- }
-
- assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!",
- linkUpDownTrapEnable);
- assertNotNull("Expected Enum OperStatus, but was NULL!", operStatus);
-
- assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition " +
- "not NULL reference!", linkUpDownTrapEnable.getValues());
- assertNotNull("Enum OperStatus MUST contain Values definition not " +
- "NULL reference!", operStatus.getValues());
- assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2,
- linkUpDownTrapEnable.getValues().size());
- assertEquals("Enum OperStatus MUST contain 7 values!", 7,
- operStatus.getValues().size());
-
- final List<MethodSignature> methods = genInterface
- .getMethodDefinitions();
-
- assertNotNull("Generated Interface cannot contain NULL reference for " +
- "Method Signature Definitions!", methods);
-
- assertEquals("Expected count of method signature definitions is 14",
- 14, methods.size());
- Enumeration ianaIfType = null;
- for (final MethodSignature method : methods) {
- if (method.getName().equals("getType")) {
- if (method.getReturnType() instanceof Enumeration) {
- ianaIfType = (Enumeration)method.getReturnType();
- }
- }
- }
-
- assertNotNull("Method getType MUST return Enumeration Type, " +
- "not NULL reference!", ianaIfType);
- assertEquals("Enumeration getType MUST contain 272 values!", 272,
- ianaIfType.getValues().size());
- }
-
- @Test
- public void testTypedefEnumResolving() {
- final String ianaIfTypePath = getClass().getResource(
- "/leafref-test-models/iana-if-type@2012-06-05.yang").getPath();
-
- final SchemaContext context = resolveSchemaContextFromFiles(ianaIfTypePath);
- assertTrue(context != null);
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context);
- assertTrue(genTypes != null);
- assertEquals(3, genTypes.size());
-
- final Type type = genTypes.get(1);
- assertTrue(type instanceof Enumeration);
-
- final Enumeration enumer = (Enumeration) type;
- assertEquals("Enumeration type MUST contain 272 values!", 272,
- enumer.getValues().size());
- }
-
- @Test
- public void testLeafrefEnumResolving() {
- final String ietfInterfacesPath = getClass().getResource(
- "/enum-test-models/ietf-interfaces@2012-11-15.yang").getPath();
- final String ifTypePath = getClass().getResource(
- "/enum-test-models/iana-if-type@2012-06-05.yang").getPath();
- final String yangTypesPath = getClass().getResource(
- "/enum-test-models/ietf-yang-types@2010-09-24.yang").getPath();
- final String topologyPath = getClass().getResource(
- "/enum-test-models/abstract-topology@2013-02-08.yang")
- .getPath();
- final String inetTypesPath = getClass().getResource(
- "/enum-test-models/ietf-inet-types@2010-09-24.yang")
- .getPath();
- final SchemaContext context = resolveSchemaContextFromFiles(
- ietfInterfacesPath, ifTypePath, yangTypesPath, topologyPath,
- inetTypesPath);
-
- assertNotNull(context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context);
- assertNotNull(genTypes);
- assertTrue(!genTypes.isEmpty());
-
- GeneratedType genInterface = null;
- for (final Type type : genTypes) {
- if (type instanceof GeneratedType) {
- if (type.getPackageName().equals("org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev201328.topology.interfaces")
- && type.getName().equals("Interface")) {
- genInterface = (GeneratedType) type;
- }
- }
- }
- assertNotNull("Generated Type Interface is not present in list of " +
- "Generated Types", genInterface);
-
- Type linkUpDownTrapEnable = null;
- Type operStatus = null;
- final List<MethodSignature> methods = genInterface.getMethodDefinitions();
- assertNotNull("Generated Type Interface cannot contain NULL reference" +
- " to Enumeration types!", methods);
- assertEquals("Generated Type Interface MUST contain 4 Methods ",
- 4, methods.size());
- for (final MethodSignature method : methods) {
- if (method.getName().equals("getLinkUpDownTrapEnable")) {
- linkUpDownTrapEnable = method.getReturnType();
- } else if (method.getName().equals("getOperStatus")) {
- operStatus = method.getReturnType();
- }
- }
-
- assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!",
- linkUpDownTrapEnable);
- assertTrue("Expected LinkUpDownTrapEnable of type ReferencedTypeImpl",
- linkUpDownTrapEnable instanceof ReferencedTypeImpl);
- assertEquals(linkUpDownTrapEnable.getPackageName(),
- "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev20121115.interfaces.Interface");
-
- assertNotNull("Expected Referenced Enum OperStatus, but was NULL!",
- operStatus);
- assertTrue("Expected OperStatus of type ReferencedTypeImpl",
- operStatus instanceof ReferencedTypeImpl);
- assertEquals(operStatus.getPackageName(),
- "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev20121115.interfaces.Interface");
- }
-}
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.yangtools.sal.binding.generator.impl;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import java.io.File;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Set;\r
+\r
+import org.junit.Test;\r
+import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;\r
+import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;\r
+import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;\r
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
+import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;\r
+import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
+import org.opendaylight.yangtools.yang.model.api.Module;\r
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
+import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;\r
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;\r
+\r
+public class GenEnumResolvingTest {\r
+\r
+ private SchemaContext resolveSchemaContextFromFiles(\r
+ final String... yangFiles) {\r
+ final YangModelParser parser = new YangParserImpl();\r
+\r
+ final List<File> inputFiles = new ArrayList<File>();\r
+ for (int i = 0; i < yangFiles.length; ++i) {\r
+ inputFiles.add(new File(yangFiles[i]));\r
+ }\r
+\r
+ final Set<Module> modules = parser.parseYangModels(inputFiles);\r
+ return parser.resolveSchemaContext(modules);\r
+ }\r
+\r
+ @Test\r
+ public void testLeafEnumResolving() {\r
+ final String ietfInterfacesPath = getClass().getResource(\r
+ "/enum-test-models/ietf-interfaces@2012-11-15.yang").getPath();\r
+ final String ifTypePath = getClass().getResource(\r
+ "/enum-test-models/iana-if-type@2012-06-05.yang").getPath();\r
+ final String yangTypesPath = getClass().getResource(\r
+ "/enum-test-models/ietf-yang-types@2010-09-24.yang").getPath();\r
+\r
+ final SchemaContext context = resolveSchemaContextFromFiles(\r
+ ietfInterfacesPath, ifTypePath, yangTypesPath);\r
+ assertTrue(context != null);\r
+\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context);\r
+ assertTrue(genTypes != null);\r
+\r
+ assertEquals("Expected count of all Generated Types", 20, genTypes.size());\r
+\r
+ GeneratedType genInterface = null;\r
+ for (final Type type : genTypes) {\r
+ if (type instanceof GeneratedType) {\r
+ if (type.getName().equals("Interface")) {\r
+ genInterface = (GeneratedType) type;\r
+ }\r
+ }\r
+ }\r
+ assertNotNull("Generated Type Interface is not present in list of " +\r
+ "Generated Types", genInterface);\r
+\r
+ Enumeration linkUpDownTrapEnable = null;\r
+ Enumeration operStatus = null;\r
+ final List<Enumeration> enums = genInterface.getEnumerations();\r
+ assertNotNull("Generated Type Interface cannot contain NULL reference" +\r
+ " to Enumeration types!", enums);\r
+ assertEquals("Generated Type Interface MUST contain 2 Enumeration " +\r
+ "Types", 2, enums.size());\r
+ for (final Enumeration e : enums) {\r
+ if (e.getName().equals("LinkUpDownTrapEnable")) {\r
+ linkUpDownTrapEnable = e;\r
+ } else if (e.getName().equals("OperStatus")) {\r
+ operStatus = e;\r
+ }\r
+ }\r
+\r
+ assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!",\r
+ linkUpDownTrapEnable);\r
+ assertNotNull("Expected Enum OperStatus, but was NULL!", operStatus);\r
+\r
+ assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition " +\r
+ "not NULL reference!", linkUpDownTrapEnable.getValues());\r
+ assertNotNull("Enum OperStatus MUST contain Values definition not " +\r
+ "NULL reference!", operStatus.getValues());\r
+ assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2,\r
+ linkUpDownTrapEnable.getValues().size());\r
+ assertEquals("Enum OperStatus MUST contain 7 values!", 7,\r
+ operStatus.getValues().size());\r
+\r
+ final List<MethodSignature> methods = genInterface\r
+ .getMethodDefinitions();\r
+\r
+ assertNotNull("Generated Interface cannot contain NULL reference for " +\r
+ "Method Signature Definitions!", methods);\r
+\r
+ assertEquals("Expected count of method signature definitions is 14",\r
+ 14, methods.size());\r
+ Enumeration ianaIfType = null;\r
+ for (final MethodSignature method : methods) {\r
+ if (method.getName().equals("getType")) {\r
+ if (method.getReturnType() instanceof Enumeration) {\r
+ ianaIfType = (Enumeration)method.getReturnType();\r
+ }\r
+ }\r
+ }\r
+\r
+ assertNotNull("Method getType MUST return Enumeration Type, " +\r
+ "not NULL reference!", ianaIfType);\r
+ assertEquals("Enumeration getType MUST contain 272 values!", 272,\r
+ ianaIfType.getValues().size());\r
+ }\r
+\r
+ @Test\r
+ public void testTypedefEnumResolving() {\r
+ final String ianaIfTypePath = getClass().getResource(\r
+ "/leafref-test-models/iana-if-type@2012-06-05.yang").getPath();\r
+\r
+ final SchemaContext context = resolveSchemaContextFromFiles(ianaIfTypePath);\r
+ assertTrue(context != null);\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context);\r
+ assertTrue(genTypes != null);\r
+ assertEquals(1, genTypes.size());\r
+\r
+ final Type type = genTypes.get(0);\r
+ assertTrue(type instanceof Enumeration);\r
+\r
+ final Enumeration enumer = (Enumeration) type;\r
+ assertEquals("Enumeration type MUST contain 272 values!", 272,\r
+ enumer.getValues().size());\r
+ }\r
+\r
+ @Test\r
+ public void testLeafrefEnumResolving() {\r
+ final String ietfInterfacesPath = getClass().getResource(\r
+ "/enum-test-models/ietf-interfaces@2012-11-15.yang").getPath();\r
+ final String ifTypePath = getClass().getResource(\r
+ "/enum-test-models/iana-if-type@2012-06-05.yang").getPath();\r
+ final String yangTypesPath = getClass().getResource(\r
+ "/enum-test-models/ietf-yang-types@2010-09-24.yang").getPath();\r
+ final String topologyPath = getClass().getResource(\r
+ "/enum-test-models/abstract-topology@2013-02-08.yang")\r
+ .getPath();\r
+ final String inetTypesPath = getClass().getResource(\r
+ "/enum-test-models/ietf-inet-types@2010-09-24.yang")\r
+ .getPath();\r
+ final SchemaContext context = resolveSchemaContextFromFiles(\r
+ ietfInterfacesPath, ifTypePath, yangTypesPath, topologyPath,\r
+ inetTypesPath);\r
+\r
+ assertNotNull(context);\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context);\r
+ assertNotNull(genTypes);\r
+ assertTrue(!genTypes.isEmpty());\r
+\r
+ GeneratedType genInterface = null;\r
+ for (final Type type : genTypes) {\r
+ if (type instanceof GeneratedType) {\r
+ if (type.getPackageName().equals("org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev201328.topology.interfaces")\r
+ && type.getName().equals("Interface")) {\r
+ genInterface = (GeneratedType) type;\r
+ }\r
+ }\r
+ }\r
+ assertNotNull("Generated Type Interface is not present in list of " +\r
+ "Generated Types", genInterface);\r
+\r
+ Type linkUpDownTrapEnable = null;\r
+ Type operStatus = null;\r
+ final List<MethodSignature> methods = genInterface.getMethodDefinitions();\r
+ assertNotNull("Generated Type Interface cannot contain NULL reference" +\r
+ " to Enumeration types!", methods);\r
+ assertEquals("Generated Type Interface MUST contain 4 Methods ",\r
+ 4, methods.size());\r
+ for (final MethodSignature method : methods) {\r
+ if (method.getName().equals("getLinkUpDownTrapEnable")) {\r
+ linkUpDownTrapEnable = method.getReturnType();\r
+ } else if (method.getName().equals("getOperStatus")) {\r
+ operStatus = method.getReturnType();\r
+ }\r
+ }\r
+\r
+ assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!",\r
+ linkUpDownTrapEnable);\r
+ assertTrue("Expected LinkUpDownTrapEnable of type ReferencedTypeImpl",\r
+ linkUpDownTrapEnable instanceof ReferencedTypeImpl);\r
+ assertEquals(linkUpDownTrapEnable.getPackageName(),\r
+ "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev20121115.interfaces.Interface");\r
+\r
+ assertNotNull("Expected Referenced Enum OperStatus, but was NULL!",\r
+ operStatus);\r
+ assertTrue("Expected OperStatus of type ReferencedTypeImpl",\r
+ operStatus instanceof ReferencedTypeImpl);\r
+ assertEquals(operStatus.getPackageName(),\r
+ "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev20121115.interfaces.Interface");\r
+ }\r
+}\r
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.sal.binding.generator.impl;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-
-public class GenTypesSubSetTest {
-
- private final static List<File> yangModels = new ArrayList<>();
- private final static String yangModelsFolder = AugmentedTypeTest.class
- .getResource("/leafref-test-models").getPath();
-
- @BeforeClass
- public static void loadTestResources() {
- final File augFolder = new File(yangModelsFolder);
-
- for (final File fileEntry : augFolder.listFiles()) {
- if (fileEntry.isFile()) {
- yangModels.add(fileEntry);
- }
- }
- }
-
- @Test
- public void genTypesFromSubsetOfTwoModulesTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
-
- final Set<Module> toGenModules = new HashSet<>();
- for (final Module module : modules) {
- if (module.getName().equals("abstract-topology")) {
- toGenModules.add(module);
- } else if (module.getName().equals("ietf-interfaces")) {
- toGenModules.add(module);
- }
- }
-
- assertEquals("Set of to Generate Modules must contain 2 modules", 2,
- toGenModules.size());
- assertNotNull("Schema Context is null", context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context, toGenModules);
- assertNotNull("genTypes is null", genTypes);
- assertFalse("genTypes is empty", genTypes.isEmpty());
- assertEquals("Expected Generated Types from provided sub set of " +
- "modules should be 23!", 25,
- genTypes.size());
- }
-
- @Test
- public void genTypesFromSubsetOfThreeModulesTest() {
- final YangModelParser parser = new YangParserImpl();
- final Set<Module> modules = parser.parseYangModels(yangModels);
- final SchemaContext context = parser.resolveSchemaContext(modules);
-
- final Set<Module> toGenModules = new HashSet<>();
- for (final Module module : modules) {
- if (module.getName().equals("abstract-topology")) {
- toGenModules.add(module);
- } else if (module.getName().equals("ietf-interfaces")) {
- toGenModules.add(module);
- } else if (module.getName().equals("iana-if-type")) {
- toGenModules.add(module);
- }
- }
-
- assertEquals("Set of to Generate Modules must contain 3 modules", 3,
- toGenModules.size());
-
- assertNotNull("Schema Context is null", context);
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context, toGenModules);
- assertNotNull("genTypes is null", genTypes);
- assertFalse("genTypes is empty", genTypes.isEmpty());
- assertEquals("Expected Generated Types from provided sub set of " +
- "modules should be 25!", 28, genTypes.size());
- }
-}
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.yangtools.sal.binding.generator.impl;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import java.io.File;\r
+import java.util.ArrayList;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Set;\r
+\r
+import org.junit.BeforeClass;\r
+import org.junit.Test;\r
+import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;\r
+import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
+import org.opendaylight.yangtools.yang.model.api.Module;\r
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
+import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;\r
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;\r
+\r
+public class GenTypesSubSetTest {\r
+\r
+ private final static List<File> yangModels = new ArrayList<>();\r
+ private final static String yangModelsFolder = AugmentedTypeTest.class\r
+ .getResource("/leafref-test-models").getPath();\r
+\r
+ @BeforeClass\r
+ public static void loadTestResources() {\r
+ final File augFolder = new File(yangModelsFolder);\r
+\r
+ for (final File fileEntry : augFolder.listFiles()) {\r
+ if (fileEntry.isFile()) {\r
+ yangModels.add(fileEntry);\r
+ }\r
+ }\r
+ }\r
+\r
+ @Test\r
+ public void genTypesFromSubsetOfTwoModulesTest() {\r
+ final YangModelParser parser = new YangParserImpl();\r
+ final Set<Module> modules = parser.parseYangModels(yangModels);\r
+ final SchemaContext context = parser.resolveSchemaContext(modules);\r
+\r
+ final Set<Module> toGenModules = new HashSet<>();\r
+ for (final Module module : modules) {\r
+ if (module.getName().equals("abstract-topology")) {\r
+ toGenModules.add(module);\r
+ } else if (module.getName().equals("ietf-interfaces")) {\r
+ toGenModules.add(module);\r
+ }\r
+ }\r
+\r
+ assertEquals("Set of to Generate Modules must contain 2 modules", 2,\r
+ toGenModules.size());\r
+ assertNotNull("Schema Context is null", context);\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context, toGenModules);\r
+ assertNotNull("genTypes is null", genTypes);\r
+ assertFalse("genTypes is empty", genTypes.isEmpty());\r
+ assertEquals("Expected Generated Types from provided sub set of " +\r
+ "modules should be 23!", 23,\r
+ genTypes.size());\r
+ }\r
+\r
+ @Test\r
+ public void genTypesFromSubsetOfThreeModulesTest() {\r
+ final YangModelParser parser = new YangParserImpl();\r
+ final Set<Module> modules = parser.parseYangModels(yangModels);\r
+ final SchemaContext context = parser.resolveSchemaContext(modules);\r
+\r
+ final Set<Module> toGenModules = new HashSet<>();\r
+ for (final Module module : modules) {\r
+ if (module.getName().equals("abstract-topology")) {\r
+ toGenModules.add(module);\r
+ } else if (module.getName().equals("ietf-interfaces")) {\r
+ toGenModules.add(module);\r
+ } else if (module.getName().equals("iana-if-type")) {\r
+ toGenModules.add(module);\r
+ }\r
+ }\r
+\r
+ assertEquals("Set of to Generate Modules must contain 3 modules", 3,\r
+ toGenModules.size());\r
+\r
+ assertNotNull("Schema Context is null", context);\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context, toGenModules);\r
+ assertNotNull("genTypes is null", genTypes);\r
+ assertFalse("genTypes is empty", genTypes.isEmpty());\r
+ assertEquals("Expected Generated Types", 24, genTypes.size());\r
+ }\r
+}\r
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.sal.binding.generator.impl;
-
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.Test;
-import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
-import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
-import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
-import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
-
-public class GeneratedTypesTest {
-
- private SchemaContext resolveSchemaContextFromFiles(final String... yangFiles) {
- final YangModelParser parser = new YangParserImpl();
-
- final List<File> inputFiles = new ArrayList<File>();
- for (int i = 0; i < yangFiles.length; ++i) {
- inputFiles.add(new File(yangFiles[i]));
- }
-
- final Set<Module> modules = parser.parseYangModels(inputFiles);
- return parser.resolveSchemaContext(modules);
- }
-
- @Test
- public void testMultipleModulesResolving() {
- final String topologyPath = getClass().getResource("/abstract-topology.yang").getPath();
- final String typesPath = getClass().getResource("/ietf-inet-types@2010-09-24.yang").getPath();
- final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, typesPath);
- assertNotNull(context);
-
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context);
-
- assertNotNull(genTypes);
- assertEquals(29, genTypes.size());
- }
-
- @Test
- public void testLeafrefResolving() {
- final String topologyPath = getClass().getResource("/leafref-test-models/abstract-topology@2013-02-08.yang")
- .getPath();
- final String interfacesPath = getClass().getResource("/leafref-test-models/ietf-interfaces@2012-11-15.yang")
- .getPath();
- // final String ifTypePath = getClass().getResource(
- // "/leafref-test-models/iana-if-type@2012-06-05.yang").getPath();
- final String inetTypesPath = getClass().getResource("/leafref-test-models/ietf-inet-types@2010-09-24.yang")
- .getPath();
- final String yangTypesPath = getClass().getResource("/leafref-test-models/ietf-yang-types@2010-09-24.yang")
- .getPath();
-
- assertNotNull(topologyPath);
- assertNotNull(interfacesPath);
- // assertTrue(ifTypePath != null);
- assertNotNull(inetTypesPath);
- assertNotNull(yangTypesPath);
-
- // final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, ifTypePath,
- // inetTypesPath, yangTypesPath);
- final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, inetTypesPath,
- yangTypesPath);
- assertNotNull(context);
- assertEquals(4, context.getModules().size());
-
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context);
-
- assertEquals(57, genTypes.size());
- assertNotNull(genTypes);
-
- GeneratedTransferObject gtIfcKey = null;
- GeneratedType gtIfc = null;
- GeneratedType gtNetworkLink = null;
- GeneratedType gtSource = null;
- GeneratedType gtDest = null;
- GeneratedType gtTunnel = null;
- GeneratedTransferObject gtTunnelKey = null;
- GeneratedType gtTopology = null;
- for (final Type type : genTypes) {
- String name = type.getName();
- if ("InterfaceKey".equals(name)) {
- gtIfcKey = (GeneratedTransferObject) type;
- } else if ("Interface".equals(name)) {
- gtIfc = (GeneratedType) type;
- } else if ("NetworkLink".equals(name)) {
- gtNetworkLink = (GeneratedType) type;
- } else if ("SourceNode".equals(name)) {
- gtSource = (GeneratedType) type;
- } else if ("DestinationNode".equals(name)) {
- gtDest = (GeneratedType) type;
- } else if ("Tunnel".equals(name)) {
- gtTunnel = (GeneratedType) type;
- } else if ("TunnelKey".equals(name)) {
- gtTunnelKey = (GeneratedTransferObject) type;
- } else if ("Topology".equals(name)) {
- gtTopology = (GeneratedType) type;
- }
- }
-
- assertNotNull(gtIfcKey);
- assertNotNull(gtIfc);
- assertNotNull(gtNetworkLink);
- assertNotNull(gtSource);
- assertNotNull(gtDest);
- assertNotNull(gtTunnel);
- assertNotNull(gtTunnelKey);
- assertNotNull(gtTopology);
-
- // Topology
- final List<MethodSignature> gtTopoMethods = gtTopology.getMethodDefinitions();
- assertNotNull(gtTopoMethods);
- MethodSignature condLeafref = null;
- for (final MethodSignature method : gtTopoMethods) {
- if (method.getName().equals("getCondLeafref")) {
- condLeafref = method;
- }
- }
- assertNotNull(condLeafref);
- Type condLeafRT = condLeafref.getReturnType();
- assertNotNull(condLeafRT);
- assertEquals("java.lang.Object", condLeafRT.getFullyQualifiedName());
-
- // InterfaceId
- final List<GeneratedProperty> gtIfcKeyProps = gtIfcKey.getProperties();
- assertNotNull(gtIfcKeyProps);
- GeneratedProperty ifcIdProp = null;
- for (final GeneratedProperty property : gtIfcKeyProps) {
- if (property.getName().equals("InterfaceId")) {
- ifcIdProp = property;
- }
- }
- assertNotNull(ifcIdProp);
- Type ifcIdPropType = ifcIdProp.getReturnType();
- assertNotNull(ifcIdPropType);
- assertEquals("java.lang.String", ifcIdPropType.getFullyQualifiedName());
-
- // Interface
- final List<MethodSignature> gtIfcMethods = gtIfc.getMethodDefinitions();
- assertNotNull(gtIfcMethods);
- MethodSignature getIfcKey = null;
- MethodSignature getHigherLayerIf = null;
- for (final MethodSignature method : gtIfcMethods) {
- if (method.getName().equals("getInterfaceKey")) {
- getIfcKey = method;
- } else if (method.getName().equals("getHigherLayerIf")) {
- getHigherLayerIf = method;
- }
- }
- assertNotNull(getIfcKey);
- Type getIfcKeyType = getIfcKey.getReturnType();
- assertNotNull(getIfcKeyType);
- assertNotSame("java.lang.Void", getIfcKeyType);
- assertEquals("InterfaceKey", getIfcKeyType.getName());
-
- assertNotNull(getHigherLayerIf);
- Type getHigherLayerIfType = getHigherLayerIf.getReturnType();
- assertNotNull(getHigherLayerIfType);
- assertNotSame("java.lang.Void", getHigherLayerIfType);
- assertEquals("List", getHigherLayerIfType.getName());
-
- // NetworkLink
- final List<MethodSignature> gtNetworkLinkMethods = gtNetworkLink.getMethodDefinitions();
- assertNotNull(gtNetworkLinkMethods);
- MethodSignature getIfc = null;
- for (MethodSignature method : gtNetworkLinkMethods) {
- if (method.getName().equals("getInterface")) {
- getIfc = method;
- }
- }
- assertNotNull(getIfc);
- Type getIfcType = getIfc.getReturnType();
- assertNotNull(getIfcType);
- assertNotSame("java.lang.Void", getIfcType);
- assertEquals("String", getIfcType.getName());
-
- // SourceNode
- final List<MethodSignature> gtSourceMethods = gtSource.getMethodDefinitions();
- assertNotNull(gtSourceMethods);
- MethodSignature getIdSource = null;
- for (MethodSignature method : gtSourceMethods) {
- if (method.getName().equals("getId")) {
- getIdSource = method;
- }
- }
- assertNotNull(getIdSource);
- Type getIdType = getIdSource.getReturnType();
- assertNotNull(getIdType);
- assertNotSame("java.lang.Void", getIdType);
- assertEquals("Uri", getIdType.getName());
-
- // DestinationNode
- final List<MethodSignature> gtDestMethods = gtDest.getMethodDefinitions();
- assertNotNull(gtDestMethods);
- MethodSignature getIdDest = null;
- for (MethodSignature method : gtDestMethods) {
- if (method.getName().equals("getId")) {
- getIdDest = method;
- }
- }
- assertNotNull(getIdDest);
- Type getIdDestType = getIdDest.getReturnType();
- assertNotNull(getIdDestType);
- assertNotSame("java.lang.Void", getIdDestType);
- assertEquals("Uri", getIdDestType.getName());
-
- // Tunnel
- final List<MethodSignature> gtTunnelMethods = gtTunnel.getMethodDefinitions();
- assertNotNull(gtTunnelMethods);
- MethodSignature getTunnelKey = null;
- for (MethodSignature method : gtTunnelMethods) {
- if (method.getName().equals("getTunnelKey")) {
- getTunnelKey = method;
- }
- }
- assertNotNull(getTunnelKey);
- Type getTunnelKeyType = getTunnelKey.getReturnType();
- assertNotNull(getTunnelKeyType);
- assertNotSame("java.lang.Void", getTunnelKeyType);
- assertEquals("TunnelKey", getTunnelKeyType.getName());
-
- // TunnelKey
- final List<GeneratedProperty> gtTunnelKeyProps = gtTunnelKey.getProperties();
- assertNotNull(gtTunnelKeyProps);
- GeneratedProperty tunnelId = null;
- for (final GeneratedProperty property : gtTunnelKeyProps) {
- if (property.getName().equals("TunnelId")) {
- tunnelId = property;
- }
- }
- assertNotNull(tunnelId);
- Type tunnelIdType = tunnelId.getReturnType();
- assertNotNull(tunnelIdType);
- assertNotSame("java.lang.Void", tunnelIdType);
- assertEquals("Uri", tunnelIdType.getName());
- }
-
- @Test
- public void testContainerResolving() {
- final String filePath = getClass().getResource("/simple-container-demo.yang").getPath();
- final SchemaContext context = resolveSchemaContextFromFiles(filePath);
- assert (context != null);
-
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context);
-
- assertNotNull(genTypes);
- assertEquals(4, genTypes.size());
-
- final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
- final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
-
- assertEquals("SimpleContainer", simpleContainer.getName());
- assertEquals("NestedContainer", nestedContainer.getName());
- assertEquals(3, simpleContainer.getMethodDefinitions().size());
- assertEquals(2, nestedContainer.getMethodDefinitions().size());
-
- int getFooMethodCounter = 0;
- int getBarMethodCounter = 0;
- int getNestedContainerCounter = 0;
-
- String getFooMethodReturnTypeName = "";
- String getBarMethodReturnTypeName = "";
- String getNestedContainerReturnTypeName = "";
- for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {
- if (method.getName().equals("getFoo")) {
- getFooMethodCounter++;
- getFooMethodReturnTypeName = method.getReturnType().getName();
- }
-
- if (method.getName().equals("getBar")) {
- getBarMethodCounter++;
- getBarMethodReturnTypeName = method.getReturnType().getName();
- }
-
- if (method.getName().equals("getNestedContainer")) {
- getNestedContainerCounter++;
- getNestedContainerReturnTypeName = method.getReturnType().getName();
- }
- }
-
- assertEquals(1, getFooMethodCounter);
- assertEquals("Integer", getFooMethodReturnTypeName);
-
- assertEquals(1, getBarMethodCounter);
- assertEquals("String", getBarMethodReturnTypeName);
-
- assertEquals(1, getNestedContainerCounter);
- assertEquals("NestedContainer", getNestedContainerReturnTypeName);
-
- getFooMethodCounter = 0;
- getBarMethodCounter = 0;
-
- getFooMethodReturnTypeName = "";
- getBarMethodReturnTypeName = "";
-
- for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {
-
- if (method.getName().equals("getFoo")) {
- getFooMethodCounter++;
- getFooMethodReturnTypeName = method.getReturnType().getName();
- }
-
- if (method.getName().equals("getBar")) {
- getBarMethodCounter++;
- getBarMethodReturnTypeName = method.getReturnType().getName();
- }
- }
-
- assertEquals(1, getFooMethodCounter);
- assertEquals("Short", getFooMethodReturnTypeName);
-
- assertEquals(1, getBarMethodCounter);
- assertEquals("String", getBarMethodReturnTypeName);
- }
-
- @Test
- public void testLeafListResolving() {
- final String filePath = getClass().getResource("/simple-leaf-list-demo.yang").getPath();
- final SchemaContext context = resolveSchemaContextFromFiles(filePath);
- assertNotNull(context);
-
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context);
-
- assertNotNull(genTypes);
- assertEquals(4, genTypes.size());
-
- final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);
- final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);
-
- assertEquals("SimpleContainer", simpleContainer.getName());
- assertEquals("NestedContainer", nestedContainer.getName());
- assertEquals(3, simpleContainer.getMethodDefinitions().size());
- assertEquals(2, nestedContainer.getMethodDefinitions().size());
-
- int getFooMethodCounter = 0;
- int getBarMethodCounter = 0;
- int getNestedContainerCounter = 0;
-
- String getFooMethodReturnTypeName = "";
- String getBarMethodReturnTypeName = "";
- String getNestedContainerReturnTypeName = "";
- for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {
- if (method.getName().equals("getFoo")) {
- getFooMethodCounter++;
- getFooMethodReturnTypeName = method.getReturnType().getName();
- }
-
- if (method.getName().equals("getBar")) {
- getBarMethodCounter++;
- getBarMethodReturnTypeName = method.getReturnType().getName();
- }
-
- if (method.getName().equals("getNestedContainer")) {
- getNestedContainerCounter++;
- getNestedContainerReturnTypeName = method.getReturnType().getName();
- }
- }
-
- assertEquals(1, getFooMethodCounter);
- assertEquals("List", getFooMethodReturnTypeName);
-
- assertEquals(1, getBarMethodCounter);
- assertEquals("String", getBarMethodReturnTypeName);
-
- assertEquals(1, getNestedContainerCounter);
- assertEquals("NestedContainer", getNestedContainerReturnTypeName);
-
- getFooMethodCounter = 0;
- getBarMethodCounter = 0;
-
- getFooMethodReturnTypeName = "";
- getBarMethodReturnTypeName = "";
-
- for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {
- if (method.getName().equals("getFoo")) {
- getFooMethodCounter++;
- getFooMethodReturnTypeName = method.getReturnType().getName();
- }
-
- if (method.getName().equals("getBar")) {
- getBarMethodCounter++;
- getBarMethodReturnTypeName = method.getReturnType().getName();
- }
- }
-
- assertEquals(1, getFooMethodCounter);
- assertEquals("Short", getFooMethodReturnTypeName);
-
- assertEquals(1, getBarMethodCounter);
- assertEquals("List", getBarMethodReturnTypeName);
- }
-
- @Test
- public void testListResolving() {
- final String filePath = getClass().getResource("/simple-list-demo.yang").getPath();
- final SchemaContext context = resolveSchemaContextFromFiles(filePath);
- assertNotNull(context);
-
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context);
-
- assertNotNull(genTypes);
- assertEquals(6, genTypes.size());
-
- int listParentContainerMethodsCount = 0;
- int simpleListMethodsCount = 0;
- int listChildContainerMethodsCount = 0;
- int listKeyClassCount = 0;
-
- int getSimpleListKeyMethodCount = 0;
- int getListChildContainerMethodCount = 0;
- int getFooMethodCount = 0;
- int setFooMethodCount = 0;
- int getSimpleLeafListMethodCount = 0;
- int setSimpleLeafListMethodCount = 0;
- int getBarMethodCount = 0;
-
- String getSimpleListKeyMethodReturnTypeName = "";
- String getListChildContainerMethodReturnTypeName = "";
-
- int listKeyClassPropertyCount = 0;
- String listKeyClassPropertyName = "";
- String listKeyClassPropertyTypeName = "";
- boolean listKeyClassPropertyReadOnly = false;
-
- int hashMethodParameterCount = 0;
- String hashMethodParameterName = "";
- String hashMethodParameterReturnTypeName = "";
-
- int equalMethodParameterCount = 0;
- String equalMethodParameterName = "";
- String equalMethodParameterReturnTypeName = "";
-
- for (final Type type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- final GeneratedType genType = (GeneratedType) type;
- if (genType.getName().equals("ListParentContainer")) {
- listParentContainerMethodsCount = genType.getMethodDefinitions().size();
- } else if (genType.getName().equals("SimpleList")) {
- simpleListMethodsCount = genType.getMethodDefinitions().size();
- final List<MethodSignature> methods = genType.getMethodDefinitions();
- for (final MethodSignature method : methods) {
- if (method.getName().equals("getSimpleListKey")) {
- getSimpleListKeyMethodCount++;
- getSimpleListKeyMethodReturnTypeName = method.getReturnType().getName();
- } else if (method.getName().equals("getListChildContainer")) {
- getListChildContainerMethodCount++;
- getListChildContainerMethodReturnTypeName = method.getReturnType().getName();
- } else if (method.getName().equals("getFoo")) {
- getFooMethodCount++;
- } else if (method.getName().equals("setFoo")) {
- setFooMethodCount++;
- } else if (method.getName().equals("getSimpleLeafList")) {
- getSimpleLeafListMethodCount++;
- } else if (method.getName().equals("setSimpleLeafList")) {
- setSimpleLeafListMethodCount++;
- } else if (method.getName().equals("getBar")) {
- getBarMethodCount++;
- }
- }
- } else if (genType.getName().equals("ListChildContainer")) {
- listChildContainerMethodsCount = genType.getMethodDefinitions().size();
- }
- } else if (type instanceof GeneratedTransferObject) {
- final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
- final List<GeneratedProperty> properties = genTO.getProperties();
- final List<GeneratedProperty> hashProps = genTO.getHashCodeIdentifiers();
- final List<GeneratedProperty> equalProps = genTO.getEqualsIdentifiers();
-
- listKeyClassCount++;
- listKeyClassPropertyCount = properties.size();
- listKeyClassPropertyName = properties.get(0).getName();
- listKeyClassPropertyTypeName = properties.get(0).getReturnType().getName();
- listKeyClassPropertyReadOnly = properties.get(0).isReadOnly();
-
- hashMethodParameterCount = hashProps.size();
- hashMethodParameterName = hashProps.get(0).getName();
- hashMethodParameterReturnTypeName = hashProps.get(0).getReturnType().getName();
-
- equalMethodParameterCount = equalProps.size();
- equalMethodParameterName = equalProps.get(0).getName();
- equalMethodParameterReturnTypeName = equalProps.get(0).getReturnType().getName();
-
- }
- }
-
- assertEquals(1, listParentContainerMethodsCount);
- assertEquals(1, listChildContainerMethodsCount);
- assertEquals(1, getSimpleListKeyMethodCount);
- assertEquals(1, listKeyClassCount);
-
- assertEquals(1, listKeyClassPropertyCount);
- assertEquals("ListKey", listKeyClassPropertyName);
- assertEquals("Byte", listKeyClassPropertyTypeName);
- assertEquals(true, listKeyClassPropertyReadOnly);
- assertEquals(1, hashMethodParameterCount);
- assertEquals("ListKey", hashMethodParameterName);
- assertEquals("Byte", hashMethodParameterReturnTypeName);
- assertEquals(1, equalMethodParameterCount);
- assertEquals("ListKey", equalMethodParameterName);
- assertEquals("Byte", equalMethodParameterReturnTypeName);
-
- assertEquals("SimpleListKey", getSimpleListKeyMethodReturnTypeName);
-
- assertEquals(1, getListChildContainerMethodCount);
- assertEquals("ListChildContainer", getListChildContainerMethodReturnTypeName);
- assertEquals(1, getFooMethodCount);
- assertEquals(0, setFooMethodCount);
- assertEquals(1, getSimpleLeafListMethodCount);
- assertEquals(0, setSimpleLeafListMethodCount);
- assertEquals(1, getBarMethodCount);
-
- assertEquals(5, simpleListMethodsCount);
- }
-
- @Test
- public void testListCompositeKeyResolving() {
- final String filePath = getClass().getResource("/list-composite-key.yang").getPath();
- final SchemaContext context = resolveSchemaContextFromFiles(filePath);
-
- assertNotNull(context);
-
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context);
-
- assertNotNull(genTypes);
- assertEquals(8, genTypes.size());
-
- int genTypesCount = 0;
- int genTOsCount = 0;
-
- int compositeKeyListKeyPropertyCount = 0;
- int compositeKeyListKeyCount = 0;
- int innerListKeyPropertyCount = 0;
-
- for (final Type type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- genTypesCount++;
- } else if (type instanceof GeneratedTransferObject) {
- final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
-
- if (genTO.getName().equals("CompositeKeyListKey")) {
- compositeKeyListKeyCount++;
- final List<GeneratedProperty> properties = genTO.getProperties();
- for (final GeneratedProperty prop : properties) {
- if (prop.getName().equals("Key1")) {
- compositeKeyListKeyPropertyCount++;
- } else if (prop.getName().equals("Key2")) {
- compositeKeyListKeyPropertyCount++;
- }
- }
- genTOsCount++;
- } else if (genTO.getName().equals("InnerListKey")) {
- final List<GeneratedProperty> properties = genTO.getProperties();
- innerListKeyPropertyCount = properties.size();
- genTOsCount++;
- }
- }
- }
- assertEquals(1, compositeKeyListKeyCount);
- assertEquals(2, compositeKeyListKeyPropertyCount);
-
- assertEquals(1, innerListKeyPropertyCount);
-
- assertEquals(6, genTypesCount);
- assertEquals(2, genTOsCount);
- }
-
- @Test
- public void testGeneratedTypes() {
- final String filePath = getClass().getResource("/demo-topology.yang").getPath();
- final SchemaContext context = resolveSchemaContextFromFiles(filePath);
- assertNotNull(context);
-
- final BindingGenerator bindingGen = new BindingGeneratorImpl();
- final List<Type> genTypes = bindingGen.generateTypes(context);
-
- assertNotNull(genTypes);
- assertEquals(15, genTypes.size());
-
- int genTypesCount = 0;
- int genTOsCount = 0;
- for (final Type type : genTypes) {
- if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
- genTypesCount++;
- } else if (type instanceof GeneratedTransferObject) {
- genTOsCount++;
- }
- }
-
- assertEquals(12, genTypesCount);
- assertEquals(3, genTOsCount);
- }
-}
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.yangtools.sal.binding.generator.impl;\r
+\r
+import static org.junit.Assert.*;\r
+\r
+import java.io.File;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Set;\r
+\r
+import org.junit.Test;\r
+import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;\r
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;\r
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;\r
+import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;\r
+import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;\r
+import org.opendaylight.yangtools.sal.binding.model.api.Type;\r
+import org.opendaylight.yangtools.yang.model.api.Module;\r
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;\r
+import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;\r
+import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;\r
+\r
+public class GeneratedTypesTest {\r
+\r
+ private SchemaContext resolveSchemaContextFromFiles(final String... yangFiles) {\r
+ final YangModelParser parser = new YangParserImpl();\r
+\r
+ final List<File> inputFiles = new ArrayList<File>();\r
+ for (int i = 0; i < yangFiles.length; ++i) {\r
+ inputFiles.add(new File(yangFiles[i]));\r
+ }\r
+\r
+ final Set<Module> modules = parser.parseYangModels(inputFiles);\r
+ return parser.resolveSchemaContext(modules);\r
+ }\r
+\r
+ @Test\r
+ public void testMultipleModulesResolving() {\r
+ final String topologyPath = getClass().getResource("/abstract-topology.yang").getPath();\r
+ final String typesPath = getClass().getResource("/ietf-inet-types@2010-09-24.yang").getPath();\r
+ final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, typesPath);\r
+ assertNotNull(context);\r
+\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context);\r
+\r
+ assertNotNull(genTypes);\r
+ assertEquals(26, genTypes.size());\r
+ }\r
+\r
+ @Test\r
+ public void testLeafrefResolving() {\r
+ final String topologyPath = getClass().getResource("/leafref-test-models/abstract-topology@2013-02-08.yang")\r
+ .getPath();\r
+ final String interfacesPath = getClass().getResource("/leafref-test-models/ietf-interfaces@2012-11-15.yang")\r
+ .getPath();\r
+ // final String ifTypePath = getClass().getResource(\r
+ // "/leafref-test-models/iana-if-type@2012-06-05.yang").getPath();\r
+ final String inetTypesPath = getClass().getResource("/leafref-test-models/ietf-inet-types@2010-09-24.yang")\r
+ .getPath();\r
+ final String yangTypesPath = getClass().getResource("/leafref-test-models/ietf-yang-types@2010-09-24.yang")\r
+ .getPath();\r
+\r
+ assertNotNull(topologyPath);\r
+ assertNotNull(interfacesPath);\r
+ // assertTrue(ifTypePath != null);\r
+ assertNotNull(inetTypesPath);\r
+ assertNotNull(yangTypesPath);\r
+\r
+ // final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, ifTypePath,\r
+ // inetTypesPath, yangTypesPath);\r
+ final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, interfacesPath, inetTypesPath,\r
+ yangTypesPath);\r
+ assertNotNull(context);\r
+ assertEquals(4, context.getModules().size());\r
+\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context);\r
+\r
+ assertEquals(51, genTypes.size());\r
+ assertNotNull(genTypes);\r
+\r
+ GeneratedTransferObject gtIfcKey = null;\r
+ GeneratedType gtIfc = null;\r
+ GeneratedType gtNetworkLink = null;\r
+ GeneratedType gtSource = null;\r
+ GeneratedType gtDest = null;\r
+ GeneratedType gtTunnel = null;\r
+ GeneratedTransferObject gtTunnelKey = null;\r
+ GeneratedType gtTopology = null;\r
+ for (final Type type : genTypes) {\r
+ String name = type.getName();\r
+ if ("InterfaceKey".equals(name)) {\r
+ gtIfcKey = (GeneratedTransferObject) type;\r
+ } else if ("Interface".equals(name)) {\r
+ gtIfc = (GeneratedType) type;\r
+ } else if ("NetworkLink".equals(name)) {\r
+ gtNetworkLink = (GeneratedType) type;\r
+ } else if ("SourceNode".equals(name)) {\r
+ gtSource = (GeneratedType) type;\r
+ } else if ("DestinationNode".equals(name)) {\r
+ gtDest = (GeneratedType) type;\r
+ } else if ("Tunnel".equals(name)) {\r
+ gtTunnel = (GeneratedType) type;\r
+ } else if ("TunnelKey".equals(name)) {\r
+ gtTunnelKey = (GeneratedTransferObject) type;\r
+ } else if ("Topology".equals(name)) {\r
+ gtTopology = (GeneratedType) type;\r
+ }\r
+ }\r
+\r
+ assertNotNull(gtIfcKey);\r
+ assertNotNull(gtIfc);\r
+ assertNotNull(gtNetworkLink);\r
+ assertNotNull(gtSource);\r
+ assertNotNull(gtDest);\r
+ assertNotNull(gtTunnel);\r
+ assertNotNull(gtTunnelKey);\r
+ assertNotNull(gtTopology);\r
+\r
+ // Topology\r
+ final List<MethodSignature> gtTopoMethods = gtTopology.getMethodDefinitions();\r
+ assertNotNull(gtTopoMethods);\r
+ MethodSignature condLeafref = null;\r
+ for (final MethodSignature method : gtTopoMethods) {\r
+ if (method.getName().equals("getCondLeafref")) {\r
+ condLeafref = method;\r
+ }\r
+ }\r
+ assertNotNull(condLeafref);\r
+ Type condLeafRT = condLeafref.getReturnType();\r
+ assertNotNull(condLeafRT);\r
+ assertEquals("java.lang.Object", condLeafRT.getFullyQualifiedName());\r
+\r
+ // InterfaceId\r
+ final List<GeneratedProperty> gtIfcKeyProps = gtIfcKey.getProperties();\r
+ assertNotNull(gtIfcKeyProps);\r
+ GeneratedProperty ifcIdProp = null;\r
+ for (final GeneratedProperty property : gtIfcKeyProps) {\r
+ if (property.getName().equals("InterfaceId")) {\r
+ ifcIdProp = property;\r
+ }\r
+ }\r
+ assertNotNull(ifcIdProp);\r
+ Type ifcIdPropType = ifcIdProp.getReturnType();\r
+ assertNotNull(ifcIdPropType);\r
+ assertEquals("java.lang.String", ifcIdPropType.getFullyQualifiedName());\r
+\r
+ // Interface\r
+ final List<MethodSignature> gtIfcMethods = gtIfc.getMethodDefinitions();\r
+ assertNotNull(gtIfcMethods);\r
+ MethodSignature getIfcKey = null;\r
+ MethodSignature getHigherLayerIf = null;\r
+ for (final MethodSignature method : gtIfcMethods) {\r
+ if (method.getName().equals("getInterfaceKey")) {\r
+ getIfcKey = method;\r
+ } else if (method.getName().equals("getHigherLayerIf")) {\r
+ getHigherLayerIf = method;\r
+ }\r
+ }\r
+ assertNotNull(getIfcKey);\r
+ Type getIfcKeyType = getIfcKey.getReturnType();\r
+ assertNotNull(getIfcKeyType);\r
+ assertNotSame("java.lang.Void", getIfcKeyType);\r
+ assertEquals("InterfaceKey", getIfcKeyType.getName());\r
+\r
+ assertNotNull(getHigherLayerIf);\r
+ Type getHigherLayerIfType = getHigherLayerIf.getReturnType();\r
+ assertNotNull(getHigherLayerIfType);\r
+ assertNotSame("java.lang.Void", getHigherLayerIfType);\r
+ assertEquals("List", getHigherLayerIfType.getName());\r
+\r
+ // NetworkLink\r
+ final List<MethodSignature> gtNetworkLinkMethods = gtNetworkLink.getMethodDefinitions();\r
+ assertNotNull(gtNetworkLinkMethods);\r
+ MethodSignature getIfc = null;\r
+ for (MethodSignature method : gtNetworkLinkMethods) {\r
+ if (method.getName().equals("getInterface")) {\r
+ getIfc = method;\r
+ }\r
+ }\r
+ assertNotNull(getIfc);\r
+ Type getIfcType = getIfc.getReturnType();\r
+ assertNotNull(getIfcType);\r
+ assertNotSame("java.lang.Void", getIfcType);\r
+ assertEquals("String", getIfcType.getName());\r
+\r
+ // SourceNode\r
+ final List<MethodSignature> gtSourceMethods = gtSource.getMethodDefinitions();\r
+ assertNotNull(gtSourceMethods);\r
+ MethodSignature getIdSource = null;\r
+ for (MethodSignature method : gtSourceMethods) {\r
+ if (method.getName().equals("getId")) {\r
+ getIdSource = method;\r
+ }\r
+ }\r
+ assertNotNull(getIdSource);\r
+ Type getIdType = getIdSource.getReturnType();\r
+ assertNotNull(getIdType);\r
+ assertNotSame("java.lang.Void", getIdType);\r
+ assertEquals("Uri", getIdType.getName());\r
+\r
+ // DestinationNode\r
+ final List<MethodSignature> gtDestMethods = gtDest.getMethodDefinitions();\r
+ assertNotNull(gtDestMethods);\r
+ MethodSignature getIdDest = null;\r
+ for (MethodSignature method : gtDestMethods) {\r
+ if (method.getName().equals("getId")) {\r
+ getIdDest = method;\r
+ }\r
+ }\r
+ assertNotNull(getIdDest);\r
+ Type getIdDestType = getIdDest.getReturnType();\r
+ assertNotNull(getIdDestType);\r
+ assertNotSame("java.lang.Void", getIdDestType);\r
+ assertEquals("Uri", getIdDestType.getName());\r
+\r
+ // Tunnel\r
+ final List<MethodSignature> gtTunnelMethods = gtTunnel.getMethodDefinitions();\r
+ assertNotNull(gtTunnelMethods);\r
+ MethodSignature getTunnelKey = null;\r
+ for (MethodSignature method : gtTunnelMethods) {\r
+ if (method.getName().equals("getTunnelKey")) {\r
+ getTunnelKey = method;\r
+ }\r
+ }\r
+ assertNotNull(getTunnelKey);\r
+ Type getTunnelKeyType = getTunnelKey.getReturnType();\r
+ assertNotNull(getTunnelKeyType);\r
+ assertNotSame("java.lang.Void", getTunnelKeyType);\r
+ assertEquals("TunnelKey", getTunnelKeyType.getName());\r
+\r
+ // TunnelKey\r
+ final List<GeneratedProperty> gtTunnelKeyProps = gtTunnelKey.getProperties();\r
+ assertNotNull(gtTunnelKeyProps);\r
+ GeneratedProperty tunnelId = null;\r
+ for (final GeneratedProperty property : gtTunnelKeyProps) {\r
+ if (property.getName().equals("TunnelId")) {\r
+ tunnelId = property;\r
+ }\r
+ }\r
+ assertNotNull(tunnelId);\r
+ Type tunnelIdType = tunnelId.getReturnType();\r
+ assertNotNull(tunnelIdType);\r
+ assertNotSame("java.lang.Void", tunnelIdType);\r
+ assertEquals("Uri", tunnelIdType.getName());\r
+ }\r
+\r
+ @Test\r
+ public void testContainerResolving() {\r
+ final String filePath = getClass().getResource("/simple-container-demo.yang").getPath();\r
+ final SchemaContext context = resolveSchemaContextFromFiles(filePath);\r
+ assert (context != null);\r
+\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context);\r
+\r
+ assertNotNull(genTypes);\r
+ assertEquals(3, genTypes.size());\r
+\r
+ final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);\r
+ final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);\r
+\r
+ assertEquals("SimpleContainer", simpleContainer.getName());\r
+ assertEquals("NestedContainer", nestedContainer.getName());\r
+ assertEquals(3, simpleContainer.getMethodDefinitions().size());\r
+ assertEquals(2, nestedContainer.getMethodDefinitions().size());\r
+\r
+ int getFooMethodCounter = 0;\r
+ int getBarMethodCounter = 0;\r
+ int getNestedContainerCounter = 0;\r
+\r
+ String getFooMethodReturnTypeName = "";\r
+ String getBarMethodReturnTypeName = "";\r
+ String getNestedContainerReturnTypeName = "";\r
+ for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {\r
+ if (method.getName().equals("getFoo")) {\r
+ getFooMethodCounter++;\r
+ getFooMethodReturnTypeName = method.getReturnType().getName();\r
+ }\r
+\r
+ if (method.getName().equals("getBar")) {\r
+ getBarMethodCounter++;\r
+ getBarMethodReturnTypeName = method.getReturnType().getName();\r
+ }\r
+\r
+ if (method.getName().equals("getNestedContainer")) {\r
+ getNestedContainerCounter++;\r
+ getNestedContainerReturnTypeName = method.getReturnType().getName();\r
+ }\r
+ }\r
+\r
+ assertEquals(1, getFooMethodCounter);\r
+ assertEquals("Integer", getFooMethodReturnTypeName);\r
+\r
+ assertEquals(1, getBarMethodCounter);\r
+ assertEquals("String", getBarMethodReturnTypeName);\r
+\r
+ assertEquals(1, getNestedContainerCounter);\r
+ assertEquals("NestedContainer", getNestedContainerReturnTypeName);\r
+\r
+ getFooMethodCounter = 0;\r
+ getBarMethodCounter = 0;\r
+\r
+ getFooMethodReturnTypeName = "";\r
+ getBarMethodReturnTypeName = "";\r
+\r
+ for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {\r
+\r
+ if (method.getName().equals("getFoo")) {\r
+ getFooMethodCounter++;\r
+ getFooMethodReturnTypeName = method.getReturnType().getName();\r
+ }\r
+\r
+ if (method.getName().equals("getBar")) {\r
+ getBarMethodCounter++;\r
+ getBarMethodReturnTypeName = method.getReturnType().getName();\r
+ }\r
+ }\r
+\r
+ assertEquals(1, getFooMethodCounter);\r
+ assertEquals("Short", getFooMethodReturnTypeName);\r
+\r
+ assertEquals(1, getBarMethodCounter);\r
+ assertEquals("String", getBarMethodReturnTypeName);\r
+ }\r
+\r
+ @Test\r
+ public void testLeafListResolving() {\r
+ final String filePath = getClass().getResource("/simple-leaf-list-demo.yang").getPath();\r
+ final SchemaContext context = resolveSchemaContextFromFiles(filePath);\r
+ assertNotNull(context);\r
+\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context);\r
+\r
+ assertNotNull(genTypes);\r
+ assertEquals(3, genTypes.size());\r
+\r
+ final GeneratedType simpleContainer = (GeneratedType) genTypes.get(1);\r
+ final GeneratedType nestedContainer = (GeneratedType) genTypes.get(2);\r
+\r
+ assertEquals("SimpleContainer", simpleContainer.getName());\r
+ assertEquals("NestedContainer", nestedContainer.getName());\r
+ assertEquals(3, simpleContainer.getMethodDefinitions().size());\r
+ assertEquals(2, nestedContainer.getMethodDefinitions().size());\r
+\r
+ int getFooMethodCounter = 0;\r
+ int getBarMethodCounter = 0;\r
+ int getNestedContainerCounter = 0;\r
+\r
+ String getFooMethodReturnTypeName = "";\r
+ String getBarMethodReturnTypeName = "";\r
+ String getNestedContainerReturnTypeName = "";\r
+ for (final MethodSignature method : simpleContainer.getMethodDefinitions()) {\r
+ if (method.getName().equals("getFoo")) {\r
+ getFooMethodCounter++;\r
+ getFooMethodReturnTypeName = method.getReturnType().getName();\r
+ }\r
+\r
+ if (method.getName().equals("getBar")) {\r
+ getBarMethodCounter++;\r
+ getBarMethodReturnTypeName = method.getReturnType().getName();\r
+ }\r
+\r
+ if (method.getName().equals("getNestedContainer")) {\r
+ getNestedContainerCounter++;\r
+ getNestedContainerReturnTypeName = method.getReturnType().getName();\r
+ }\r
+ }\r
+\r
+ assertEquals(1, getFooMethodCounter);\r
+ assertEquals("List", getFooMethodReturnTypeName);\r
+\r
+ assertEquals(1, getBarMethodCounter);\r
+ assertEquals("String", getBarMethodReturnTypeName);\r
+\r
+ assertEquals(1, getNestedContainerCounter);\r
+ assertEquals("NestedContainer", getNestedContainerReturnTypeName);\r
+\r
+ getFooMethodCounter = 0;\r
+ getBarMethodCounter = 0;\r
+\r
+ getFooMethodReturnTypeName = "";\r
+ getBarMethodReturnTypeName = "";\r
+\r
+ for (final MethodSignature method : nestedContainer.getMethodDefinitions()) {\r
+ if (method.getName().equals("getFoo")) {\r
+ getFooMethodCounter++;\r
+ getFooMethodReturnTypeName = method.getReturnType().getName();\r
+ }\r
+\r
+ if (method.getName().equals("getBar")) {\r
+ getBarMethodCounter++;\r
+ getBarMethodReturnTypeName = method.getReturnType().getName();\r
+ }\r
+ }\r
+\r
+ assertEquals(1, getFooMethodCounter);\r
+ assertEquals("Short", getFooMethodReturnTypeName);\r
+\r
+ assertEquals(1, getBarMethodCounter);\r
+ assertEquals("List", getBarMethodReturnTypeName);\r
+ }\r
+\r
+ @Test\r
+ public void testListResolving() {\r
+ final String filePath = getClass().getResource("/simple-list-demo.yang").getPath();\r
+ final SchemaContext context = resolveSchemaContextFromFiles(filePath);\r
+ assertNotNull(context);\r
+\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context);\r
+\r
+ assertNotNull(genTypes);\r
+ assertEquals(5, genTypes.size());\r
+\r
+ int listParentContainerMethodsCount = 0;\r
+ int simpleListMethodsCount = 0;\r
+ int listChildContainerMethodsCount = 0;\r
+ int listKeyClassCount = 0;\r
+\r
+ int getSimpleListKeyMethodCount = 0;\r
+ int getListChildContainerMethodCount = 0;\r
+ int getFooMethodCount = 0;\r
+ int setFooMethodCount = 0;\r
+ int getSimpleLeafListMethodCount = 0;\r
+ int setSimpleLeafListMethodCount = 0;\r
+ int getBarMethodCount = 0;\r
+\r
+ String getSimpleListKeyMethodReturnTypeName = "";\r
+ String getListChildContainerMethodReturnTypeName = "";\r
+\r
+ int listKeyClassPropertyCount = 0;\r
+ String listKeyClassPropertyName = "";\r
+ String listKeyClassPropertyTypeName = "";\r
+ boolean listKeyClassPropertyReadOnly = false;\r
+\r
+ int hashMethodParameterCount = 0;\r
+ String hashMethodParameterName = "";\r
+ String hashMethodParameterReturnTypeName = "";\r
+\r
+ int equalMethodParameterCount = 0;\r
+ String equalMethodParameterName = "";\r
+ String equalMethodParameterReturnTypeName = "";\r
+\r
+ for (final Type type : genTypes) {\r
+ if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {\r
+ final GeneratedType genType = (GeneratedType) type;\r
+ if (genType.getName().equals("ListParentContainer")) {\r
+ listParentContainerMethodsCount = genType.getMethodDefinitions().size();\r
+ } else if (genType.getName().equals("SimpleList")) {\r
+ simpleListMethodsCount = genType.getMethodDefinitions().size();\r
+ final List<MethodSignature> methods = genType.getMethodDefinitions();\r
+ for (final MethodSignature method : methods) {\r
+ if (method.getName().equals("getSimpleListKey")) {\r
+ getSimpleListKeyMethodCount++;\r
+ getSimpleListKeyMethodReturnTypeName = method.getReturnType().getName();\r
+ } else if (method.getName().equals("getListChildContainer")) {\r
+ getListChildContainerMethodCount++;\r
+ getListChildContainerMethodReturnTypeName = method.getReturnType().getName();\r
+ } else if (method.getName().equals("getFoo")) {\r
+ getFooMethodCount++;\r
+ } else if (method.getName().equals("setFoo")) {\r
+ setFooMethodCount++;\r
+ } else if (method.getName().equals("getSimpleLeafList")) {\r
+ getSimpleLeafListMethodCount++;\r
+ } else if (method.getName().equals("setSimpleLeafList")) {\r
+ setSimpleLeafListMethodCount++;\r
+ } else if (method.getName().equals("getBar")) {\r
+ getBarMethodCount++;\r
+ }\r
+ }\r
+ } else if (genType.getName().equals("ListChildContainer")) {\r
+ listChildContainerMethodsCount = genType.getMethodDefinitions().size();\r
+ }\r
+ } else if (type instanceof GeneratedTransferObject) {\r
+ final GeneratedTransferObject genTO = (GeneratedTransferObject) type;\r
+ final List<GeneratedProperty> properties = genTO.getProperties();\r
+ final List<GeneratedProperty> hashProps = genTO.getHashCodeIdentifiers();\r
+ final List<GeneratedProperty> equalProps = genTO.getEqualsIdentifiers();\r
+\r
+ listKeyClassCount++;\r
+ listKeyClassPropertyCount = properties.size();\r
+ listKeyClassPropertyName = properties.get(0).getName();\r
+ listKeyClassPropertyTypeName = properties.get(0).getReturnType().getName();\r
+ listKeyClassPropertyReadOnly = properties.get(0).isReadOnly();\r
+\r
+ hashMethodParameterCount = hashProps.size();\r
+ hashMethodParameterName = hashProps.get(0).getName();\r
+ hashMethodParameterReturnTypeName = hashProps.get(0).getReturnType().getName();\r
+\r
+ equalMethodParameterCount = equalProps.size();\r
+ equalMethodParameterName = equalProps.get(0).getName();\r
+ equalMethodParameterReturnTypeName = equalProps.get(0).getReturnType().getName();\r
+\r
+ }\r
+ }\r
+\r
+ assertEquals(1, listParentContainerMethodsCount);\r
+ assertEquals(1, listChildContainerMethodsCount);\r
+ assertEquals(1, getSimpleListKeyMethodCount);\r
+ assertEquals(1, listKeyClassCount);\r
+\r
+ assertEquals(1, listKeyClassPropertyCount);\r
+ assertEquals("ListKey", listKeyClassPropertyName);\r
+ assertEquals("Byte", listKeyClassPropertyTypeName);\r
+ assertEquals(true, listKeyClassPropertyReadOnly);\r
+ assertEquals(1, hashMethodParameterCount);\r
+ assertEquals("ListKey", hashMethodParameterName);\r
+ assertEquals("Byte", hashMethodParameterReturnTypeName);\r
+ assertEquals(1, equalMethodParameterCount);\r
+ assertEquals("ListKey", equalMethodParameterName);\r
+ assertEquals("Byte", equalMethodParameterReturnTypeName);\r
+\r
+ assertEquals("SimpleListKey", getSimpleListKeyMethodReturnTypeName);\r
+\r
+ assertEquals(1, getListChildContainerMethodCount);\r
+ assertEquals("ListChildContainer", getListChildContainerMethodReturnTypeName);\r
+ assertEquals(1, getFooMethodCount);\r
+ assertEquals(0, setFooMethodCount);\r
+ assertEquals(1, getSimpleLeafListMethodCount);\r
+ assertEquals(0, setSimpleLeafListMethodCount);\r
+ assertEquals(1, getBarMethodCount);\r
+\r
+ assertEquals(5, simpleListMethodsCount);\r
+ }\r
+\r
+ @Test\r
+ public void testListCompositeKeyResolving() {\r
+ final String filePath = getClass().getResource("/list-composite-key.yang").getPath();\r
+ final SchemaContext context = resolveSchemaContextFromFiles(filePath);\r
+\r
+ assertNotNull(context);\r
+\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context);\r
+\r
+ assertNotNull(genTypes);\r
+ assertEquals(7, genTypes.size());\r
+\r
+ int genTypesCount = 0;\r
+ int genTOsCount = 0;\r
+\r
+ int compositeKeyListKeyPropertyCount = 0;\r
+ int compositeKeyListKeyCount = 0;\r
+ int innerListKeyPropertyCount = 0;\r
+\r
+ for (final Type type : genTypes) {\r
+ if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {\r
+ genTypesCount++;\r
+ } else if (type instanceof GeneratedTransferObject) {\r
+ final GeneratedTransferObject genTO = (GeneratedTransferObject) type;\r
+\r
+ if (genTO.getName().equals("CompositeKeyListKey")) {\r
+ compositeKeyListKeyCount++;\r
+ final List<GeneratedProperty> properties = genTO.getProperties();\r
+ for (final GeneratedProperty prop : properties) {\r
+ if (prop.getName().equals("Key1")) {\r
+ compositeKeyListKeyPropertyCount++;\r
+ } else if (prop.getName().equals("Key2")) {\r
+ compositeKeyListKeyPropertyCount++;\r
+ }\r
+ }\r
+ genTOsCount++;\r
+ } else if (genTO.getName().equals("InnerListKey")) {\r
+ final List<GeneratedProperty> properties = genTO.getProperties();\r
+ innerListKeyPropertyCount = properties.size();\r
+ genTOsCount++;\r
+ }\r
+ }\r
+ }\r
+ assertEquals(1, compositeKeyListKeyCount);\r
+ assertEquals(2, compositeKeyListKeyPropertyCount);\r
+\r
+ assertEquals(1, innerListKeyPropertyCount);\r
+\r
+ assertEquals(5, genTypesCount);\r
+ assertEquals(2, genTOsCount);\r
+ }\r
+\r
+ @Test\r
+ public void testGeneratedTypes() {\r
+ final String filePath = getClass().getResource("/demo-topology.yang").getPath();\r
+ final SchemaContext context = resolveSchemaContextFromFiles(filePath);\r
+ assertNotNull(context);\r
+\r
+ final BindingGenerator bindingGen = new BindingGeneratorImpl();\r
+ final List<Type> genTypes = bindingGen.generateTypes(context);\r
+\r
+ assertNotNull(genTypes);\r
+ assertEquals(14, genTypes.size());\r
+\r
+ int genTypesCount = 0;\r
+ int genTOsCount = 0;\r
+ for (final Type type : genTypes) {\r
+ if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {\r
+ genTypesCount++;\r
+ } else if (type instanceof GeneratedTransferObject) {\r
+ genTOsCount++;\r
+ }\r
+ }\r
+\r
+ assertEquals(11, genTypesCount);\r
+ assertEquals(3, genTOsCount);\r
+ }\r
+}\r
final List<Type> genTypes = bindingGen.generateTypes(context);\r
\r
assertTrue(genTypes != null);\r
- assertEquals(8, genTypes.size());\r
+ assertEquals(7, genTypes.size());\r
\r
int genTypesCount = 0;\r
int genTOsCount = 0;\r
}\r
}\r
\r
- assertEquals(6, genTypesCount);\r
+ assertEquals(5, genTypesCount);\r
assertEquals(2, genTOsCount);\r
}\r
\r
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
+
+ <properties>
+ <yang.version>0.5.7-SNAPSHOT</yang.version>
+ </properties>
<modules>
<module>binding-model-api</module>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
- <version>${yang.version}</version>
+ <version>0.5.7-SNAPSHOT</version>
<executions>
<execution>
<goals>
<parent>
<artifactId>model-ietf</artifactId>
- <groupId>org.opendaylight.yangtools</groupId>
- <version>0.5.1-SNAPSHOT</version>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <version>0.5.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
+ <packaging>bundle</packaging>
</project>
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <artifactId>model-ietf</artifactId>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <version>0.5.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>ietf-ted</artifactId>
+ <version>2013.07.12-SNAPSHOT</version>
+ <name>${project.artifactId}</name>
+ <description>${project.artifactId}</description>
+
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-inet-types</artifactId>
+ <version>2010.09.24-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-yang-types</artifactId>
+ <version>2010.09.24-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+module ted {
+ yang-version 1;
+ namespace "urn:TBD:params:xml:ns:yang:network:ted";
+ // replace with IANA namespace when assigned
+ prefix ted;
+
+ import ietf-inet-types {
+ prefix inet;
+ }
+
+ organization "TBD";
+ contact
+ "TBD";
+ description
+ "Helper module to hold TED attributes for OSPF/ISIS";
+
+ revision 2013-07-12 {
+ description
+ "Initial revision";
+ }
+
+ typedef switching-capabilities {
+ description
+ "Switching Capabilities of an interface.";
+ reference
+ "RFC 5307: IS-IS Extensions in Support of Generalized
+ Multi-Protocol Label Switching (GMPLS)";
+ type enumeration {
+ enum "PSC-1" {
+ description
+ "Packet-Switch Capable-1 (PSC-1)";
+ value 1;
+ }
+ enum "PSC-2" {
+ description
+ "Packet-Switch Capable-2 (PSC-2)";
+ value 2;
+ }
+ enum "PSC-3" {
+ description
+ "Packet-Switch Capable-3 (PSC-3)";
+ value 3;
+ }
+ enum "PSC-4" {
+ description
+ "Packet-Switch Capable-4 (PSC-4)";
+ value 4;
+ }
+ enum "L2SC" {
+ description
+ "Layer-2 Switch Capable (L2SC)";
+ value 51;
+ }
+ enum "TDM" {
+ description
+ "Time-Division-Multiplex Capable (TDM)";
+ value 100;
+ }
+ enum "LSC" {
+ description
+ "Lambda-Switch Capable (LSC)";
+ value 150;
+ }
+ enum "FSC" {
+ description
+ "Fiber-Switch Capable (FSC)";
+ value 200;
+ }
+ }
+ }
+
+ typedef pcc-capabilities {
+ description
+ "Path Computation Capabilities.";
+ reference
+ "RFC 5088, draft-ietf-pce-disco-protoc-isis-07.txt
+ OSPF/ISIS Protocol Extensions for Path Computation Element (PCE) Discovery.";
+ type bits {
+ bit path-computation-with-gmpls-link-constraints {
+ position 0;
+ }
+ bit bidirectional-path-computation {
+ position 1;
+ }
+ bit diverse-path-computation {
+ position 2;
+ }
+ bit load-balanced-path-computation {
+ position 3;
+ }
+ bit synchronized-path-computation {
+ position 4;
+ }
+ bit support-for-multiple-objective-functions {
+ position 5;
+ }
+ bit support-for-additive-path-constraints {
+ position 6;
+ }
+ bit support-for-request-prioritization {
+ position 7;
+ }
+ bit support-for-multiple-requests-per-message {
+ position 8;
+ }
+ }
+ }
+
+
+grouping srlg-attributes {
+ description
+ "Shared Risk Link Group Attributes";
+ reference
+ "RFC 5307, RFC 4203: ISIS / OSPF Extensions in Support of
+ Generalized Multi-Protocol Label Switching (GMPLS)";
+ list interface-switching-capabilities {
+ description
+ "List of interface capabilities for this interface";
+ key "switching-capability";
+ leaf switching-capability {
+ description
+ "Switching Capability for this interface";
+ type ted:switching-capabilities;
+ }
+ leaf encoding {
+ description
+ "Encoding supported by this interface";
+ type uint8;
+ }
+ list max-lsp-bandwidth {
+ description
+ "Maximum LSP Bandwidth at priorities 0-7";
+ max-elements "8";
+ key "priority";
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ }
+ leaf bandwidth {
+ description
+ "Max LSP Bandwidth for this level";
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ }
+ container packet-switch-capable {
+ when "../switching-capability = PSC-1 or ../switching-capability = PSC-2 or ../switching-capability = PSC-3 or ../switching-capability = PSC-4";
+ description
+ "Interface has packet-switching capabilities";
+ leaf minimum-lsp-bandwidth {
+ description
+ "Minimum LSP Bandwidth. Units in bytes per second";
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ leaf interface-mtu {
+ description
+ "Interface MTU";
+ type uint16;
+ }
+ }
+ container time-division-multiplex-capable {
+ when "../switching-capability = TDM";
+ description
+ "Interface has time-division multiplex capabilities";
+ leaf minimum-lsp-bandwidth {
+ description
+ "Minimum LSP Bandwidth. Units in bytes per second";
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ leaf indication {
+ description
+ "Indication whether the interface supports Standard or Arbitrary SONET/SDH";
+ type uint16;
+ }
+ }
+ }
+ list srlg-values {
+ description
+ "List of Shared Risk Link Group this interface belongs to.";
+ key "srlg-value";
+ leaf srlg-value {
+ description
+ "Shared Risk Link Group value";
+ type uint32;
+ }
+ }
+ leaf link-protection-type {
+ description
+ "Link Protection Type desired for this link";
+ type uint16;
+ }
+ }
+
+ grouping ted-node-attributes {
+ description
+ "Identifier to uniquely identify a node in TED";
+ reference "RFC 5305, RFC 6119: IPv6 Traffic Engineering in IS-IS/OSPF";
+ leaf te-router-id-ipv4 {
+ description
+ "Globally unique IPv4 Traffic Engineering Router ID.";
+ type inet:ipv4-address;
+ }
+ leaf te-router-id-ipv6 {
+ description
+ "Globally unique IPv6 Traffic Engineering Router ID";
+ type inet:ipv6-address;
+ }
+ list ipv4-local-address {
+ description
+ "List of IPv4 Local Address(OSPF). RFC 5786";
+ key "ipv4-prefix";
+ leaf ipv4-prefix {
+ description
+ "Local IPv4 address for the node";
+ type inet:ipv4-prefix;
+ }
+ }
+ list ipv6-local-address {
+ description
+ "List of IPv6 Local Address.";
+ reference
+ "RFC 5786: Advertising a Router's Local Addresses
+ in OSPF Traffic Engineering (TE) Extensions";
+ key "ipv6-prefix";
+ leaf ipv6-prefix {
+ description
+ "Local IPv6 address for the node";
+ type inet:ipv6-prefix;
+ }
+ leaf prefix-option {
+ description
+ "IPv6 prefix option.";
+ type uint8;
+ }
+ }
+ leaf pcc-capabilities {
+ description
+ "OSPF/ISIS PCC capabilities";
+ type pcc-capabilities;
+ }
+ }
+
+ grouping ted-link-attributes {
+ description
+ "TED Attributes associated with the link.";
+ reference "RFC 3630, RFC 3784: IS-IS / OSPF Traffic Engineering (TE)";
+ leaf color {
+ description
+ "Administrative group or color of the link";
+ type uint32;
+ }
+ leaf max-link-bandwidth {
+ description
+ "Maximum bandwidth that can be see on this link in this direction. Units in bytes per second";
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ leaf max-resv-link-bandwidth {
+ description
+ "Maximum amount of bandwidth that can be reserved in this direction in this link. Units in bytes per second";
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ list unreserved-bandwidth {
+ description
+ "Unreserved bandwidth for 0-7 priority levels. Units in bytes per second";
+ max-elements "8";
+ key "priority";
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ }
+ leaf bandwidth {
+ description
+ "Unreserved bandwidth for this level";
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ }
+ leaf te-default-metric {
+ description
+ "Traffic Engineering Metric";
+ type uint32;
+ }
+ container srlg {
+ description
+ "Shared Risk Link Group Attributes";
+ uses srlg-attributes;
+ }
+ }
+}
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <artifactId>model-ietf</artifactId>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <version>0.5.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>ietf-topology-isis</artifactId>
+ <version>2013.07.12-SNAPSHOT</version>
+ <name>${project.artifactId}</name>
+ <description>${project.artifactId}</description>
+
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-topology-l3-unicast-igp</artifactId>
+ <version>2013.07.12-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-ted</artifactId>
+ <version>2013.07.12-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+
+</project>
--- /dev/null
+module isis-topology {
+ yang-version 1;
+ namespace "urn:TBD:params:xml:ns:yang:network:isis-topology";
+ // replace with IANA namespace when assigned
+ prefix "isis";
+ import network-topology {
+ prefix nt;
+ }
+ import l3-unicast-igp-topology {
+ prefix igp;
+ }
+ import ted {
+ prefix ted;
+ }
+
+ organization "TBD";
+ contact "TBD";
+ description "ISIS Topology model";
+
+ revision "2013-07-12" {
+ description "Initial version";
+ }
+ typedef iso-system-id {
+ description "ISO System ID. RFC 1237";
+ type string {
+ pattern '[0-9a-fA-F]{4}(.[0-9a-fA-F]{4}){2}';
+ }
+ }
+
+ typedef iso-pseudonode-id {
+ description "ISO pseudonode id for broadcast network";
+ type string {
+ pattern '[0-9a-fA-F]{2}';
+ }
+ }
+
+ typedef iso-net-id {
+ description "ISO NET ID. RFC 1237";
+ type string {
+ pattern '[0-9a-fA-F]{2}((.[0-9a-fA-F]{4}){6}*)';
+ }
+ }
+
+ grouping isis-topology-type {
+ container isis {
+ presence "Indicates ISIS Topology";
+ }
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:topology-types/igp:l3-unicast-igp-topology" {
+ uses isis-topology-type;
+ }
+
+ augment "/nt:network-topology/nt:topology/igp:igp-topology-attributes" {
+ when "../../topology-types/isis";
+ container isis-topogloy-attributes {
+ leaf net {
+ type iso-net-id;
+ }
+ }
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:node/igp:igp-node-attributes" {
+ when "../../../topology-types/isis";
+ uses isis-node-attributes;
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:link/igp:igp-link-attributes" {
+ when "../../../../topology-types/isis";
+ uses isis-link-attributes;
+ }
+
+ grouping isis-node-attributes {
+ container isis-node-attributes {
+ container iso {
+ leaf iso-system-id {
+ type iso-system-id;
+ }
+ leaf iso-pseudonode-id {
+ default "0";
+ type iso-pseudonode-id;
+ }
+ }
+ leaf-list net {
+ max-elements 3;
+ type iso-net-id;
+ }
+ leaf-list multi-topology-id {
+ description "List of Multi Topology Identifier upto 128 (0-127). RFC 4915";
+ max-elements "128";
+ type uint8 {
+ range "0..127";
+ }
+ }
+ choice router-type {
+ case level-2 {
+ leaf level-2 {
+ type empty;
+ }
+ }
+ case level-1 {
+ leaf level-1 {
+ type empty;
+ }
+ }
+ case level-1-2 {
+ leaf level-1-2 {
+ type empty;
+ }
+ }
+ }
+ container ted {
+ uses ted:ted-node-attributes;
+ }
+ }
+ }
+
+ grouping isis-link-attributes {
+ container isis-link-attributes {
+ leaf multi-topology-id {
+ type uint8 {
+ range "0..127";
+ }
+ }
+ container ted {
+ uses ted:ted-link-attributes;
+ }
+ }
+ }
+ /*
+ augment "/igp:igp-node-event" {
+ uses isis-topology-type;
+ uses isis-node-attributes;
+ }
+
+ augment "/igp:igp-link-event" {
+ uses isis-topology-type;
+ uses isis-link-attributes;
+ }*/
+} // Module isis-topology
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <artifactId>model-ietf</artifactId>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <version>0.5.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>ietf-topology-l3-unicast-igp</artifactId>
+ <version>2013.07.12-SNAPSHOT</version>
+ <name>${project.artifactId}</name>
+ <description>${project.artifactId}</description>
+
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-topology</artifactId>
+ <version>2013.07.12-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+module l3-unicast-igp-topology {
+ yang-version 1;
+ namespace "urn:TBD:params:xml:ns:yang:nt:l3-unicast-igp-topology";
+ // replace with IANA namespace when assigned
+ prefix "l3t";
+ import network-topology {
+ prefix "nt";
+ }
+
+ import ietf-inet-types {
+ prefix "inet";
+ }
+
+ organization "TBD";
+ contact "TBD";
+
+ revision "2013-07-12" {
+ description "Initial revision";
+ reference "TBD";
+ }
+
+ typedef igp-event-type {
+ description "IGP Event type for notifications";
+ type enumeration {
+ enum "add" {
+ value 0;
+ description "An IGP node or link or prefix or termination-point has been added";
+ }
+ enum "remove" {
+ value 1;
+ description "An IGP node or link or prefix or termination-point has been removed";
+ }
+ enum "update" {
+ value 2;
+ description "An IGP node or link or prefix or termination-point has been updated";
+ }
+ }
+ } // igp-event-type
+
+ identity flag-identity {
+ description "Base type for flags";
+ }
+ identity undefined-flag {
+ base "flag-identity";
+ }
+
+ typedef flag-type {
+ type identityref {
+ base "flag-identity";
+ }
+ }
+
+ grouping igp-prefix-attributes {
+ leaf prefix {
+ type inet:ip-prefix;
+ }
+ leaf metric {
+ type uint32;
+ }
+ leaf-list flag {
+ type flag-type;
+ }
+ }
+
+ grouping l3-unicast-igp-topology-type {
+ container l3-unicast-igp-topology {
+ presence "indicates L3 Unicast IGP Topology";
+ }
+ }
+
+ grouping igp-topology-attributes {
+ container igp-topology-attributes {
+ leaf name {
+ description "Name of the topology";
+ type string;
+ }
+ leaf-list flag {
+ description "Topology flags";
+ type flag-type;
+ }
+ }
+ }
+
+ grouping igp-node-attributes {
+ container igp-node-attributes {
+ leaf name {
+ description "Node name";
+ type inet:domain-name;
+ }
+ leaf-list flag {
+ description "Node operational flags";
+ type flag-type;
+ }
+
+ leaf-list router-id {
+ description "Router-id for the node";
+ type inet:ip-address;
+ }
+
+ list prefix {
+ key "prefix";
+ uses igp-prefix-attributes;
+ }
+ }
+ }
+
+ grouping igp-link-attributes {
+ container igp-link-attributes {
+ leaf name {
+ description "Link Name";
+ type string;
+ }
+ leaf-list flag {
+ description "Link flags";
+ type flag-type;
+ }
+ leaf metric {
+ description "Link Metric";
+ type uint32 {
+ range "0..16777215" {
+ description "
+ ";
+ // OSPF/ISIS supports max 3 byte metric.
+ // Ideally we would like this restriction to be
+ // defined in the derived models, however,
+ // we are not allowed to augment a "must" statement.
+ }
+ }
+ }
+ }
+ } // grouping igp-link-attributes
+
+ grouping igp-termination-point-attributes {
+ container igp-termination-point-attributes {
+ choice termination-point-type {
+ case ip {
+ leaf-list ip-address {
+ description "IPv4 or IPv6 address";
+ type inet:ip-address;
+ }
+ }
+ case unnumbered {
+ leaf unnumbered-id {
+ description "Unnumbered interface identifier";
+ type uint32;
+ }
+ }
+ }
+ }
+ } // grouping igp-termination-point-attributes
+
+
+ augment "/nt:network-topology/nt:topology/nt:topology-types" {
+ uses l3-unicast-igp-topology-type;
+ }
+
+
+ augment "/nt:network-topology/nt:topology" {
+ when "topology-types/l3-unicast-igp-topology";
+ uses igp-topology-attributes;
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:node" {
+ when "../../topology-types/l3-unicast-igp-topology";
+ uses igp-node-attributes;
+ }
+
+
+ augment "/nt:network-topology/nt:topology/nt:link" {
+ when "../../topology-types/l3-unicast-igp-topology";
+ uses igp-link-attributes;
+ }
+ augment "/nt:network-topology/nt:topology/nt:node/nt:termination-point" {
+ when "../../topology-types/l3-unicast-igp-topology";
+ uses igp-termination-point-attributes;
+ }
+
+ notification igp-node-event {
+ leaf igp-event-type {
+ type igp-event-type;
+ }
+ leaf topology-ref {
+ type nt:topology-ref;
+ }
+ uses l3-unicast-igp-topology-type;
+ uses nt:node-attributes;
+ uses igp-node-attributes;
+ }
+
+ notification igp-link-event {
+ leaf igp-event-type {
+ type igp-event-type;
+ }
+ leaf topology-ref {
+ type nt:topology-ref;
+ }
+ uses l3-unicast-igp-topology-type;
+ uses nt:link-attributes;
+ uses igp-link-attributes;
+ }
+
+ notification igp-prefix-event {
+ leaf igp-event-type {
+ type igp-event-type;
+ }
+ leaf topology-ref {
+ type nt:topology-ref;
+ }
+ leaf node-ref {
+ type nt:node-ref;
+ }
+ uses l3-unicast-igp-topology-type;
+ container prefix {
+ uses igp-prefix-attributes;
+ }
+ }
+
+ notification termination-point-event {
+ leaf igp-event-type {
+ type igp-event-type;
+ }
+ leaf topology-ref {
+ type nt:topology-ref;
+ }
+ leaf node-ref {
+ type nt:node-ref;
+ }
+ uses l3-unicast-igp-topology-type;
+ uses nt:tp-attributes;
+ uses igp-termination-point-attributes;
+ }
+}
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <artifactId>model-ietf</artifactId>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <version>0.5.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>ietf-topology-ospf</artifactId>
+ <version>2013.07.12-SNAPSHOT</version>
+ <name>${project.artifactId}</name>
+ <description>${project.artifactId}</description>
+
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>model-l3-unicast-igp-topology</artifactId>
+ <version>2013.07.12-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>model-ted</artifactId>
+ <version>2013.07.12-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+
+</project>
--- /dev/null
+ňmodule ospf-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:ospf-topology";
+ // replace with IANA namespace when assigned
+ prefix "ospf";
+
+ import network-topology {
+ prefix "nt";
+ }
+
+ import l3-unicast-igp-topology {
+ prefix "igp";
+ }
+ import ietf-inet-types {
+ prefix "inet";
+ }
+ import ted {
+ prefix "ted";
+ }
+
+ organization "TBD";
+ contact "TBD";
+ description "OSPF Topology model";
+
+ revision "2013-07-12" {
+ description "Initial revision";
+ reference "TBD";
+ }
+
+ typedef area-id {
+ description "OSPF Area ID";
+ type uint32;
+ }
+
+ grouping ospf-topology-type {
+ container ospf {
+ presence "indiates OSPF Topology";
+ }
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:topology-types/igp:l3-unicast-igp-topology" {
+ uses ospf-topology-type;
+ }
+
+ augment "/nt:network-topology/nt:topology/igp:igp-topology-attributes" {
+ when "../topology-types/ospf";
+ container ospf-topology-attributes {
+ leaf area-id {
+ type area-id;
+ }
+ }
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:node/igp:igp-node-attributes" {
+ when "../../../topology-types/ospf";
+ uses ospf-node-attributes;
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:link/igp:igp-link-attributes" {
+ when "../../../topology-types/ospf";
+ uses ospf-link-attributes;
+ }
+
+ augment "/nt:network-topology/nt:topology/nt:node/igp:igp-node-attributes/igp:prefix" {
+ when "../../../../topology-types/ospf";
+ uses ospf-prefix-attributes;
+ }
+
+ grouping ospf-node-attributes {
+ container ospf-node-attributes {
+ choice router-type {
+ case abr {
+ leaf abr {
+ type empty;
+ }
+ }
+ case asbr {
+ leaf asbr {
+ type empty;
+ }
+ }
+ case internal {
+ leaf internal {
+ type empty;
+ }
+ }
+ case pseudonode {
+ leaf pseudonode {
+ type empty;
+ }
+ }
+ }
+ leaf dr-interface-id {
+ when "../router-type/pseudonode";
+ description "For pseudonodes, DR interface-id";
+ default "0";
+ type uint32;
+ }
+ leaf-list multi-topology-id {
+ description "List of Multi-Topology Identifier up-to 128 (0-127). RFC 4915";
+ max-elements "128";
+ type uint8 {
+ range "0..127";
+ }
+ }
+ leaf capabilities {
+ description "OSPF capabilities as bit vector. RFC 4970";
+ type bits {
+ bit graceful-restart-capable {
+ position 0;
+ }
+ bit graceful-restart-helper {
+ position 1;
+ }
+ bit stub-router-support {
+ position 2;
+ }
+ bit traffic-engineering-support {
+ position 3;
+ }
+ bit point-to-point-over-lan {
+ position 4;
+ }
+ bit experimental-te {
+ position 5;
+ }
+ }
+ }
+ container ted {
+ uses ted:ted-node-attributes;
+ }
+ } // ospf
+ } // ospf-node-attributes
+
+ grouping ospf-link-attributes {
+ container ospf-link-attributes {
+ leaf multi-topology-id {
+ type uint8 {
+ range "0..127";
+ }
+ }
+ container ted {
+ uses ted:ted-link-attributes;
+ }
+ }
+ } // ospf-link-attributes
+
+ grouping ospf-prefix-attributes {
+ container ospf-prefix-attributes {
+ leaf forwarding-address {
+ when "../../igp:l3-unicast-igp-topology/igp:ospf/igp:router-type/igp:asbr";
+ type inet:ipv4-address;
+ }
+ }
+ }
+
+ /*
+ augment "/igp:igp-node-event" {
+ uses ospf-topology-type;
+ uses ospf:ospf-node-attributes;
+ }
+
+ augment "/igp:igp-link-event" {
+ uses ospf-topology-type;
+ uses ospf:ospf-link-attributes;
+ }
+
+ augment "/igp:igp-prefix-event" {
+ uses ospf-topology-type;
+ uses ospf:ospf-prefix-attributes;
+ }
+ */
+}
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <parent>
+ <artifactId>model-ietf</artifactId>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <version>0.5.7-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>ietf-topology</artifactId>
+ <version>2013.07.12-SNAPSHOT</version>
+ <name>${project.artifactId}</name>
+ <description>${project.artifactId}</description>
+
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-inet-types</artifactId>
+ <version>2010.09.24-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <artifactId>ietf-yang-types</artifactId>
+ <version>2010.09.24-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+module network-topology {
+ yang-version 1;
+ namespace "urn:TBD:params:xml:ns:yang:network-topology";
+ // replace with IANA namespace when assigned
+ prefix "nt";
+
+ import ietf-inet-types { prefix "inet"; }
+
+ organization "TBD";
+
+ contact "WILL-BE-DEFINED-LATER";
+/*
+ description
+ "This module defines a model for the topology of a network.
+ Key design decisions are as follows:
+ A topology consists of a set of nodes and links.
+ Links are point-to-point and unidirectional.
+ Bidirectional connections need to be represented through
+ two separate links.
+ Multipoint connections, broadcast domains etc can be represented
+ through a hierarchy of nodes, then connecting nodes at
+ upper layers of the hierarchy.";
+*/
+ revision 2013-07-12 {
+ description
+ "Initial revision.";
+ }
+
+ typedef topology-id {
+ type inet:uri;
+ description
+ "An identifier for a topology.";
+ }
+
+ typedef node-id {
+ type inet:uri;
+ description
+ "An identifier for a node in a topology.
+ The identifier may be opaque.
+ The identifier SHOULD be chosen such that the same node in a
+ real network topology will always be identified through the
+ same identifier, even if the model is instantiated in separate
+ datastores. An implementation MAY choose to capture semantics
+ in the identifier, for example to indicate the type of node
+ and/or the type of topology that the node is a part of.";
+ }
+
+ typedef link-id {
+ type inet:uri;
+ description
+ "An identifier for a link in a topology.
+ The identifier may be opaque.
+ The identifier SHOULD be chosen such that the same link in a
+ real network topology will always be identified through the
+ same identifier, even if the model is instantiated in separate
+ datastores. An implementation MAY choose to capture semantics
+ in the identifier, for example to indicate the type of link
+ and/or the type of topology that the link is a part of.";
+ }
+
+ typedef tp-id {
+ type inet:uri;
+ description
+ "An identifier for termination points on a node.
+ The identifier may be opaque.
+ The identifier SHOULD be chosen such that the same TP in a
+ real network topology will always be identified through the
+ same identifier, even if the model is instantiated in separate
+ datastores. An implementation MAY choose to capture semantics
+ in the identifier, for example to indicate the type of TP
+ and/or the type of node and topology that the TP is a part of.";
+ }
+
+ typedef tp-ref {
+ type leafref {
+ path "/network-topology/topology/node/termination-point/tp-id";
+ }
+ description
+ "A type for an absolute reference to a termination point.
+ (This type should not be used for relative references.
+ In such a case, a relative path should be used instead.)";
+ }
+ typedef topology-ref {
+ type leafref {
+ path "/network-topology/topology/topology-id";
+ }
+ description
+ "A type for an absolute reference a topology instance.";
+ }
+
+ typedef node-ref {
+ type leafref {
+ path "/network-topology/topology/node/node-id";
+ }
+ description
+ "A type for an absolute reference to a node instance.
+ (This type should not be used for relative references.
+ In such a case, a relative path should be used instead.)";
+ }
+
+ typedef link-ref {
+ type leafref {
+ path "/network-topology/topology/link/link-id";
+ }
+ description
+ "A type for an absolute reference a link instance.
+ (This type should not be used for relative references.
+ In such a case, a relative path should be used instead.)";
+ }
+
+ grouping tp-attributes {
+ description
+ "The data objects needed to define a termination point.
+ (This only includes a single leaf at this point, used
+ to identify the termination point.)
+ Provided in a grouping so that in addition to the datastore,
+ the data can also be included in notifications.";
+ leaf tp-id {
+ type tp-id;
+ }
+ leaf-list tp-ref {
+ type tp-ref;
+ config false;
+ description
+ "The leaf list identifies any termination points that the
+ termination point is dependent on, or maps onto.
+ Those termination points will themselves be contained
+ in a supporting node.
+ This dependency information can be inferred from
+ the dependencies between links. For this reason,
+ this item is not separately configurable. Hence no
+ corresponding constraint needs to be articulated.
+ The corresponding information is simply provided by the
+ implementing system.";
+ }
+ }
+
+ grouping node-attributes {
+ description
+ "The data objects needed to define a node.
+ The objects are provided in a grouping so that in addition to
+ the datastore, the data can also be included in notifications
+ as needed.";
+ leaf node-id {
+ type node-id;
+ description
+ "The identifier of a node in the topology.
+ A node is specific to a topology to which it belongs.";
+ }
+ list supporting-node {
+ description
+ "This list defines vertical layering information for nodes.
+ It allows to capture for any given node, which node (or nodes)
+ in the corresponding underlay topology it maps onto.
+ A node can map to zero, one, or more nodes below it;
+ accordingly there can be zero, one, or more elements in the list.
+ If there are specific layering requirements, for example
+ specific to a particular type of topology that only allows
+ for certain layering relationships, the choice
+ below can be augmented with additional cases.
+ A list has been chosen rather than a leaf-list in order
+ to provide room for augmentations, e.g. for
+ statistics or priorization information associated with
+ supporting nodes.";
+ key "node-ref";
+ leaf node-ref {
+ type node-ref;
+ }
+ }
+ }
+
+ grouping link-attributes {
+ // This is a grouping, not defined inline with the link definition itself,
+ // so it can be included in a notification, if needed
+ leaf link-id {
+ type link-id;
+ description
+ "The identifier of a link in the topology.
+ A link is specific to a topology to which it belongs.";
+ }
+ container source {
+ leaf source-node {
+ mandatory true;
+ type node-ref;
+ description
+ "Source node identifier, must be in same topology.";
+ }
+ leaf source-tp {
+ type tp-ref;
+ description
+ "Termination point within source node that terminates the link.";
+ }
+ }
+ container destination {
+ leaf dest-node {
+ mandatory true;
+ type node-ref;
+ description
+ "Destination node identifier, must be in same topology.";
+ }
+ leaf dest-tp {
+ type tp-ref;
+ description
+ "Termination point within destination node that terminates the link.";
+ }
+ }
+ list supporting-link {
+ key "link-ref";
+ leaf link-ref {
+ type link-ref;
+ }
+ }
+ }
+
+
+ container network-topology {
+ list topology {
+ description "
+ This is the model of an abstract topology.
+ A topology contins nodes and links.
+ Each topology MUST be identified by
+ unique topology-id for reason that a network could contain many
+ topologies.
+ ";
+ key "topology-id";
+ leaf topology-id {
+ type topology-id;
+ description "
+ It is presumed that a datastore will contain many topologies. To
+ distinguish between topologies it is vital to have UNIQUE
+ topology identifiers.
+ ";
+ }
+ container topology-types {
+ description
+ "This container is used to identify the type, or types
+ (as a topology can support several types simultaneously),
+ of the topology.
+ Topology types are the subject of several integrity constraints
+ that an implementing server can validate in order to
+ maintain integrity of the datastore.
+ Topology types are indicated through separate data nodes;
+ the set of topology types is expected to increase over time.
+ To add support for a new topology, an augmenting module
+ needs to augment this container with a new empty optional
+ container to indicate the new topology type.
+ The use of a container allows to indicate a subcategorization
+ of topology types.
+ The container SHALL NOT be augmented with any data nodes
+ that serve a purpose other than identifying a particular
+ topology type.
+ ";
+ }
+ list underlay-topology {
+ key "topology-ref";
+ leaf topology-ref {
+ type topology-ref;
+ }
+ // a list, not a leaf-list, to allow for potential augmentation
+ // with properties specific to the underlay topology,
+ // such as statistics, preferences, or cost.
+ description
+ "Identifies the topology, or topologies, that this topology
+ is dependent on.";
+ }
+
+ list node {
+ description "The list of network nodes defined for the topology.";
+ key "node-id";
+ uses node-attributes;
+ must "boolean(../underlay-topology[*]/node[./supporting-nodes/node-ref])";
+ // This constraint is meant to ensure that a referenced node is in fact
+ // a node in an underlay topology.
+ list termination-point {
+ description
+ "A termination point can terminate a link.
+ Depending on the type of topology, a termination point could,
+ for example, refer to a port or an interface.";
+ key "tp-id";
+ uses tp-attributes;
+ }
+ }
+
+ list link {
+ description "
+ A Network Link connects a by Local (Source) node and
+ a Remote (Destination) Network Nodes via a set of the
+ nodes' termination points.
+ As it is possible to have several links between the same
+ source and destination nodes, and as a link could potentially
+ be re-homed between termination points, to ensure that we
+ would always know to distinguish between links, every link
+ is identified by a dedicated link identifier.
+ Note that a link models a point-to-point link, not a multipoint
+ link.
+ Layering dependencies on links in underlay topologies are
+ not represented as the layering information of nodes and of
+ termination points is sufficient.
+ ";
+ key "link-id";
+ uses link-attributes;
+ must "boolean(../underlay-topology/link[./supporting-link]";
+ // Constraint: any supporting link must be part of an underlay topology
+ must "boolean(../node[./source/source-node])";
+ // Constraint: A link must have as source a node of the same topology
+ must "boolean(../node[./destination/dest-node])";
+ // Constraint: A link must have as source a destination of the same topology
+ must "boolean(../node/termination-point[./source/source-tp])";
+ // Constraint: The source termination point must be contained in the source node
+ must "boolean(../node/termination-point[./destination/dest-tp])";
+ // Constraint: The destination termination point must be contained
+ // in the destination node
+ }
+ }
+ }
+}
<parent>
<artifactId>model-ietf</artifactId>
- <groupId>org.opendaylight.yangtools</groupId>
- <version>0.5.1-SNAPSHOT</version>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <version>0.5.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
+ <packaging>bundle</packaging>
</project>
<parent>
<artifactId>model-parent</artifactId>
- <groupId>org.opendaylight.yangtools</groupId>
- <version>0.5.1-SNAPSHOT</version>
+ <groupId>org.opendaylight.yangtools.model</groupId>
+ <version>0.5.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<modules>
<module>ietf-inet-types</module>
<module>ietf-yang-types</module>
+ <module>ietf-ted</module>
+ <module>ietf-topology</module>
+ <!--
+ <module>ietf-topology-l3-unicast-igp</module>
+ <module>ietf-topology-isis</module>
+ <module>ietf-topology-ospf</module>
+ -->
</modules>
-
</project>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>model-parent</artifactId>
- <groupId>org.opendaylight.yangtools</groupId>
- <version>0.5.1-SNAPSHOT</version>
- </parent>
- <artifactId>model-openflow</artifactId>
-</project>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>model-parent</artifactId>
- <groupId>org.opendaylight.yangtools</groupId>
- <version>0.5.1-SNAPSHOT</version>
- </parent>
- <artifactId>model-topology-bgp</artifactId>
-</project>
+++ /dev/null
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <artifactId>model-parent</artifactId>
- <groupId>org.opendaylight.yangtools</groupId>
- <version>0.5.1-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>model-topology</artifactId>
-
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>ietf-inet-types</artifactId>
- <version>2010.09.24-SNAPSHOT</version>
- </dependency>
- </dependencies>
-
-</project>
+++ /dev/null
-module topology {
- yang-version 1;
- namespace "urn:ietf:params:xml:ns:yang:topology";
- prefix "tp";
-
- import ietf-inet-types { prefix "inet"; }
-
- organization "TBD";
-
- contact "WILL-BE-DEFINED-LATER";
-
- description "";
-
- revision 2013-06-11 {
- description "Updated model with review comments.
- Removed top-level container network.
- Moved network elements to separate module.";
- }
-
- typedef topology-id {
- type inet:uri;
- }
-
- typedef node-id {
- description "Node abstract identifier, schema for URI will be defined by augmentation";
- type inet:uri;
- }
-
- typedef link-id {
- description "Node abstract identifier, schema for URI will be defined by augmentation";
- type inet:uri;
- }
-
- typedef tp-id {
- type inet:uri;
- description "identifier for termination points on a port";
- }
-
- typedef tp-ref {
- type leafref {
- path "/topologies/topology/nodes/node/termination-points/termination-point/tp-id";
- }
- }
- typedef topology-ref {
- type leafref {
- path "/topologies/topology/topology-id";
- }
- description "This type is used for leafs that reference topology identifier instance.";
- // currently not used
- }
-
- typedef node-ref {
- type leafref {
- path "/topologies/topology/nodes/node/node-id";
- }
- description "This type is used for leafs that reference a node instance.";
- }
-
- typedef link-ref {
- type leafref {
- path "/topologies/topology/links/link/link-id";
- }
- description "This type is used for leafs that reference a link instance.";
- // currently not used
- }
-
- container topologies {
- list topology {
- description "
- This is the model of abstract topology which contains only Network
- Nodes and Network Links. Each topology MUST be identified by
- unique topology-id for reason that the store could contain many
- topologies.
- ";
- key "topology-id";
- leaf topology-id {
- type topology-id;
- description "
- It is presumed that datastore will contain many topologies. To
- distinguish between topologies it is vital to have UNIQUE
- topology identifier.
- ";
- }
-
- container types {
- description "
- The container for definition of topology types.
- The augmenting modules should add empty optional leaf
- to this container to signalize topology type.
- ";
- }
-
- container nodes {
- list node {
- description "The list of network nodes defined for topology.";
-
- key "node-id";
- leaf node-id {
- type node-id;
- description "The Topology identifier of network-node.";
- }
-
- //leaf supporting-ne {
- // type network-element-ref;
- //}
-
- container termination-points {
- list termination-point {
- key "tp-id";
- leaf tp-id {
- type tp-id;
- }
- }
- }
- }
- }
-
- container links {
- list link {
- description "
- The Network Link which is defined by Local (Source) and
- Remote (Destination) Network Nodes. Every link MUST be
- defined either by identifier and his local and remote
- Network Nodes (in real applications it is common that many
- links are originated from one node and end up in same
- remote node). To ensure that we would always know to
- distinguish between links, every link SHOULD have
- identifier.
- ";
- key "link-id";
-
- leaf link-id {
- type link-id;
- description "";
- }
-
- container source {
- leaf source-node {
- type node-ref;
- description "Source node identifier.";
- }
- leaf source-tp {
- type tp-ref;
- }
- }
-
- container destination {
- leaf dest-node {
- type node-ref;
- description "Destination node identifier.";
- }
- leaf dest-tp {
- type tp-ref;
- }
- }
- }
- }
- }
- }
-}
</parent>
<modelVersion>4.0.0</modelVersion>
+ <groupId>org.opendaylight.yangtools.model</groupId>
<artifactId>model-parent</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.5.7-SNAPSHOT</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<description>${project.artifactId}</description>
+ <properties>
+ <yang.version>0.5.7-SNAPSHOT</yang.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <maven.bundle.version>2.4.0</maven.bundle.version>
+ </properties>
+
<modules>
<module>ietf</module>
- <module>model-topology</module>
- <module>model-openflow</module>
<!-- <module>model-topology-bgp</module> -->
</modules>
<build>
<plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${maven.bundle.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+ </instructions>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-maven-plugin</artifactId>
</properties>
<modules>
+ <module>yang</module>
<module>code-generator</module>
<module>model</module>
- <module>yang</module>
</modules>
<dependencyManagement>
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang</artifactId>
- <version>0.5.7-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>yang-ext</artifactId>
- <version>2013.09.07-SNAPSHOT</version>
- <name>${project.artifactId}</name>
- <description>${project.artifactId}</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-maven-plugin</artifactId>
- <version>${yang.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>generate-sources</goal>
- </goals>
- <configuration>
- <yangFilesRootDir>src/main/yang</yangFilesRootDir>
- <codeGenerators>
- </codeGenerators>
- <inspectDependencies>false</inspectDependencies>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
-
- <pluginManagement>
- <plugins>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.7</version>
- <executions>
- <execution>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>target/generated-sources/sal</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <!--This plugin's configuration is used to store Eclipse
- m2e settings only. It has no influence on the Maven build itself. -->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>
- org.opendaylight.yangtools
- </groupId>
- <artifactId>
- yang-maven-plugin
- </artifactId>
- <versionRange>
- [0.5.7,)
- </versionRange>
- <goals>
- <goal>
- generate-sources
- </goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore></ignore>
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
-</project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+\r
+ <parent>\r
+ <groupId>org.opendaylight.yangtools</groupId>\r
+ <artifactId>yang</artifactId>\r
+ <version>0.5.7-SNAPSHOT</version>\r
+ </parent>\r
+\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <artifactId>yang-ext</artifactId>\r
+ <version>2013.09.07-SNAPSHOT</version>\r
+ <name>${project.artifactId}</name>\r
+ <description>${project.artifactId}</description>\r
+\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.opendaylight.yangtools</groupId>\r
+ <artifactId>yang-maven-plugin</artifactId>\r
+ <version>${parent.version}</version>\r
+ <executions>\r
+ <execution>\r
+ <goals>\r
+ <goal>generate-sources</goal>\r
+ </goals>\r
+ <configuration>\r
+ <yangFilesRootDir>src/main/yang</yangFilesRootDir>\r
+ <codeGenerators>\r
+ </codeGenerators>\r
+ <inspectDependencies>false</inspectDependencies>\r
+ </configuration>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ </plugins>\r
+\r
+ <pluginManagement>\r
+ <plugins>\r
+\r
+ <plugin>\r
+ <groupId>org.codehaus.mojo</groupId>\r
+ <artifactId>build-helper-maven-plugin</artifactId>\r
+ <version>1.7</version>\r
+ <executions>\r
+ <execution>\r
+ <phase>generate-sources</phase>\r
+ <goals>\r
+ <goal>add-source</goal>\r
+ </goals>\r
+ <configuration>\r
+ <sources>\r
+ <source>target/generated-sources/sal</source>\r
+ </sources>\r
+ </configuration>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
+ <!--This plugin's configuration is used to store Eclipse \r
+ m2e settings only. It has no influence on the Maven build itself. -->\r
+ <plugin>\r
+ <groupId>org.eclipse.m2e</groupId>\r
+ <artifactId>lifecycle-mapping</artifactId>\r
+ <version>1.0.0</version>\r
+ <configuration>\r
+ <lifecycleMappingMetadata>\r
+ <pluginExecutions>\r
+ <pluginExecution>\r
+ <pluginExecutionFilter>\r
+ <groupId>\r
+ org.opendaylight.yangtools\r
+ </groupId>\r
+ <artifactId>\r
+ yang-maven-plugin\r
+ </artifactId>\r
+ <versionRange>\r
+ [0.5,)\r
+ </versionRange>\r
+ <goals>\r
+ <goal>\r
+ generate-sources\r
+ </goal>\r
+ </goals>\r
+ </pluginExecutionFilter>\r
+ <action>\r
+ <ignore></ignore>\r
+ </action>\r
+ </pluginExecution>\r
+ </pluginExecutions>\r
+ </lifecycleMappingMetadata>\r
+ </configuration>\r
+ </plugin>\r
+ </plugins>\r
+ </pluginManagement>\r
+ </build>\r
+\r
+</project>\r
<groupId>org.slf4j</groupId>\r
<artifactId>slf4j-simple</artifactId>\r
<version>1.7.2</version>\r
+ <scope>test</scope>\r
</dependency>\r
<dependency>\r
<groupId>org.mockito</groupId>\r
<artifactId>mockito-all</artifactId>\r
<version>1.8.4</version>\r
+ <scope>test</scope>\r
</dependency>\r
<dependency>\r
<groupId>com.google.guava</groupId>\r
nextModule = allModulesIterator.next();
resolveAugment(modules, nextModule);
} catch (NoSuchElementException e) {
+
+
throw new YangParseException("Failed to resolve augments in module '" + module.getName() + "'.", e);
}
// then try to resolve first module again