[ONOS-5878] schema context provider impl
Change-Id: Ib93ca69d659fe700cd4270035dae8cece1b23b88
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/DefaultYangNamespace.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/DefaultYangNamespace.java
new file mode 100644
index 0000000..4fd27da
--- /dev/null
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/DefaultYangNamespace.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.datamodel;
+
+/**
+ * Represents YANG node identifier's namespace.
+ */
+public class DefaultYangNamespace implements YangNamespace {
+
+ /*
+ * Reference for namespace.
+ */
+ private final String namespace;
+
+ /**
+ * Creates an instance of namespace which is used to initialize the
+ * nameSpace for requested YDT node.
+ *
+ * @param ns namespace of the requested node
+ */
+ public DefaultYangNamespace(String ns) {
+ namespace = ns;
+ }
+
+ @Override
+ public String getModuleNamespace() {
+ return namespace;
+ }
+
+ @Override
+ public String getModuleName() {
+ return namespace;
+ }
+}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/SchemaDataNode.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/SchemaDataNode.java
new file mode 100644
index 0000000..bd294b2
--- /dev/null
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/SchemaDataNode.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.datamodel;
+
+/**
+ * Abstraction of an entity that represents schema node which are also
+ * data nodes.
+ */
+public interface SchemaDataNode {
+
+}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangAugment.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangAugment.java
index e7e36c2..3179a73 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangAugment.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangAugment.java
@@ -25,6 +25,7 @@
import java.util.List;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentSchemaContext;
/*-
* Reference RFC 6020.
@@ -409,6 +410,18 @@
}
}
+ @Override
+ public void setLeafParentContext() {
+ // Add parent context for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setParentContext(getParentSchemaContext(this));
+ }
+ // Add parent context for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setParentContext(getParentSchemaContext(this));
+ }
+ }
+
/**
* Returns the textual reference.
*
@@ -525,7 +538,6 @@
@Override
public void setResolvableStatus(ResolvableStatus resolvableStatus) {
this.resolvableStatus = resolvableStatus;
-
}
@Override
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangCase.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangCase.java
index c2e1a01..d6621c5 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangCase.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangCase.java
@@ -33,6 +33,7 @@
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.getErrorMsg;
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.getErrorMsgCollision;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentSchemaContext;
import static org.onosproject.yang.compiler.datamodel.utils.YangConstructType.CASE_DATA;
/*-
@@ -105,7 +106,8 @@
public abstract class YangCase
extends YangNode
implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector,
- YangAugmentableNode, YangWhenHolder, YangIfFeatureHolder, YangIsFilterContentNodes {
+ YangAugmentableNode, YangWhenHolder, YangIfFeatureHolder,
+ YangIsFilterContentNodes {
private static final long serialVersionUID = 806201603L;
@@ -461,6 +463,17 @@
}
}
+ @Override
+ public void setLeafParentContext() {
+ // Add parent context for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setParentContext(getParentSchemaContext(this));
+ }
+ // Add parent context for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setParentContext(getParentSchemaContext(this));
+ }
+ }
public void cloneAugmentInfo() {
yangAugmentedInfo = new ArrayList<>();
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangContainer.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangContainer.java
index 66f0190..abf6652 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangContainer.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangContainer.java
@@ -19,13 +19,22 @@
import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
import org.onosproject.yang.compiler.datamodel.utils.Parsable;
import org.onosproject.yang.compiler.datamodel.utils.YangConstructType;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.SchemaContext;
+import org.onosproject.yang.model.SchemaId;
+import org.onosproject.yang.model.SingleInstanceNodeContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.FMT_NOT_EXIST;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.errorMsg;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getNodeIdFromSchemaId;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentSchemaContext;
/*-
* Reference RFC 6020.
@@ -93,7 +102,7 @@
extends YangNode
implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector,
YangAugmentableNode, YangMustHolder, YangWhenHolder, YangIfFeatureHolder, YangIsFilterContentNodes,
- YangConfig {
+ YangConfig, SingleInstanceNodeContext, SchemaDataNode {
private static final long serialVersionUID = 806201605L;
@@ -154,7 +163,8 @@
* Create a container node.
*/
public YangContainer() {
- super(YangNodeType.CONTAINER_NODE, new HashMap<>());
+ super(YangNodeType.CONTAINER_NODE, new HashMap<>(),
+ DataNode.Type.SINGLE_INSTANCE_NODE);
listOfLeaf = new LinkedList<>();
listOfLeafList = new LinkedList<>();
mustConstraintList = new LinkedList<>();
@@ -421,7 +431,8 @@
* @param leafLists list of leaf-list attributes of container
* @throws DataModelException a violation of data model rules
*/
- private void validateConfig(List<YangLeaf> leaves, List<YangLeafList> leafLists)
+ private void validateConfig(List<YangLeaf> leaves,
+ List<YangLeafList> leafLists)
throws DataModelException {
/*
@@ -431,12 +442,13 @@
if (!isConfig && leaves != null) {
for (YangLeaf leaf : leaves) {
if (leaf.isConfig()) {
- throw new DataModelException("If a container has \"config\" set to \"false\", no node underneath " +
- "it can have \"config\" set to \"true\"." +
- getName() + " in " +
- getLineNumber() + " at " +
- getCharPosition() +
- " in " + getFileName() + "\"");
+ throw new DataModelException(
+ "If a container has \"config\" set to \"false\", " +
+ "no node underneath it can have " +
+ "\"config\" set to \"true\"." + getName() +
+ " in " + getLineNumber() + " at " +
+ getCharPosition() +
+ " in " + getFileName() + "\"");
}
}
}
@@ -444,33 +456,39 @@
if (!isConfig && leafLists != null) {
for (YangLeafList leafList : leafLists) {
if (leafList.isConfig()) {
- throw new DataModelException("If a container has \"config\" set to \"false\", no node underneath " +
- "it can have \"config\" set to \"true\"." +
- getName() + " in " +
- getLineNumber() + " at " +
- getCharPosition() +
- " in " + getFileName() + "\"");
+ throw new DataModelException(
+ "If a container has \"config\" set to \"false\", " +
+ "no node underneath it can have " +
+ "\"config\" set to \"true\"." +
+ getName() + " in " +
+ getLineNumber() + " at " +
+ getCharPosition() +
+ " in " + getFileName() + "\"");
}
}
}
}
@Override
- public void detectCollidingChild(String identifierName, YangConstructType dataType)
+ public void detectCollidingChild(String identifierName,
+ YangConstructType dataType)
throws DataModelException {
// Asks helper to detect colliding child.
detectCollidingChildUtil(identifierName, dataType, this);
}
@Override
- public void detectSelfCollision(String identifierName, YangConstructType dataType)
+ public void detectSelfCollision(String identifierName,
+ YangConstructType dataType)
throws DataModelException {
if (getName().equals(identifierName)) {
- throw new DataModelException("YANG file error: Duplicate input identifier detected, same as container \"" +
- getName() + " in " +
- getLineNumber() + " at " +
- getCharPosition() +
- " in " + getFileName() + "\"");
+ throw new DataModelException(
+ "YANG file error: Duplicate input identifier detected," +
+ " same as container \"" +
+ getName() + " in " +
+ getLineNumber() + " at " +
+ getCharPosition() +
+ " in " + getFileName() + "\"");
}
}
@@ -537,7 +555,39 @@
}
}
+ @Override
+ public void setLeafParentContext() {
+ // Add parent context for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setParentContext(getParentSchemaContext(this));
+ }
+ // Add parent context for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setParentContext(getParentSchemaContext(this));
+ }
+ }
+
public void cloneAugmentInfo() {
yangAugmentedInfo = new ArrayList<>();
}
+
+ @Override
+ public SchemaContext getChildContext(SchemaId schemaId) {
+
+ checkNotNull(schemaId);
+ YangSchemaNodeIdentifier id = getNodeIdFromSchemaId(
+ schemaId, getNameSpace().getModuleNamespace());
+ try {
+ YangSchemaNode node = getChildSchema(id).getSchemaNode();
+ if (node instanceof SchemaDataNode) {
+ return node;
+ } else {
+ throw new IllegalArgumentException(errorMsg(FMT_NOT_EXIST,
+ schemaId.name(),
+ getName()));
+ }
+ } catch (DataModelException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangGrouping.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangGrouping.java
index aa2303b..d7989e0 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangGrouping.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangGrouping.java
@@ -121,6 +121,9 @@
*/
private int groupingDepth;
+ private static final String E_NONDATA =
+ "Method called for other then data node";
+
/**
* Creates the grouping node.
*/
@@ -365,6 +368,11 @@
yangLeafList.setLeafNameSpaceAndAddToParentSchemaMap(getNameSpace());
}
}
+
+ @Override
+ public void setLeafParentContext() {
+ throw new IllegalArgumentException(E_NONDATA);
+ }
// TODO A grouping MUST NOT reference itself, neither directly nor indirectly through a chain of other groupings.
/**
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangInput.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangInput.java
index a1019a5..bc69391 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangInput.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangInput.java
@@ -19,19 +19,28 @@
import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
import org.onosproject.yang.compiler.datamodel.utils.Parsable;
import org.onosproject.yang.compiler.datamodel.utils.YangConstructType;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.SchemaContext;
+import org.onosproject.yang.model.SchemaId;
+import org.onosproject.yang.model.SingleInstanceNodeContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Collections.unmodifiableList;
import static org.onosproject.yang.compiler.datamodel.YangNodeType.INPUT_NODE;
import static org.onosproject.yang.compiler.datamodel.YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.COLLISION_DETECTION;
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.INPUT;
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.getErrorMsgCollision;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.FMT_NOT_EXIST;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.errorMsg;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getNodeIdFromSchemaId;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentSchemaContext;
import static org.onosproject.yang.compiler.datamodel.utils.YangConstructType.INPUT_DATA;
/*
@@ -80,7 +89,8 @@
public abstract class YangInput
extends YangNode
implements YangLeavesHolder, Parsable, CollisionDetector,
- YangAugmentableNode, YangIsFilterContentNodes, InvalidOpTypeHolder {
+ YangAugmentableNode, YangIsFilterContentNodes, InvalidOpTypeHolder,
+ SchemaDataNode, SingleInstanceNodeContext {
private static final long serialVersionUID = 806201608L;
@@ -100,7 +110,7 @@
* Create a rpc input node.
*/
public YangInput() {
- super(INPUT_NODE, new HashMap<>());
+ super(INPUT_NODE, new HashMap<>(), DataNode.Type.SINGLE_INSTANCE_NODE);
listOfLeaf = new LinkedList<>();
listOfLeafList = new LinkedList<>();
yangAugmentedInfo = new ArrayList<>();
@@ -245,7 +255,39 @@
}
}
+ @Override
+ public void setLeafParentContext() {
+ // Add parent context for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setParentContext(getParentSchemaContext(this));
+ }
+ // Add parent context for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setParentContext(getParentSchemaContext(this));
+ }
+ }
+
public void cloneAugmentInfo() {
yangAugmentedInfo = new ArrayList<>();
}
+
+ @Override
+ public SchemaContext getChildContext(SchemaId schemaId) {
+
+ checkNotNull(schemaId);
+ YangSchemaNodeIdentifier id = getNodeIdFromSchemaId(
+ schemaId, getNameSpace().getModuleNamespace());
+ try {
+ YangSchemaNode node = getChildSchema(id).getSchemaNode();
+ if (node instanceof SchemaDataNode) {
+ return node;
+ } else {
+ throw new IllegalArgumentException(errorMsg(FMT_NOT_EXIST,
+ schemaId.name(),
+ getName()));
+ }
+ } catch (DataModelException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeaf.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeaf.java
index 7d64d7f..8226587 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeaf.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeaf.java
@@ -19,6 +19,13 @@
import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
import org.onosproject.yang.compiler.datamodel.utils.Parsable;
import org.onosproject.yang.compiler.datamodel.utils.YangConstructType;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.ObjectProvider;
+import org.onosproject.yang.model.DataNode.Type;
+import org.onosproject.yang.model.LeafRestriction;
+import org.onosproject.yang.model.LeafSchemaContext;
+import org.onosproject.yang.model.LeafType;
+import org.onosproject.yang.model.SchemaContext;
+import org.onosproject.yang.model.SchemaId;
import java.io.Serializable;
import java.util.LinkedList;
@@ -26,6 +33,7 @@
import java.util.Map;
import static org.onosproject.yang.compiler.datamodel.YangStatusType.CURRENT;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getLeafTypeByDataType;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.validateEmptyDataType;
/*
@@ -68,7 +76,8 @@
public abstract class YangLeaf extends DefaultLocationInfo
implements YangCommonInfo, Parsable, Cloneable, Serializable,
YangMustHolder, YangIfFeatureHolder, YangWhenHolder, YangSchemaNode,
- YangConfig, YangUnits, YangDefault, YangMandatory {
+ YangConfig, YangUnits, YangDefault, YangMandatory, LeafSchemaContext,
+ SchemaDataNode {
private static final long serialVersionUID = 806201635L;
@@ -146,6 +155,11 @@
private boolean isKeyLeaf;
/**
+ * Parent context of data node.
+ */
+ private SchemaContext parentContext;
+
+ /**
* Creates a YANG leaf.
*/
public YangLeaf() {
@@ -595,4 +609,52 @@
public void setKeyLeaf(boolean keyLeaf) {
isKeyLeaf = keyLeaf;
}
+
+ @Override
+ public Type getType() {
+ return Type.SINGLE_INSTANCE_LEAF_VALUE_NODE;
+ }
+
+ @Override
+ public SchemaId getSchemaId() {
+ SchemaId schemaId = new SchemaId(getName(), getNameSpace()
+ .getModuleNamespace());
+ return schemaId;
+ }
+
+
+ @Override
+ public LeafType getLeafType() {
+ return getLeafTypeByDataType(dataType, dataType.getDataType());
+ }
+
+ @Override
+ public <T extends LeafRestriction> T getLeafRestrictions() {
+ //TODO implementation
+ return null;
+ }
+
+ @Override
+ public Object fromString(String value) {
+ return ObjectProvider.getObject(dataType, value, dataType.getDataType());
+ }
+
+ @Override
+ public SchemaContext getParentContext() {
+ return parentContext;
+ }
+
+ /**
+ * Sets the parent context for current context.
+ *
+ * @param sc schema context
+ */
+ public void setParentContext(SchemaContext sc) {
+ parentContext = sc;
+ }
+
+ @Override
+ public void setRootContext(SchemaContext context) {
+ parentContext = context;
+ }
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeafList.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeafList.java
index cba5d06..2d67dc8 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeafList.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeafList.java
@@ -19,6 +19,13 @@
import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
import org.onosproject.yang.compiler.datamodel.utils.Parsable;
import org.onosproject.yang.compiler.datamodel.utils.YangConstructType;
+import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.ObjectProvider;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.LeafRestriction;
+import org.onosproject.yang.model.LeafSchemaContext;
+import org.onosproject.yang.model.LeafType;
+import org.onosproject.yang.model.SchemaContext;
+import org.onosproject.yang.model.SchemaId;
import java.io.Serializable;
import java.util.LinkedList;
@@ -26,6 +33,7 @@
import java.util.Map;
import static org.onosproject.yang.compiler.datamodel.YangStatusType.CURRENT;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getLeafTypeByDataType;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.validateEmptyDataType;
/*
@@ -64,7 +72,8 @@
public abstract class YangLeafList extends DefaultLocationInfo
implements YangCommonInfo, Parsable, Cloneable, Serializable,
YangMustHolder, YangWhenHolder, YangIfFeatureHolder, YangSchemaNode,
- YangConfig, YangUnits, YangMaxElementHolder, YangMinElementHolder {
+ YangConfig, YangUnits, YangMaxElementHolder, YangMinElementHolder,
+ SchemaDataNode, LeafSchemaContext {
private static final long serialVersionUID = 806201637L;
@@ -161,6 +170,11 @@
private YangLeafList referredLeafList;
/**
+ * Parent context of data node.
+ */
+ private SchemaContext parentContext;
+
+ /**
* Creates a YANG leaf-list.
*/
public YangLeafList() {
@@ -590,4 +604,51 @@
public void setReferredSchemaLeafList(YangLeafList leafList) {
referredLeafList = leafList;
}
+
+ @Override
+ public DataNode.Type getType() {
+ return DataNode.Type.MULTI_INSTANCE_LEAF_VALUE_NODE;
+ }
+
+ @Override
+ public SchemaId getSchemaId() {
+ SchemaId schemaId = new SchemaId(
+ this.getName(), this.getNameSpace().getModuleNamespace());
+ return schemaId;
+ }
+
+ @Override
+ public SchemaContext getParentContext() {
+ return parentContext;
+ }
+
+ /**
+ * Sets the parent context for current context.
+ *
+ * @param schemaContext schema context
+ */
+ public void setParentContext(SchemaContext schemaContext) {
+ this.parentContext = schemaContext;
+ }
+
+ @Override
+ public void setRootContext(SchemaContext context) {
+ parentContext = context;
+ }
+
+ @Override
+ public LeafType getLeafType() {
+ return getLeafTypeByDataType(dataType, dataType.getDataType());
+ }
+
+ @Override
+ public <T extends LeafRestriction> T getLeafRestrictions() {
+ // TODO implementation.
+ return null;
+ }
+
+ @Override
+ public Object fromString(String value) {
+ return ObjectProvider.getObject(dataType, value, dataType.getDataType());
+ }
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeavesHolder.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeavesHolder.java
index e7e1fac..5f065ab 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeavesHolder.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangLeavesHolder.java
@@ -84,7 +84,11 @@
/**
* Adds namespace for leafs and leaf-list, this is used in case of
* submodule.
- *
*/
void setLeafNameSpaceAndAddToParentSchemaMap();
+
+ /**
+ * Adds the parent context for leafs and leaf-list.
+ */
+ void setLeafParentContext();
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangList.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangList.java
index 7b7032b..0855b98 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangList.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangList.java
@@ -20,15 +20,25 @@
import org.onosproject.yang.compiler.datamodel.utils.DataModelUtils;
import org.onosproject.yang.compiler.datamodel.utils.Parsable;
import org.onosproject.yang.compiler.datamodel.utils.YangConstructType;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.MultiInstanceNodeContext;
+import org.onosproject.yang.model.SchemaContext;
+import org.onosproject.yang.model.SchemaId;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
+import static com.google.common.base.Preconditions.checkNotNull;
import static org.onosproject.yang.compiler.datamodel.YangNodeType.LIST_NODE;
import static org.onosproject.yang.compiler.datamodel.YangSchemaNodeType.YANG_MULTI_INSTANCE_NODE;
import static org.onosproject.yang.compiler.datamodel.YangStatusType.CURRENT;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.FMT_NOT_EXIST;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.errorMsg;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getNodeIdFromSchemaId;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentSchemaContext;
import static org.onosproject.yang.compiler.datamodel.utils.YangConstructType.LIST_DATA;
import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.EMPTY;
@@ -79,7 +89,7 @@
implements YangLeavesHolder, YangCommonInfo, Parsable, CollisionDetector,
YangAugmentableNode, YangMustHolder, YangWhenHolder, YangIfFeatureHolder, YangSchemaNode,
YangIsFilterContentNodes, YangConfig, YangUniqueHolder,
- YangMaxElementHolder, YangMinElementHolder {
+ YangMaxElementHolder, YangMinElementHolder, SchemaDataNode, MultiInstanceNodeContext {
private static final long serialVersionUID = 806201609L;
@@ -116,9 +126,9 @@
* All key leafs in a list MUST have the same value for their "config" as
* the list itself.
* <p>
- * List of key leaf names.
+ * Set of key leaf names.
*/
- private List<String> keyList;
+ private LinkedHashSet<String> keyList;
/**
* Reference RFC 6020.
@@ -215,16 +225,21 @@
private transient YangCompilerAnnotation compilerAnnotation;
/**
+ * Parent context of data node.
+ */
+ private SchemaContext parentContext;
+
+ /**
* Creates a YANG list object.
*/
public YangList() {
- super(LIST_NODE, new HashMap<>());
+ super(LIST_NODE, new HashMap<>(), DataNode.Type.MULTI_INSTANCE_NODE);
listOfLeaf = new LinkedList<>();
listOfLeafList = new LinkedList<>();
mustConstraintList = new LinkedList<>();
ifFeatureList = new LinkedList<>();
uniqueList = new LinkedList<>();
- keyList = new LinkedList<>();
+ keyList = new LinkedHashSet<>();
}
@Override
@@ -347,20 +362,25 @@
}
/**
- * Returns the list of key field names.
+ * Returns the set of key field names.
*
- * @return the list of key field names
+ * @return the set of key field names
*/
- public List<String> getKeyList() {
+ public LinkedHashSet<String> getKeyList() {
+ return keyList;
+ }
+
+ @Override
+ public LinkedHashSet<String> getKeyLeaf() {
return keyList;
}
/**
* Sets the list of key field names.
*
- * @param keyList the list of key field names
+ * @param keyList the set of key field names
*/
- private void setKeyList(List<String> keyList) {
+ private void setKeyList(LinkedHashSet<String> keyList) {
this.keyList = keyList;
}
@@ -373,7 +393,7 @@
public void addKey(String key)
throws DataModelException {
if (getKeyList() == null) {
- setKeyList(new LinkedList<>());
+ setKeyList(new LinkedHashSet<String>());
}
if (getKeyList().contains(key)) {
@@ -600,7 +620,7 @@
@Override
public void validateDataOnExit()
throws DataModelException {
- List<String> keys = getKeyList();
+ LinkedHashSet<String> keys = getKeyList();
List<YangLeaf> leaves = getListOfLeaf();
List<YangLeafList> leafLists = getListOfLeafList();
@@ -664,10 +684,10 @@
* Validates key statement of list.
*
* @param leaves list of leaf attributes of list
- * @param keys list of key attributes of list
+ * @param keys set of key attributes of list
* @throws DataModelException a violation of data model rules
*/
- private void validateKey(List<YangLeaf> leaves, List<String> keys)
+ private void validateKey(List<YangLeaf> leaves, LinkedHashSet<String> keys)
throws DataModelException {
boolean leafFound = false;
List<YangLeaf> keyLeaves = new LinkedList<>();
@@ -827,7 +847,39 @@
}
}
+ @Override
+ public void setLeafParentContext() {
+ // Add parent context for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setParentContext(getParentSchemaContext(this));
+ }
+ // Add parent context for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setParentContext(getParentSchemaContext(this));
+ }
+ }
+
public void cloneAugmentInfo() {
yangAugmentedInfo = new ArrayList<>();
}
+
+ @Override
+ public SchemaContext getChildContext(SchemaId schemaId) {
+
+ checkNotNull(schemaId);
+ YangSchemaNodeIdentifier id = getNodeIdFromSchemaId(
+ schemaId, getNameSpace().getModuleNamespace());
+ try {
+ YangSchemaNode node = getChildSchema(id).getSchemaNode();
+ if (node instanceof SchemaDataNode) {
+ return node;
+ } else {
+ throw new IllegalArgumentException(errorMsg(FMT_NOT_EXIST,
+ schemaId.name(),
+ getName()));
+ }
+ } catch (DataModelException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangModule.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangModule.java
index 09dbc98..83c8ca4 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangModule.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangModule.java
@@ -279,6 +279,9 @@
*/
private boolean isModuleForDeviation;
+ private static final String E_NONDATA =
+ "Method called for other then data node";
+
/**
* Creates a YANG node of module type.
*/
@@ -808,6 +811,11 @@
}
@Override
+ public void setLeafParentContext() {
+ throw new IllegalArgumentException(E_NONDATA);
+ }
+
+ @Override
public boolean isNotificationPresent() {
return isNotificationPresent;
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangNode.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangNode.java
index 8b7f597..bca3490 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangNode.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangNode.java
@@ -17,6 +17,9 @@
import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
import org.onosproject.yang.compiler.datamodel.utils.Parsable;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.SchemaContext;
+import org.onosproject.yang.model.SchemaId;
import java.io.Serializable;
import java.util.HashMap;
@@ -25,8 +28,10 @@
import static org.onosproject.yang.compiler.datamodel.TraversalType.CHILD;
import static org.onosproject.yang.compiler.datamodel.TraversalType.PARENT;
import static org.onosproject.yang.compiler.datamodel.TraversalType.SIBILING;
+import static org.onosproject.yang.compiler.datamodel.YangNodeType.RPC_NODE;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.cloneListOfLeaf;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.cloneListOfLeafList;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentSchemaContext;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.updateClonedLeavesUnionEnumRef;
/**
@@ -44,16 +49,31 @@
private YangSchemaNodeIdentifier yangSchemaNodeIdentifier;
/**
+ * YANG Data node schema identifier.
+ */
+ private SchemaId schemaId;
+
+ /**
* Type of node.
*/
private YangNodeType nodeType;
/**
+ * Type of node.
+ */
+ private DataNode.Type dataNodeType;
+
+ /**
* Parent reference.
*/
private YangNode parent;
/**
+ * Parent schema context reference.
+ */
+ private SchemaContext parentContext;
+
+ /**
* First child reference.
*/
private YangNode child;
@@ -112,6 +132,9 @@
*/
private YangNode referredSchemaNode;
+ private static final String E_NONDATA =
+ "Method called for other then data node";
+
/**
* Returns the priority of the node.
*
@@ -142,9 +165,26 @@
*
* @param type of YANG node
* @param ysnContextInfoMap YSN context info map
+ * @param dtype data node type
*/
protected YangNode(YangNodeType type,
- Map<YangSchemaNodeIdentifier, YangSchemaNodeContextInfo> ysnContextInfoMap) {
+ Map<YangSchemaNodeIdentifier,
+ YangSchemaNodeContextInfo> ysnContextInfoMap,
+ DataNode.Type dtype) {
+ nodeType = type;
+ dataNodeType = dtype;
+ this.ysnContextInfoMap = ysnContextInfoMap;
+ }
+
+ /**
+ * Creates a specific type of node.
+ *
+ * @param type of YANG node
+ * @param ysnContextInfoMap YSN context info map
+ */
+ protected YangNode(YangNodeType type,
+ Map<YangSchemaNodeIdentifier,
+ YangSchemaNodeContextInfo> ysnContextInfoMap) {
nodeType = type;
this.ysnContextInfoMap = ysnContextInfoMap;
}
@@ -515,7 +555,6 @@
* update the traversal's current node.
*/
nextNodeToClone = nextNodeToClone.getChild();
-
} else if (nextNodeToClone.getNextSibling() != null) {
curTraversal = SIBILING;
@@ -533,7 +572,6 @@
" at " + nextNodeToClone.getCharPosition() +
" in " + nextNodeToClone.getFileName() + "\"");
}
-
}
/**
@@ -796,13 +834,12 @@
/**
* Adds to YSN context info map.
*
- * @param yangSchemaNodeIdentifier YANG schema node identifier
- * @param yangSchemaNodeContextInfo YANG schema node context info
+ * @param id YANG schema node identifier
+ * @param info YANG schema node context info
*/
- public void addToYsnContextInfoMap(YangSchemaNodeIdentifier
- yangSchemaNodeIdentifier, YangSchemaNodeContextInfo
- yangSchemaNodeContextInfo) {
- getYsnContextInfoMap().put(yangSchemaNodeIdentifier, yangSchemaNodeContextInfo);
+ public void addToYsnContextInfoMap(YangSchemaNodeIdentifier id,
+ YangSchemaNodeContextInfo info) {
+ getYsnContextInfoMap().put(id, info);
}
@Override
@@ -823,13 +860,13 @@
/**
* Sets YANG schema node identifier.
*
- * @param yangSchemaNodeIdentifier YANG schema node identifier
+ * @param id YANG schema node identifier
*/
- public void setYangSchemaNodeIdentifier(YangSchemaNodeIdentifier yangSchemaNodeIdentifier) {
+ public void setYangSchemaNodeIdentifier(YangSchemaNodeIdentifier id) {
if (this.yangSchemaNodeIdentifier == null) {
this.yangSchemaNodeIdentifier = new YangSchemaNodeIdentifier();
}
- this.yangSchemaNodeIdentifier = yangSchemaNodeIdentifier;
+ this.yangSchemaNodeIdentifier = id;
}
@Override
@@ -936,4 +973,79 @@
public void setFileName(String name) {
fileName = name;
}
+
+ @Override
+ public SchemaId getSchemaId() throws IllegalArgumentException {
+ if (schemaId == null) {
+ throw new IllegalArgumentException(E_NONDATA);
+ }
+ return schemaId;
+ }
+
+ @Override
+ public DataNode.Type getType() throws IllegalArgumentException {
+ if (dataNodeType == null) {
+ throw new IllegalArgumentException(E_NONDATA);
+ }
+ return dataNodeType;
+ }
+
+ @Override
+ public SchemaContext getParentContext() throws IllegalArgumentException {
+ if (parentContext == null) {
+ throw new IllegalArgumentException(E_NONDATA);
+ }
+ return parentContext;
+ }
+
+ /**
+ * Sets parent context of data node.
+ */
+ public void setParentContext() {
+ if (this instanceof SchemaDataNode) {
+ parentContext = getParentSchemaContext(this.getParent());
+
+ // As rpc node is not leaf holder
+ if (this.nodeType != RPC_NODE) {
+ ((YangLeavesHolder) this).setLeafParentContext();
+ }
+ // setting the schema Id
+ schemaId = new SchemaId(getName(), getNameSpace()
+ .getModuleNamespace());
+ } else if (this instanceof YangCase) {
+ ((YangLeavesHolder) this).setLeafParentContext();
+ }
+ }
+
+ /**
+ * Sets given node as parent context current data node.
+ *
+ * @param schemaContext schema context
+ */
+ public void setParentContext(SchemaContext schemaContext) {
+ parentContext = schemaContext;
+ }
+
+ @Override
+ public void setRootContext(SchemaContext context) {
+ parentContext = context;
+ }
+
+ /**
+ * Sets provided context as parent context for module/submodule and case
+ * nodes.
+ *
+ * @param context module registry schema context
+ */
+ public void setLeafRootContext(SchemaContext context) {
+ // Add parent context for all leafs.
+ for (YangLeaf yangLeaf : ((YangLeavesHolder) this).getListOfLeaf()) {
+ yangLeaf.setParentContext(context);
+ }
+ // Add parent context for all leaf list.
+ for (YangLeafList yangLeafList : ((YangLeavesHolder) this)
+ .getListOfLeafList()) {
+ yangLeafList.setParentContext(context);
+ }
+ }
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangNotification.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangNotification.java
index 07a5958..0255a2a 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangNotification.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangNotification.java
@@ -33,6 +33,7 @@
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.NOTIFICATION;
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.getErrorMsgCollision;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentSchemaContext;
import static org.onosproject.yang.compiler.datamodel.utils.YangConstructType.NOTIFICATION_DATA;
/*
@@ -313,6 +314,18 @@
}
}
+ @Override
+ public void setLeafParentContext() {
+ // Add parent context for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setParentContext(getParentSchemaContext(this));
+ }
+ // Add parent context for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setParentContext(getParentSchemaContext(this));
+ }
+ }
+
public void cloneAugmentInfo() {
yangAugmentedInfo = new ArrayList<>();
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangOutput.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangOutput.java
index 6ce7aed..ca49cd9 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangOutput.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangOutput.java
@@ -19,18 +19,27 @@
import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
import org.onosproject.yang.compiler.datamodel.utils.Parsable;
import org.onosproject.yang.compiler.datamodel.utils.YangConstructType;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.SchemaContext;
+import org.onosproject.yang.model.SchemaId;
+import org.onosproject.yang.model.SingleInstanceNodeContext;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Collections.unmodifiableList;
import static org.onosproject.yang.compiler.datamodel.YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.COLLISION_DETECTION;
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.OUTPUT;
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.getErrorMsgCollision;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.FMT_NOT_EXIST;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.errorMsg;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getNodeIdFromSchemaId;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentSchemaContext;
import static org.onosproject.yang.compiler.datamodel.utils.YangConstructType.OUTPUT_DATA;
/*
@@ -78,7 +87,8 @@
public abstract class YangOutput
extends YangNode
implements YangLeavesHolder, Parsable, CollisionDetector,
- YangAugmentableNode, YangIsFilterContentNodes, InvalidOpTypeHolder {
+ YangAugmentableNode, YangIsFilterContentNodes, InvalidOpTypeHolder,
+ SchemaDataNode, SingleInstanceNodeContext {
private static final long serialVersionUID = 806201612L;
@@ -98,7 +108,8 @@
* Create a rpc output node.
*/
public YangOutput() {
- super(YangNodeType.OUTPUT_NODE, new HashMap<>());
+ super(YangNodeType.OUTPUT_NODE, new HashMap<>(),
+ DataNode.Type.SINGLE_INSTANCE_NODE);
listOfLeaf = new LinkedList<>();
listOfLeafList = new LinkedList<>();
yangAugmentedInfo = new ArrayList<>();
@@ -241,7 +252,39 @@
}
}
+ @Override
+ public void setLeafParentContext() {
+ // Add parent context for all leafs.
+ for (YangLeaf yangLeaf : getListOfLeaf()) {
+ yangLeaf.setParentContext(getParentSchemaContext(this));
+ }
+ // Add parent context for all leaf list.
+ for (YangLeafList yangLeafList : getListOfLeafList()) {
+ yangLeafList.setParentContext(getParentSchemaContext(this));
+ }
+ }
+
public void cloneAugmentInfo() {
yangAugmentedInfo = new ArrayList<>();
}
+
+ @Override
+ public SchemaContext getChildContext(SchemaId schemaId) {
+
+ checkNotNull(schemaId);
+ YangSchemaNodeIdentifier id = getNodeIdFromSchemaId(
+ schemaId, getNameSpace().getModuleNamespace());
+ try {
+ YangSchemaNode node = getChildSchema(id).getSchemaNode();
+ if (node instanceof SchemaDataNode) {
+ return node;
+ } else {
+ throw new IllegalArgumentException(errorMsg(FMT_NOT_EXIST,
+ schemaId.name(),
+ getName()));
+ }
+ } catch (DataModelException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangRpc.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangRpc.java
index cd3f30e..2b96956 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangRpc.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangRpc.java
@@ -19,11 +19,16 @@
import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
import org.onosproject.yang.compiler.datamodel.utils.Parsable;
import org.onosproject.yang.compiler.datamodel.utils.YangConstructType;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.SchemaContext;
+import org.onosproject.yang.model.SchemaId;
+import org.onosproject.yang.model.SingleInstanceNodeContext;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
+import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Collections.unmodifiableList;
import static org.onosproject.yang.compiler.datamodel.YangNodeType.RPC_NODE;
import static org.onosproject.yang.compiler.datamodel.YangSchemaNodeType.YANG_SINGLE_INSTANCE_NODE;
@@ -31,7 +36,10 @@
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.COLLISION_DETECTION;
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.RPC;
import static org.onosproject.yang.compiler.datamodel.exceptions.ErrorMessages.getErrorMsgCollision;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.FMT_NOT_EXIST;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.errorMsg;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getNodeIdFromSchemaId;
import static org.onosproject.yang.compiler.datamodel.utils.YangConstructType.RPC_DATA;
/*
@@ -71,7 +79,8 @@
public abstract class YangRpc
extends YangNode
implements YangCommonInfo, Parsable,
- CollisionDetector, YangIfFeatureHolder, InvalidOpTypeHolder {
+ CollisionDetector, YangIfFeatureHolder, InvalidOpTypeHolder,
+ SingleInstanceNodeContext, SchemaDataNode {
private static final long serialVersionUID = 806201613L;
@@ -99,7 +108,7 @@
* Creates a rpc node.
*/
public YangRpc() {
- super(RPC_NODE, new HashMap<>());
+ super(RPC_NODE, new HashMap<>(), DataNode.Type.SINGLE_INSTANCE_NODE);
ifFeatureList = new LinkedList<>();
}
@@ -215,4 +224,24 @@
public void setIfFeatureList(List<YangIfFeature> ifFeatureList) {
this.ifFeatureList = ifFeatureList;
}
+
+ @Override
+ public SchemaContext getChildContext(SchemaId schemaId) {
+
+ checkNotNull(schemaId);
+ YangSchemaNodeIdentifier id = getNodeIdFromSchemaId(
+ schemaId, getNameSpace().getModuleNamespace());
+ try {
+ YangSchemaNode node = getChildSchema(id).getSchemaNode();
+ if (node instanceof SchemaDataNode) {
+ return node;
+ } else {
+ throw new IllegalArgumentException(errorMsg(FMT_NOT_EXIST,
+ schemaId.name(),
+ getName()));
+ }
+ } catch (DataModelException e) {
+ throw new IllegalArgumentException(e.getMessage());
+ }
+ }
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSchemaNode.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSchemaNode.java
index 155f522..6bc6dc7 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSchemaNode.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSchemaNode.java
@@ -17,6 +17,7 @@
package org.onosproject.yang.compiler.datamodel;
import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
+import org.onosproject.yang.model.SchemaContext;
import java.util.Map;
@@ -24,7 +25,7 @@
* Abstraction of YANG data node, used by YMS to abstractly refer the data
* nodes in YANG data tree.
*/
-public interface YangSchemaNode extends LocationInfo {
+public interface YangSchemaNode extends LocationInfo, SchemaContext {
/**
* Returns type of YANG schema node.
@@ -156,4 +157,11 @@
* @throws DataModelException when fails to do data model operations
*/
boolean isEmptyDataType() throws DataModelException;
+
+ /**
+ * Sets the root parent context for the module/submodule child data node.
+ *
+ * @param context schema context
+ */
+ void setRootContext(SchemaContext context);
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSchemaNodeIdentifier.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSchemaNodeIdentifier.java
index 4ee96fd..afec01a 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSchemaNodeIdentifier.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSchemaNodeIdentifier.java
@@ -21,7 +21,7 @@
/**
* Represents YANG data node identifier which is a combination of name and namespace.
- * Namespace will be present only if node is module/sub-module or augmented node.
+ * DefaultYangNamespace will be present only if node is module/sub-module or augmented node.
*/
public class YangSchemaNodeIdentifier extends DefaultLocationInfo
implements Serializable, Cloneable {
@@ -31,7 +31,7 @@
// Name of YANG data node.
private String name;
- // Namespace of YANG data node.
+ // DefaultYangNamespace of YANG data node.
private YangNamespace namespace;
/**
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSubModule.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSubModule.java
index a83ba5d..69030ed 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSubModule.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/YangSubModule.java
@@ -283,6 +283,9 @@
*/
private boolean isModuleForDeviation;
+ private static final String E_NONDATA =
+ "Method called for other then data node";
+
/**
* Creates a sub module node.
*/
@@ -813,6 +816,10 @@
}
}
+ @Override
+ public void setLeafParentContext() {
+ throw new IllegalArgumentException(E_NONDATA);
+ }
@Override
public boolean isNotificationPresent() {
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java
index 4e3534d..ea23160 100644
--- a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/DataModelUtils.java
@@ -17,6 +17,8 @@
package org.onosproject.yang.compiler.datamodel.utils;
import org.onosproject.yang.compiler.datamodel.CollisionDetector;
+import org.onosproject.yang.compiler.datamodel.DefaultYangNamespace;
+import org.onosproject.yang.compiler.datamodel.SchemaDataNode;
import org.onosproject.yang.compiler.datamodel.YangAtomicPath;
import org.onosproject.yang.compiler.datamodel.YangAugment;
import org.onosproject.yang.compiler.datamodel.YangBase;
@@ -52,6 +54,7 @@
import org.onosproject.yang.compiler.datamodel.YangResolutionInfo;
import org.onosproject.yang.compiler.datamodel.YangRpc;
import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNodeIdentifier;
import org.onosproject.yang.compiler.datamodel.YangType;
import org.onosproject.yang.compiler.datamodel.YangUnion;
import org.onosproject.yang.compiler.datamodel.YangUniqueHolder;
@@ -59,6 +62,8 @@
import org.onosproject.yang.compiler.datamodel.YangUses;
import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes;
+import org.onosproject.yang.model.LeafType;
+import org.onosproject.yang.model.SchemaId;
import java.io.File;
import java.io.FileInputStream;
@@ -86,10 +91,20 @@
import static org.onosproject.yang.compiler.datamodel.ResolvableType.YANG_IF_FEATURE;
import static org.onosproject.yang.compiler.datamodel.ResolvableType.YANG_LEAFREF;
import static org.onosproject.yang.compiler.datamodel.ResolvableType.YANG_USES;
+import static org.onosproject.yang.compiler.datamodel.YangSchemaNodeType.YANG_AUGMENT_NODE;
import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.DERIVED;
import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.EMPTY;
import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.ENUMERATION;
import static org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes.UNION;
+import static org.onosproject.yang.model.LeafType.BIG_DECIMAL;
+import static org.onosproject.yang.model.LeafType.BIG_INTEGER;
+import static org.onosproject.yang.model.LeafType.BOOLEAN;
+import static org.onosproject.yang.model.LeafType.BYTE;
+import static org.onosproject.yang.model.LeafType.BYTE_ARRAY;
+import static org.onosproject.yang.model.LeafType.INT;
+import static org.onosproject.yang.model.LeafType.LONG;
+import static org.onosproject.yang.model.LeafType.SHORT;
+import static org.onosproject.yang.model.LeafType.STRING;
/**
* Represents utilities for data model tree.
@@ -98,6 +113,9 @@
public static final String TRUE = "true";
public static final String FALSE = "false";
private static final String SLASH = File.separator;
+ public static final String FMT_NOT_EXIST =
+ "Requested %s is not child in %s.";
+ private static final String E_DATATYPE = "Data type not supported.";
/**
* Creates a new data model tree utility.
@@ -1225,6 +1243,7 @@
/**
* Searches for input in given RPC node.
*
+ * @param rpc yang node
* @return input node
*/
public static YangNode findRpcInput(YangNode rpc) {
@@ -1242,6 +1261,7 @@
/**
* Searches for output in given RPC node.
*
+ * @param rpc yang node
* @return output node
*/
public static YangNode findRpcOutput(YangNode rpc) {
@@ -1255,4 +1275,107 @@
}
return null;
}
+
+ /**
+ * Returns the parent data node schema context for given yang node.
+ *
+ * @param node yang node
+ * @return yang node
+ */
+ public static YangNode getParentSchemaContext(YangNode node) {
+ while (!(node instanceof SchemaDataNode) && node != null) {
+ if (node.getYangSchemaNodeType() == YANG_AUGMENT_NODE) {
+ node = ((YangAugment) node).getAugmentedNode();
+ continue;
+ }
+ node = node.getParent();
+ }
+ return node;
+ }
+
+ /**
+ * Returns the yang schema node identifier from provided schema id.
+ *
+ * @param schemaId schema id
+ * @param ns namespace of parent node
+ * @return yang schema node identifier
+ */
+ public static YangSchemaNodeIdentifier getNodeIdFromSchemaId(
+ SchemaId schemaId, String ns) {
+ String namespace = schemaId.namespace();
+
+ if (namespace == null) {
+ namespace = ns;
+ }
+ DefaultYangNamespace nameSpace = new DefaultYangNamespace(namespace);
+ YangSchemaNodeIdentifier id = new YangSchemaNodeIdentifier();
+ id.setName(schemaId.name());
+ id.setNameSpace(nameSpace);
+ return id;
+ }
+
+ /**
+ * Returns the error string by filling the parameters in the given
+ * formatted error string.
+ *
+ * @param fmt error format string
+ * @param params parameters to be filled in formatted string
+ * @return error string
+ */
+ public static String errorMsg(String fmt, Object... params) {
+ return String.format(fmt, params);
+ }
+
+ /**
+ * Returns the yang leaf type for corresponding supplied data type.
+ *
+ * @param type YANG type
+ * @param dataType YANG data type
+ * @return leaf type
+ */
+ public static LeafType getLeafTypeByDataType(YangType type,
+ YangDataTypes dataType) {
+
+ switch (dataType) {
+ case BITS:
+ case ENUMERATION:
+ case IDENTITYREF:
+ case STRING:
+ return STRING;
+ case BOOLEAN:
+ case EMPTY:
+ return BOOLEAN;
+ case DECIMAL64:
+ return BIG_DECIMAL;
+ case INT8:
+ return BYTE;
+ case INT16:
+ case UINT8:
+ return SHORT;
+ case INT32:
+ case UINT16:
+ return INT;
+ case INT64:
+ case UINT32:
+ return LONG;
+ case UINT64:
+ return BIG_INTEGER;
+ case BINARY:
+ return BYTE_ARRAY;
+ case DERIVED:
+ return getLeafTypeByDataType(type, ((YangDerivedInfo) type
+ .getDataTypeExtendedInfo()).getEffectiveBuiltInType());
+ case LEAFREF:
+ return getLeafTypeByDataType(type, ((YangLeafRef) type
+ .getDataTypeExtendedInfo()).getEffectiveDataType()
+ .getDataType());
+ case INSTANCE_IDENTIFIER:
+ return STRING;
+ case UNION:
+ return LeafType.UNION;
+
+ default:
+ throw new IllegalArgumentException(E_DATATYPE);
+ }
+ }
}
diff --git a/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/builtindatatype/ObjectProvider.java b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/builtindatatype/ObjectProvider.java
new file mode 100644
index 0000000..85dc23d
--- /dev/null
+++ b/compiler/base/datamodel/src/main/java/org/onosproject/yang/compiler/datamodel/utils/builtindatatype/ObjectProvider.java
@@ -0,0 +1,125 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.compiler.datamodel.utils.builtindatatype;
+
+import org.onosproject.yang.compiler.datamodel.YangDerivedInfo;
+import org.onosproject.yang.compiler.datamodel.YangLeafRef;
+import org.onosproject.yang.compiler.datamodel.YangType;
+import org.onosproject.yang.compiler.datamodel.YangUnion;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Base64;
+import java.util.Iterator;
+
+public final class ObjectProvider {
+
+ // Object provider constant error string.
+ private static final String E_DATATYPE = "Data type not supported.";
+ private static final String E_NONEMPTY = "Value is of non Empty type";
+
+ /**
+ * Restricts creation of object providers instance.
+ */
+ private ObjectProvider() {
+ }
+
+ /**
+ * Returns object from string value.
+ *
+ * @param typeInfo refers to YANG type information
+ * @param leafValue leafValue argument is used to set the value
+ * in method
+ * @param dataType yang data type
+ * @return values object of corresponding given data type
+ * @throws IllegalArgumentException if input is not valid
+ */
+ public static Object getObject(YangType typeInfo, String leafValue,
+ YangDataTypes dataType)
+ throws IllegalArgumentException {
+ YangDataTypes type;
+ if (dataType != null) {
+ type = dataType;
+ } else {
+ type = typeInfo.getDataType();
+ }
+ switch (type) {
+ case INT8:
+ return Byte.parseByte(leafValue);
+ case UINT8:
+ case INT16:
+ return Short.parseShort(leafValue);
+ case UINT16:
+ case INT32:
+ return Integer.parseInt(leafValue);
+ case UINT32:
+ case INT64:
+ return Long.parseLong(leafValue);
+ case UINT64:
+ return new BigInteger(leafValue);
+ case EMPTY:
+ if (leafValue == null || leafValue.equals("")) {
+ return true;
+ } else {
+ throw new IllegalArgumentException(E_NONEMPTY);
+ }
+ case BOOLEAN:
+ return Boolean.parseBoolean(leafValue);
+ case BINARY:
+ return Base64.getDecoder().decode(leafValue);
+ case BITS:
+ case IDENTITYREF:
+ case ENUMERATION:
+ case STRING:
+ return leafValue;
+ case DECIMAL64:
+ return new BigDecimal(leafValue);
+ case LEAFREF:
+ YangType refType = ((YangLeafRef) typeInfo
+ .getDataTypeExtendedInfo()).getEffectiveDataType();
+ return getObject(refType, leafValue, refType.getDataType());
+ case DERIVED:
+ return getObject(null, leafValue, ((YangDerivedInfo) typeInfo
+ .getDataTypeExtendedInfo()).getEffectiveBuiltInType());
+ case UNION:
+ return parseUnionTypeInfo(typeInfo, leafValue);
+ default:
+ throw new IllegalArgumentException(E_DATATYPE);
+ }
+ }
+
+ /**
+ * Returns the object for given data type with respective value.
+ *
+ * @param type data type of value
+ * @param leafValue value
+ * @return object of data type containing the value
+ */
+ private static Object parseUnionTypeInfo(YangType type, String leafValue) {
+ Iterator<YangType<?>> it = ((YangUnion) type.getDataTypeExtendedInfo())
+ .getTypeList().listIterator();
+ while (it.hasNext()) {
+ YangType t = it.next();
+ try {
+ return getObject(t, leafValue, t.getDataType());
+ } catch (IllegalArgumentException e) {
+ continue;
+ }
+ }
+ throw new IllegalArgumentException("Invalid value of data");
+ }
+}
diff --git a/compiler/base/linker/src/main/java/org/onosproject/yang/compiler/linker/impl/YangResolutionInfoImpl.java b/compiler/base/linker/src/main/java/org/onosproject/yang/compiler/linker/impl/YangResolutionInfoImpl.java
index fb71e43..ee9ad56 100644
--- a/compiler/base/linker/src/main/java/org/onosproject/yang/compiler/linker/impl/YangResolutionInfoImpl.java
+++ b/compiler/base/linker/src/main/java/org/onosproject/yang/compiler/linker/impl/YangResolutionInfoImpl.java
@@ -253,7 +253,8 @@
if (resolvable.getResolvableStatus() == UNRESOLVED) {
// If current entity is still not resolved, then
// linking/resolution has failed.
- DataModelException ex = new DataModelException(getErrorInfoForLinker(resolvable));
+ DataModelException ex = new DataModelException(
+ getErrorInfoForLinker(resolvable));
ex.setLine(getLineNumber());
ex.setCharPosition(getCharPosition());
throw ex;
@@ -776,7 +777,8 @@
throws DataModelException {
T entity = getCurEntityToResolveFromStack();
if (entity instanceof YangType) {
- return node.getName().contentEquals(((YangType<?>) entity).getDataTypeName());
+ return node.getName().contentEquals(((YangType<?>) entity)
+ .getDataTypeName());
}
if (entity instanceof YangUses) {
return node.getName().contentEquals(((YangUses) entity).getName());
@@ -785,20 +787,24 @@
return isFeatureDefinedInNode(node);
}
if (entity instanceof YangBase) {
- return node.getName().contentEquals(((YangBase) entity).getBaseIdentifier().getName());
+ return node.getName().contentEquals(((YangBase) entity)
+ .getBaseIdentifier()
+ .getName());
}
if (entity instanceof YangIdentityRef) {
- return node.getName().contentEquals(((YangIdentityRef) entity).getName());
+ return node.getName().contentEquals(((YangIdentityRef) entity)
+ .getName());
}
- throw new DataModelException(getErrorMsg(INVALID_RESOLVED_ENTITY, node.getName(),
- node.getLineNumber(), node.getCharPosition(),
- node.getFileName()));
+ throw new DataModelException(getErrorMsg(
+ INVALID_RESOLVED_ENTITY, node.getName(), node.getLineNumber(),
+ node.getCharPosition(), node.getFileName()));
}
private boolean isFeatureDefinedInNode(YangNode node) {
T entity = getCurEntityToResolveFromStack();
YangNodeIdentifier ifFeature = ((YangIfFeature) entity).getName();
- List<YangFeature> featureList = ((YangFeatureHolder) node).getFeatureList();
+ List<YangFeature> featureList = ((YangFeatureHolder) node)
+ .getFeatureList();
if (featureList != null && !featureList.isEmpty()) {
Iterator<YangFeature> iterator = featureList.iterator();
while (iterator.hasNext()) {
@@ -824,14 +830,16 @@
throws DataModelException {
T entity = getCurEntityToResolveFromStack();
if (entity instanceof YangType) {
- YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) ((YangType<?>) entity).getDataTypeExtendedInfo();
+ YangDerivedInfo<?> derivedInfo =
+ (YangDerivedInfo<?>) ((YangType<?>) entity)
+ .getDataTypeExtendedInfo();
derivedInfo.setReferredTypeDef((YangTypeDef) refNode);
} else if (entity instanceof YangUses) {
((YangUses) entity).setRefGroup((YangGrouping) refNode);
} else if (entity instanceof YangBase) {
((YangBase) entity).setReferredIdentity((YangIdentity) refNode);
- addToIdentityExtendList(((YangIdentity) ((YangBase) entity).getParentIdentity()),
- (YangIdentity) refNode);
+ addToIdentityExtendList(((YangIdentity) ((YangBase) entity)
+ .getParentIdentity()), (YangIdentity) refNode);
} else if (entity instanceof YangIdentityRef) {
((YangIdentityRef) entity).setReferredIdentity((YangIdentity) refNode);
} else if (!(entity instanceof YangIfFeature) &&
@@ -892,7 +900,8 @@
refNode.getCharPosition(), refNode.getFileName()));
} else if (entity instanceof YangBase || entity instanceof YangIdentityRef) {
- //Search if the identity has any un resolved base, if so return true, else return false.
+ //Search if the identity has any un resolved base,
+ // if so return true, else return false.
addUnResolvedBaseToStack(refNode);
} else {
throw new DataModelException(getErrorMsg(
@@ -981,7 +990,8 @@
*
* @param partialResolvedInfo partial resolved YANG construct stack
*/
- private void addInPartialResolvedStack(YangEntityToResolveInfoImpl<T> partialResolvedInfo) {
+ private void addInPartialResolvedStack(
+ YangEntityToResolveInfoImpl<T> partialResolvedInfo) {
partialResolvedStack.push(partialResolvedInfo);
}
diff --git a/compiler/base/linker/src/main/java/org/onosproject/yang/compiler/linker/impl/YangXpathLinker.java b/compiler/base/linker/src/main/java/org/onosproject/yang/compiler/linker/impl/YangXpathLinker.java
index 3cb3a85..4a5a7c1 100644
--- a/compiler/base/linker/src/main/java/org/onosproject/yang/compiler/linker/impl/YangXpathLinker.java
+++ b/compiler/base/linker/src/main/java/org/onosproject/yang/compiler/linker/impl/YangXpathLinker.java
@@ -188,7 +188,8 @@
*/
private YangNode getTargetNodeWhenPathSizeIsOne(List<YangAtomicPath> paths) {
if (paths.get(0).getNodeIdentifier().getPrefix() != null &&
- !paths.get(0).getNodeIdentifier().getPrefix().equals(getRootsPrefix(rootNode))) {
+ !paths.get(0).getNodeIdentifier().getPrefix().equals(
+ getRootsPrefix(rootNode))) {
return getImportedNode(rootNode, paths.get(0).getNodeIdentifier());
}
return rootNode;
diff --git a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ContainerListenerTest.java b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ContainerListenerTest.java
index 572131e..5e892db 100644
--- a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ContainerListenerTest.java
+++ b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ContainerListenerTest.java
@@ -31,6 +31,7 @@
import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
import java.io.IOException;
+import java.util.Iterator;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -151,7 +152,7 @@
YangList yangList1 = (YangList) yangNode.getChild();
assertThat(yangList1.getName(), is("ospf"));
- ListIterator<String> keyList = yangList1.getKeyList().listIterator();
+ Iterator<String> keyList = yangList1.getKeyList().iterator();
assertThat(keyList.next(), is("process-id"));
// Check whether the list is child of list
diff --git a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/NamespaceListenerTest.java b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/DefaultYangNamespaceListenerTest.java
similarity index 94%
rename from compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/NamespaceListenerTest.java
rename to compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/DefaultYangNamespaceListenerTest.java
index 1a11053..88c2e6d 100644
--- a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/NamespaceListenerTest.java
+++ b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/DefaultYangNamespaceListenerTest.java
@@ -30,7 +30,7 @@
/**
* Test cases for testing namespace listener functionality.
*/
-public class NamespaceListenerTest {
+public class DefaultYangNamespaceListenerTest {
private final YangUtilsParserManager manager = new YangUtilsParserManager();
@@ -50,7 +50,8 @@
YangNode node = manager.getDataModel("src/test/resources/NamespaceInDoubleQuotes.yang");
// Checks for the version value in data model tree.
- assertThat(((YangModule) node).getModuleNamespace(), is("urn:ietf:params:xml:ns:yang:ietf-ospf"));
+ assertThat(((YangModule) node).getModuleNamespace(),
+ is("urn:ietf:params:xml:ns:yang:ietf-ospf"));
}
/**
diff --git a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/KeyListenerTest.java b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/KeyListenerTest.java
index b526d40..271b5fb 100644
--- a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/KeyListenerTest.java
+++ b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/KeyListenerTest.java
@@ -28,8 +28,8 @@
import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
import java.io.IOException;
-import java.util.List;
-import java.util.ListIterator;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
@@ -65,7 +65,7 @@
YangList yangList = (YangList) yangNode.getChild();
assertThat(yangList.getName(), is("valid"));
- ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ Iterator<String> keyList = yangList.getKeyList().iterator();
assertThat(keyList.next(), is("invalid-interval"));
}
@@ -90,7 +90,7 @@
YangList yangList = (YangList) yangNode.getChild();
assertThat(yangList.getName(), is("valid"));
- List<String> keyList = yangList.getKeyList();
+ LinkedHashSet<String> keyList = yangList.getKeyList();
assertThat(keyList.contains("ospf"), is(true));
assertThat(keyList.contains("isis"), is(true));
}
@@ -138,7 +138,7 @@
YangList yangList = (YangList) yangNode.getChild();
assertThat(yangList.getName(), is("valid"));
- ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ Iterator<String> keyList = yangList.getKeyList().iterator();
assertThat(keyList.next(), is("invalid-interval"));
}
@@ -178,7 +178,7 @@
YangList yangList = (YangList) yangNode.getChild();
assertThat(yangList.getName(), is("valid"));
- ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ Iterator<String> keyList = yangList.getKeyList().iterator();
assertThat(keyList.next(), is("invalid-interval"));
}
@@ -198,7 +198,7 @@
YangList yangList = (YangList) yangNode.getChild().getNextSibling();
assertThat(yangList.getName(), is("valid"));
- ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ Iterator<String> keyList = yangList.getKeyList().iterator();
assertThat(keyList.next(), is("invalid-interval"));
}
diff --git a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ListListenerTest.java b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ListListenerTest.java
index a8d1524..d3154d3 100644
--- a/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ListListenerTest.java
+++ b/compiler/base/parser/src/test/java/org/onosproject/yang/compiler/parser/impl/listeners/ListListenerTest.java
@@ -31,6 +31,7 @@
import org.onosproject.yang.compiler.parser.impl.YangUtilsParserManager;
import java.io.IOException;
+import java.util.Iterator;
import java.util.ListIterator;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -67,7 +68,7 @@
YangList yangList = (YangList) yangNode.getChild();
assertThat(yangList.getName(), is("valid"));
- ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ Iterator<String> keyList = yangList.getKeyList().iterator();
assertThat(keyList.next(), is("invalid-interval"));
}
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/JavaCodeGeneratorUtil.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/JavaCodeGeneratorUtil.java
index 6b1f371..056f851 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/JavaCodeGeneratorUtil.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/JavaCodeGeneratorUtil.java
@@ -16,8 +16,10 @@
package org.onosproject.yang.compiler.translator.tojava;
+import org.onosproject.yang.compiler.datamodel.SchemaDataNode;
import org.onosproject.yang.compiler.datamodel.TraversalType;
import org.onosproject.yang.compiler.datamodel.YangInput;
+import org.onosproject.yang.compiler.datamodel.YangLeavesHolder;
import org.onosproject.yang.compiler.datamodel.YangNode;
import org.onosproject.yang.compiler.datamodel.YangNodeType;
import org.onosproject.yang.compiler.datamodel.YangOutput;
@@ -70,6 +72,10 @@
try {
generateCodeEntry(codeGenNode, yangPlugin, rootNode);
codeGenNode.setNameSpaceAndAddToParentSchemaMap();
+ if (codeGenNode instanceof YangLeavesHolder ||
+ codeGenNode instanceof SchemaDataNode) {
+ codeGenNode.setParentContext();
+ }
} catch (InvalidNodeForTranslatorException e) {
if (codeGenNode.getNextSibling() != null) {
curTraversal = SIBILING;
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaFragmentFiles.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaFragmentFiles.java
index 625f5aa..f3a30b6 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaFragmentFiles.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaFragmentFiles.java
@@ -39,6 +39,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
@@ -696,7 +697,7 @@
*/
public static List<JavaAttributeInfo> getListOfAttributesForKey(
YangNode curNode) throws IOException {
- List<String> keys = ((YangList) curNode).getKeyList();
+ LinkedHashSet<String> keys = ((YangList) curNode).getKeyList();
JavaFileInfoTranslator fileInfo =
((JavaFileInfoContainer) curNode).getJavaFileInfo();
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcCommandFragmentFiles.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcCommandFragmentFiles.java
index c73fa8a..0bd91fb 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcCommandFragmentFiles.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcCommandFragmentFiles.java
@@ -224,6 +224,7 @@
/**
* Returns RPC commands contents.
*
+ * @param curNode YANG RPC node
* @return RPC commands contents
*/
public static String getRpcCommandContents(YangNode curNode) {
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcFragmentFiles.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcFragmentFiles.java
index b886222..21e5f98 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcFragmentFiles.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcFragmentFiles.java
@@ -332,6 +332,7 @@
/**
* Returns register RPC class contents.
*
+ * @param node YANG module node
* @return register RPC class contents
*/
public static String getRegisterRpcContents(YangNode node) {
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGenerator.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGenerator.java
index 96c0649..54d9894 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGenerator.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGenerator.java
@@ -1078,6 +1078,7 @@
* @param file generated file
* @param curNode current YANG node
* @param imports imports for file
+ * @return generated file
* @throws IOException when fails to generate class file
*/
public static File generateRpcExtendedCommand(File file, YangNode curNode,
@@ -1099,6 +1100,7 @@
* @param file generated file
* @param curNode current YANG node
* @param imports imports for file
+ * @return generated file
* @throws IOException when fails to generate class file
*/
public static File generateRpcCommand(File file, YangNode curNode,
@@ -1122,6 +1124,7 @@
* @param file generated file
* @param curNode current YANG node
* @param imports imports for file
+ * @return generated file
* @throws IOException when fails to generate class file
*/
public static File generateRegisterRpc(File file, YangNode curNode,
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGenerator.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGenerator.java
index a5e764d..4e78c71 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGenerator.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/MethodsGenerator.java
@@ -1525,7 +1525,6 @@
.append(getIfConditionForAddToListMethod(attr));
retString = EIGHT_SPACE_INDENTATION + attrName + PERIOD + ADD_STRING +
OPEN_PARENTHESIS + ADD_STRING + TO_CAPS + CLOSE_PARENTHESIS;
-
}
} else {
builder.append(methodSignature(ADD_STRING + TO_CAPS +
@@ -1543,7 +1542,6 @@
.append(signatureClose())
.append(methodClose(FOUR_SPACE));
return builder.toString();
-
}
// Returns if condition for add to list method.
@@ -1573,7 +1571,6 @@
default:
type = ARRAY_LIST_INIT;
break;
-
}
} else {
type = ARRAY_LIST_INIT;
@@ -1939,7 +1936,8 @@
*
* @param name class name
* @param modifierType modifier type
- * @param params parameters for constrcutors
+ * @param params parameters for constructor
+ * @param space space
* @return parameterisied constructor method string
*/
public static String getParaMeterisiedConstructor(String name,
diff --git a/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGen.java b/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGen.java
index 8e5643b..2c6824b 100644
--- a/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGen.java
+++ b/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/io/impl/JavaDocGen.java
@@ -726,6 +726,7 @@
/**
* Returns javadoc for RPC command constructor.
*
+ * @param rpcName rpc name
* @return javadoc for RPC command constructor
*/
public static String getJavaDocForRpcCommandConstructor(String rpcName) {
diff --git a/model/src/main/java/org/onosproject/yang/model/LeafType.java b/model/src/main/java/org/onosproject/yang/model/LeafType.java
index ca6509e..bdd2804 100644
--- a/model/src/main/java/org/onosproject/yang/model/LeafType.java
+++ b/model/src/main/java/org/onosproject/yang/model/LeafType.java
@@ -17,67 +17,53 @@
package org.onosproject.yang.model;
/**
- * Representation of leaf's type.
+ * Represents mapping of java data types with corresponding yang leaf's data
+ * type.
*/
public enum LeafType {
/**
- * Represents JAVA short.
- */
- SHORT,
-
- /**
- * Represents JAVA int.
- */
- INT,
-
- /**
- * Represents JAVA long.
- */
- LONG,
-
- /**
- * Represents JAVA float.
- */
- FLOAT,
-
- /**
- * Represents JAVA double.
- */
- DOUBLE,
-
- /**
- * Represents JAVA boolean.
- */
- BOOLEAN,
-
- /**
- * Represents JAVA char.
- */
- CHAR,
-
- /**
- * Represents JAVA byte.
+ * Represents INT8.
*/
BYTE,
/**
- * Represents JAVA string.
+ * Represents INT16, UINT8.
+ */
+ SHORT,
+
+ /**
+ * Represents UINT16, INT32.
+ */
+ INT,
+
+ /**
+ * Represents UINT32, INT64.
+ */
+ LONG,
+
+ /**
+ * Represents BOOLEAN, EMPTY.
+ */
+ BOOLEAN,
+
+ /**
+ * Represents BITS, IDENTITYREF, ENUMERATION, STRING.
*/
STRING,
/**
- * Represents JAVA big integer.
+ * Represents UINT64.
*/
BIG_INTEGER,
/**
- * Represents JAVA enum type.
+ * Represents BASE64.
*/
- ENUM,
+ BYTE_ARRAY,
/**
- * Represents big decimal.
+ * Represents DECIMAL64.
* The decimal64 type represents a subset of the real numbers, which can
* be represented by decimal numerals. The value space of decimal64 is
* the set of numbers that can be obtained by multiplying a 64-bit
@@ -88,44 +74,7 @@
BIG_DECIMAL,
/**
- * Represents binary. The binary type represents any binary data,
- * i.e., a sequence of octets.
+ * Represents union.
*/
- BINARY,
-
- /**
- * Represents bits. The bits type represents a bit set. That
- * is, a bits value is a set of flags identified by small integer
- * position numbers starting at 0. Each bit number has an assigned name.
- */
- BITS,
-
- /**
- * Represents union type. The union type represents a value that
- * corresponds to one of its member types.
- */
- UNION,
-
- /**
- * The resource identifier type is used to uniquely identify a
- * particular instance node in the data tree.
- */
- RESOURCE_IDENTIFIER,
-
- /**
- * The identityref type is used to reference an existing identity.
- */
- IDENTITY_REF,
-
- /**
- * The leafref type is used to reference a particular leaf instance in
- * the data tree.
- */
- LEAF_REF,
-
- /**
- * The empty type represents a leaf that does not have any
- * value, it conveys information by its presence or absence.
- */
- EMPTY
+ UNION
}
diff --git a/model/src/main/java/org/onosproject/yang/model/MultiInstanceNodeContext.java b/model/src/main/java/org/onosproject/yang/model/MultiInstanceNodeContext.java
new file mode 100644
index 0000000..8ebb6b1
--- /dev/null
+++ b/model/src/main/java/org/onosproject/yang/model/MultiInstanceNodeContext.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.model;
+
+import java.util.Set;
+
+/**
+ * Representation of multi instance node schema context.
+ */
+public interface MultiInstanceNodeContext extends SchemaContext {
+
+ /**
+ * Returns child context.
+ *
+ * @param id schema identifier
+ * @return child schema context
+ * @throws IllegalArgumentException when schema identifier is invalid
+ */
+ SchemaContext getChildContext(SchemaId id);
+
+ /**
+ * Returns ordered set of key leaf name as per the YANG schema.
+ *
+ * @return set of key leaf
+ */
+ Set<String> getKeyLeaf();
+}
diff --git a/model/src/main/java/org/onosproject/yang/model/SchemaId.java b/model/src/main/java/org/onosproject/yang/model/SchemaId.java
index a257f79..4dea0fc 100644
--- a/model/src/main/java/org/onosproject/yang/model/SchemaId.java
+++ b/model/src/main/java/org/onosproject/yang/model/SchemaId.java
@@ -16,6 +16,7 @@
package org.onosproject.yang.model;
+import java.io.Serializable;
import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
@@ -26,7 +27,7 @@
* Representation of an entity which identifies a schema node in the schema /
* data tree.
*/
-public class SchemaId implements Comparable<SchemaId>, Cloneable {
+public class SchemaId implements Comparable<SchemaId>, Cloneable, Serializable {
private String name;
private String nameSpace;
@@ -36,7 +37,6 @@
public SchemaId(String name, String nameSpace) {
checkNotNull(name, INCOMPLETE_SCHEMA_INFO);
- checkNotNull(nameSpace, INCOMPLETE_SCHEMA_INFO);
this.name = name;
this.nameSpace = nameSpace;
}
diff --git a/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistry.java b/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistry.java
index 691cf2d..f5e3a60 100644
--- a/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistry.java
+++ b/runtime/app/src/main/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistry.java
@@ -18,9 +18,16 @@
import org.onosproject.yang.YangModel;
import org.onosproject.yang.YangModuleId;
+import org.onosproject.yang.compiler.datamodel.SchemaDataNode;
+import org.onosproject.yang.compiler.datamodel.YangChoice;
import org.onosproject.yang.compiler.datamodel.YangNode;
import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNodeIdentifier;
import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.SchemaContext;
+import org.onosproject.yang.model.SchemaId;
+import org.onosproject.yang.model.SingleInstanceNodeContext;
import org.onosproject.yang.runtime.api.AppModuleInfo;
import org.onosproject.yang.runtime.api.ModelRegistrationParam;
import org.onosproject.yang.runtime.api.YangModelRegistry;
@@ -34,7 +41,9 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
+import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Collections.sort;
+import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.getNodeIdFromSchemaId;
import static org.onosproject.yang.compiler.plugin.utils.YangApacheUtils.getDateInStringFormat;
import static org.onosproject.yang.runtime.utils.RuntimeHelper.getInterfaceClassName;
import static org.onosproject.yang.runtime.utils.RuntimeHelper.getNodes;
@@ -45,7 +54,7 @@
/**
* Represents YANG model registry implementation.
*/
-public class DefaultYangModelRegistry implements YangModelRegistry {
+public class DefaultYangModelRegistry implements YangModelRegistry, SingleInstanceNodeContext {
private static final Logger log = getLogger(DefaultYangModelRegistry.class);
private static final String AT = "@";
@@ -93,6 +102,11 @@
private final Set<YangModel> models;
/**
+ * Represents the schema id for model registry.
+ */
+ private SchemaId schemaId;
+
+ /**
* Creates an instance of default YANG schema registry.
*/
public DefaultYangModelRegistry() {
@@ -103,6 +117,7 @@
registerClassStore = new ConcurrentHashMap<>();
appNameKeyStore = new ConcurrentHashMap<>();
nameSpaceSchemaStore = new ConcurrentHashMap<>();
+ schemaId = new SchemaId("/", null);
}
@Override
@@ -128,6 +143,7 @@
}
}
}
+ updateChildContext(curNodes);
} else {
throw new RuntimeException("model can not be null.");
}
@@ -154,17 +170,20 @@
if (curNode != null) {
removeSchemaNode(curNode);
- interfaceNameKeyStore.remove(getInterfaceClassName(curNode));
- opParamNameKeyStore.remove(getOpParamClassName(curNode));
+ interfaceNameKeyStore.remove(
+ getInterfaceClassName(curNode));
+ opParamNameKeyStore.remove(
+ getOpParamClassName(curNode));
appNameKeyStore.remove(serviceName);
- nameSpaceSchemaStore.remove(curNode.getNameSpace()
- .getModuleNamespace());
+ nameSpaceSchemaStore.remove(
+ curNode.getNameSpace().getModuleNamespace());
log.info(" service class {} of model {} is " +
"unregistered.", sClass
.getSimpleName(), param);
} else {
- throw new RuntimeException(sClass.getSimpleName() +
- " service was not registered.");
+ throw new RuntimeException(
+ sClass.getSimpleName() +
+ " service was not registered.");
}
}
} else {
@@ -276,7 +295,8 @@
private void processRegistration(Class<?> service, Set<YangNode> nodes) {
// process storing operations.
- YangNode schemaNode = findNodeWhichShouldBeReg(service.getName(), nodes);
+ YangNode schemaNode = findNodeWhichShouldBeReg(service.getName(),
+ nodes);
if (schemaNode != null) {
//Process application context for registrations.
processApplicationContext(schemaNode, service.getName());
@@ -319,7 +339,8 @@
* @param appNode application YANG schema nodes
* @param name class name
*/
- private void processApplicationContext(YangSchemaNode appNode, String name) {
+ private void processApplicationContext(YangSchemaNode appNode,
+ String name) {
//Update map for which registrations is being called.
try {
@@ -340,7 +361,8 @@
opParamNameKeyStore.put(getOpParamClassName(appNode), appNode);
//update namespaceSchema store.
- nameSpaceSchemaStore.put(appNode.getNameSpace().getModuleNamespace(), appNode);
+ nameSpaceSchemaStore.put(appNode.getNameSpace().getModuleNamespace(),
+ appNode);
log.info("successfully registered this application {}", name);
}
@@ -378,7 +400,8 @@
return null;
}
- private String getLatestVersion(ConcurrentMap<String, YangSchemaNode> revMap) {
+ private String getLatestVersion(ConcurrentMap<String,
+ YangSchemaNode> revMap) {
List<String> keys = new ArrayList<>();
for (Map.Entry<String, YangSchemaNode> entry : revMap.entrySet()) {
keys.add(entry.getKey());
@@ -423,11 +446,114 @@
if (date != null) {
revName = name + AT + date;
}
- ConcurrentMap<String, YangSchemaNode> revMap = yangSchemaStore.get(name);
+ ConcurrentMap<String, YangSchemaNode> revMap =
+ yangSchemaStore.get(name);
if (revMap != null && !revMap.isEmpty() && revMap.size() != 1) {
revMap.remove(revName);
} else {
yangSchemaStore.remove(removableNode.getName());
}
}
+
+ @Override
+ public SchemaContext getParentContext() {
+ return null;
+ }
+
+ @Override
+ public DataNode.Type getType() {
+ return DataNode.Type.SINGLE_INSTANCE_NODE;
+ }
+
+ @Override
+ public SchemaId getSchemaId() {
+ return schemaId;
+ }
+
+ /**
+ * Updates child's context. It sets itself as a parent context for first
+ * level child's in module/sub-module.
+ *
+ * @param nodes set of module/submodule nodes
+ */
+ public void updateChildContext(Set<YangNode> nodes) {
+ // Preparing schema id for logical node with name "/"
+ for (YangNode node : nodes) {
+ node.setLeafRootContext(this);
+ YangNode child = node.getChild();
+ while (child != null) {
+ if (child instanceof YangChoice) {
+ updateSchemaContextForChoiceChild(child);
+ } else if (child instanceof SchemaDataNode) {
+ child.setRootContext(this);
+ }
+ child = child.getNextSibling();
+ }
+ }
+ }
+
+ /**
+ * Updates the parent context for given choice-case node child's.
+ *
+ * @param child yang node
+ */
+ private void updateContextForChoiceCase(YangNode child) {
+ while (child != null) {
+ if (child instanceof YangChoice) {
+ updateSchemaContextForChoiceChild(child);
+ } else if (child instanceof SchemaDataNode) {
+ child.setRootContext(this);
+ }
+ child = child.getNextSibling();
+ }
+ }
+
+ /**
+ * Updates the parent context for given choice node child's.
+ *
+ * @param curNode choice node
+ */
+ public void updateSchemaContextForChoiceChild(YangNode curNode) {
+ YangNode child = curNode.getChild();
+ // Setting the parent context for case
+ while (child != null) {
+ updateSchemaContextForCaseChild(child);
+ child = child.getNextSibling();
+ }
+ }
+
+ /**
+ * Updates the parent context for given case node child's.
+ *
+ * @param curNode case node
+ */
+ public void updateSchemaContextForCaseChild(YangNode curNode) {
+ curNode.setLeafRootContext(this);
+ YangNode child = curNode.getChild();
+ updateContextForChoiceCase(child);
+ }
+
+ @Override
+ public SchemaContext getChildContext(SchemaId schemaId) {
+
+ checkNotNull(schemaId);
+ if (schemaId.namespace() == null) {
+ log.error("node with {} namespace not found.",
+ schemaId.namespace());
+ }
+
+ String namespace = schemaId.namespace();
+ YangSchemaNode node = getForNameSpace(namespace);
+ YangSchemaNodeIdentifier id = getNodeIdFromSchemaId(
+ schemaId, namespace);
+
+ try {
+ if (node != null) {
+ return node.getChildSchema(id).getSchemaNode();
+ }
+ } catch (DataModelException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
}
diff --git a/runtime/app/src/test/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistryTest.java b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistryTest.java
index 92f542c..baa6e7b 100644
--- a/runtime/app/src/test/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistryTest.java
+++ b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/DefaultYangModelRegistryTest.java
@@ -194,7 +194,6 @@
assertThat(true, is(yangNode == null));
//Here the yangNode should be the node which does not have revision.
-
// asset should pass with false.
yangNode = registry.getForSchemaName(SCHEMA_NAME_4);
assertThat(true, is(((YangNode) yangNode).getRevision() == null));
diff --git a/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestCaseSchemaContext.java b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestCaseSchemaContext.java
new file mode 100644
index 0000000..136fd58
--- /dev/null
+++ b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestCaseSchemaContext.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.app;
+
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.DefaultYangNamespace;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangLeafList;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
+import org.onosproject.yang.model.SchemaId;
+
+import static org.onosproject.yang.model.DataNode.Type.MULTI_INSTANCE_NODE;
+import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_NODE;
+import static org.onosproject.yang.runtime.app.TestUtils.checkLeafListSchemaContext;
+import static org.onosproject.yang.runtime.app.TestUtils.checkLeafSchemaContext;
+import static org.onosproject.yang.runtime.app.TestUtils.checkSchemaContext;
+
+/**
+ * Tests the default schema context methods.
+ */
+public class TestCaseSchemaContext {
+
+ private static TestYangSchemaNodeProvider schemaProvider =
+ new TestYangSchemaNodeProvider();
+
+ public static final String CASENS = "yrt:choice-case";
+
+ /**
+ * Checks module level choice-case data node parent context.
+ */
+ @Test
+ public void caseSchemaContTest() throws DataModelException {
+
+ schemaProvider.processSchemaRegistry();
+ DefaultYangModelRegistry registry = schemaProvider.registry();
+ SchemaId id = new SchemaId("pretzel", CASENS);
+ YangLeaf leaf = (YangLeaf) registry.getChildContext(id);
+ checkLeafSchemaContext("pretzel", CASENS, "/", null, leaf);
+
+ id = new SchemaId("light", CASENS);
+ leaf = (YangLeaf) registry.getChildContext(id);
+ checkLeafSchemaContext("light", CASENS, "/", null, leaf);
+
+ id = new SchemaId("potato", CASENS);
+ YangLeafList leafList = (YangLeafList) registry.getChildContext(id);
+ checkLeafListSchemaContext("potato", CASENS, "/", null,
+ leafList);
+
+ id = new SchemaId("banana", CASENS);
+ YangNode child = (YangNode) registry.getChildContext(id);
+ checkSchemaContext("banana", CASENS, "/", null,
+ MULTI_INSTANCE_NODE, child);
+
+ id = new SchemaId("cold-drink", CASENS);
+ child = (YangNode) registry.getChildContext(id);
+ checkSchemaContext("cold-drink", CASENS, "/", null,
+ SINGLE_INSTANCE_NODE, child);
+
+ YangSchemaNodeIdentifier rId = new YangSchemaNodeIdentifier();
+ rId.setName("flavor");
+ rId.setNameSpace(new DefaultYangNamespace(CASENS));
+ leafList = (YangLeafList) child.getChildSchema(rId).getSchemaNode();
+ checkLeafListSchemaContext("flavor", CASENS, "cold-drink", CASENS,
+ leafList);
+ }
+}
diff --git a/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestLeafSchemaContext.java b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestLeafSchemaContext.java
new file mode 100644
index 0000000..d11e930
--- /dev/null
+++ b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestLeafSchemaContext.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.app;
+
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.DefaultYangNamespace;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangLeafList;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
+import org.onosproject.yang.compiler.datamodel.YangSchemaNodeIdentifier;
+import org.onosproject.yang.compiler.datamodel.exceptions.DataModelException;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.SchemaId;
+
+import static org.onosproject.yang.runtime.app.TestUtils.checkLeafListSchemaContext;
+import static org.onosproject.yang.runtime.app.TestUtils.checkLeafSchemaContext;
+import static org.onosproject.yang.runtime.app.TestUtils.checkSchemaContext;
+
+/**
+ * Tests the default schema context methods.
+ */
+public class TestLeafSchemaContext {
+
+ private static TestYangSchemaNodeProvider schemaProvider =
+ new TestYangSchemaNodeProvider();
+
+ public static final String FOODNS = "yrt:food";
+
+ /**
+ * Checks leaf, leaf-list, choice-case data node parent context.
+ */
+ @Test
+ public void leafSchemaContTest() throws DataModelException {
+
+ schemaProvider.processSchemaRegistry();
+ DefaultYangModelRegistry registry = schemaProvider.registry();
+ SchemaId id = new SchemaId("food", FOODNS);
+ YangNode child = (YangNode) registry.getChildContext(id);
+ checkSchemaContext("food", FOODNS, "/", null,
+ DataNode.Type.SINGLE_INSTANCE_NODE, child);
+
+ YangSchemaNodeIdentifier rId = new YangSchemaNodeIdentifier();
+ rId.setName("pretzel");
+ rId.setNameSpace(new DefaultYangNamespace(FOODNS));
+ YangSchemaNode leaf1 = child.getChildSchema(rId).getSchemaNode();
+ checkLeafSchemaContext("pretzel", FOODNS, "food", FOODNS,
+ (YangLeaf) leaf1);
+
+ rId.setName("redbull");
+ leaf1 = child.getChildSchema(rId).getSchemaNode();
+ checkLeafSchemaContext("redbull", FOODNS, "food", FOODNS,
+ (YangLeaf) leaf1);
+
+ rId.setName("kingfisher");
+ leaf1 = child.getChildSchema(rId).getSchemaNode();
+ checkLeafSchemaContext("kingfisher", FOODNS, "food", FOODNS,
+ (YangLeaf) leaf1);
+
+ id = new SchemaId("bool", FOODNS);
+ YangLeaf leaf = (YangLeaf) registry.getChildContext(id);
+ checkLeafSchemaContext("bool", FOODNS, "/", null,
+ leaf);
+
+ id = new SchemaId("boolean", FOODNS);
+ YangLeafList leafList = (YangLeafList) registry.getChildContext(id);
+ checkLeafListSchemaContext("boolean", FOODNS, "/", null,
+ leafList);
+ }
+}
diff --git a/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestRpcSchemaContext.java b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestRpcSchemaContext.java
new file mode 100644
index 0000000..7968b2d
--- /dev/null
+++ b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestRpcSchemaContext.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.app;
+
+/**
+ * Tests the default schema context methods.
+ */
+public class TestRpcSchemaContext {
+
+ //TODO : need to be updated afetr RPC implementation
+
+// private static TestYangSchemaNodeProvider schemaProvider =
+// new TestYangSchemaNodeProvider();
+//
+// public static final String HELLONS = "urn:yrt-hello_onos";
+// public static final String FOODNS = "yrt:food";
+// public static final String CASENS = "yrt:choice-case";
+//
+// /**
+// * Checks rpc, input, output data node parent context.
+// */
+// @Test
+// public void rpcDataNodeSchContTest() {
+//
+// schemaProvider.processSchemaRegistry();
+// DefaultYangModelRegistry registry = schemaProvider.registry();
+// SchemaId id = new SchemaId("hello-world", HELLONS);
+// YangNode child = (YangNode) registry.getChildContext(id);
+// checkSchemaContext("hello-world", HELLONS, "/", null,
+// DataNode.Type.SINGLE_INSTANCE_NODE, child);
+//
+// // Validating input node parent context.
+// child = child.getChild();
+// checkSchemaContext("input", HELLONS, "hello-world", HELLONS,
+// DataNode.Type.SINGLE_INSTANCE_NODE, child);
+//
+// List<YangLeafList> leafList = ((YangLeavesHolder) child)
+// .getListOfLeafList();
+// checkLeafListSchemaContext("stringList", HELLONS, "input",
+// HELLONS,
+// leafList.get(0));
+//
+// // Validating output node parent context.
+// child = child.getNextSibling();
+// checkSchemaContext("output", HELLONS, "hello-world", HELLONS,
+// DataNode.Type.SINGLE_INSTANCE_NODE, child);
+//
+// List<YangLeaf> leafs = ((YangLeavesHolder) child).getListOfLeaf();
+// checkLeafSchemaContext("greetingOut", HELLONS, "output", HELLONS,
+// leafs.get(0));
+// }
+}
diff --git a/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestSchemaContext.java b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestSchemaContext.java
new file mode 100644
index 0000000..2c2605a
--- /dev/null
+++ b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestSchemaContext.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yang.runtime.app;
+
+import org.junit.Test;
+import org.onosproject.yang.compiler.datamodel.YangAugment;
+import org.onosproject.yang.compiler.datamodel.YangAugmentableNode;
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangLeavesHolder;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.SchemaId;
+
+import java.util.List;
+
+import static org.onosproject.yang.runtime.app.TestUtils.checkLeafSchemaContext;
+import static org.onosproject.yang.runtime.app.TestUtils.checkSchemaContext;
+
+/**
+ * Tests the default schema context methods.
+ */
+public class TestSchemaContext {
+
+ private static TestYangSchemaNodeProvider schemaProvider =
+ new TestYangSchemaNodeProvider();
+
+ public static final String IETFNS =
+ "urn:ietf:params:xml:ns:yang:yrt-ietf-network";
+ public static final String TOPONS =
+ "urn:ietf:params:xml:ns:yang:yrt-ietf-network-topology";
+
+ /**
+ * Validates the getting schema context by schema Id scenario.
+ */
+ @Test
+ public void schemaContextBySchemaIdTest() {
+
+ schemaProvider.processSchemaRegistry();
+ DefaultYangModelRegistry registry = schemaProvider.registry();
+ SchemaId id = new SchemaId("networks", IETFNS);
+ YangNode child = (YangNode) registry.getChildContext(id);
+ checkSchemaContext("networks", IETFNS, "/", null,
+ DataNode.Type.SINGLE_INSTANCE_NODE, child);
+
+ // Validating networks parent context.
+ child = child.getChild();
+ checkSchemaContext("network", IETFNS, "networks", IETFNS,
+ DataNode.Type.MULTI_INSTANCE_NODE, child);
+ List<YangAugment> augInfo = ((YangAugmentableNode) child)
+ .getAugmentedInfoList();
+ YangAugment augNode = augInfo.get(0);
+
+ // Checking the augmented node parent context.
+ checkSchemaContext("link", TOPONS, "network", IETFNS,
+ DataNode.Type.MULTI_INSTANCE_NODE,
+ augNode.getChild());
+
+ List<YangLeaf> leafs = ((YangLeavesHolder) augNode.getChild())
+ .getListOfLeaf();
+ checkLeafSchemaContext("link-id", TOPONS, "link", TOPONS,
+ leafs.get(0));
+
+ // Validating network-types parent context.
+ child = child.getChild();
+ checkSchemaContext("network-types", IETFNS, "network", IETFNS,
+ DataNode.Type.SINGLE_INSTANCE_NODE, child);
+
+ child = child.getParent();
+ leafs = ((YangLeavesHolder) child).getListOfLeaf();
+ for (YangLeaf leaf : leafs) {
+ checkLeafSchemaContext("network-id", IETFNS, "network", IETFNS,
+ leaf);
+ }
+
+ child = child.getParent().getNextSibling();
+ checkSchemaContext("networks-state", IETFNS, "/", null,
+ DataNode.Type.SINGLE_INSTANCE_NODE, child);
+ child = child.getChild();
+
+ checkSchemaContext("network", IETFNS, "networks-state", IETFNS,
+ DataNode.Type.MULTI_INSTANCE_NODE, child);
+ leafs = ((YangLeavesHolder) child).getListOfLeaf();
+ checkLeafSchemaContext("network-ref", IETFNS, "network", IETFNS,
+ leafs.get(1));
+ }
+}
diff --git a/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestUtils.java b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestUtils.java
new file mode 100644
index 0000000..a69dc02
--- /dev/null
+++ b/runtime/app/src/test/java/org/onosproject/yang/runtime/app/TestUtils.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.yang.runtime.app;
+
+import org.onosproject.yang.compiler.datamodel.YangLeaf;
+import org.onosproject.yang.compiler.datamodel.YangLeafList;
+import org.onosproject.yang.compiler.datamodel.YangNode;
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.SchemaId;
+
+import static org.junit.Assert.assertEquals;
+import static org.onosproject.yang.model.DataNode.Type.MULTI_INSTANCE_LEAF_VALUE_NODE;
+import static org.onosproject.yang.model.DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE;
+
+public final class TestUtils {
+
+ /**
+ * Restricts creation of test utils instance.
+ */
+ private TestUtils() {
+ }
+
+ /**
+ * Checks the schema context values of given leaf node.
+ */
+ static void checkLeafSchemaContext(String name, String namespace,
+ String pname, String pnamespace,
+ YangLeaf child) {
+ SchemaId id = child.getSchemaId();
+ assertEquals(id.name(), name);
+ assertEquals(id.namespace(), namespace);
+
+ id = child.getParentContext().getSchemaId();
+ assertEquals(id.name(), pname);
+ assertEquals(id.namespace(), pnamespace);
+ assertEquals(child.getType(), SINGLE_INSTANCE_LEAF_VALUE_NODE);
+ }
+
+ /**
+ * Checks the schema context values of given leaf list node.
+ */
+ static void checkLeafListSchemaContext(String name, String namespace,
+ String pname, String pnamespace,
+ YangLeafList child) {
+ SchemaId id = child.getSchemaId();
+ assertEquals(id.name(), name);
+ assertEquals(id.namespace(), namespace);
+
+ id = child.getParentContext().getSchemaId();
+ assertEquals(id.name(), pname);
+ assertEquals(id.namespace(), pnamespace);
+ assertEquals(child.getType(), MULTI_INSTANCE_LEAF_VALUE_NODE);
+ }
+
+ /**
+ * Checks the schema context values of given node.
+ */
+ static void checkSchemaContext(String name, String namespace,
+ String pname, String pnamespace,
+ DataNode.Type type, YangNode child) {
+ SchemaId id = child.getSchemaId();
+ assertEquals(id.name(), name);
+ assertEquals(id.namespace(), namespace);
+
+ id = child.getParentContext().getSchemaId();
+ assertEquals(id.name(), pname);
+ assertEquals(id.namespace(), pnamespace);
+ assertEquals(child.getType(), type);
+ }
+}
diff --git a/runtime/app/src/test/resources/schemaProviderTestYangFiles/choice-case.yang b/runtime/app/src/test/resources/schemaProviderTestYangFiles/choice-case.yang
new file mode 100644
index 0000000..66b2f8a
--- /dev/null
+++ b/runtime/app/src/test/resources/schemaProviderTestYangFiles/choice-case.yang
@@ -0,0 +1,65 @@
+module choice-case {
+
+ yang-version 1;
+
+ namespace "yrt:choice-case";
+
+ prefix "choice";
+
+ organization "ON-LAB";
+
+ description "This module defines for choice-case.";
+
+ revision "2016-06-24" {
+ description "Initial revision.";
+ }
+
+ choice snack {
+ case sportsarena {
+
+ leaf pretzel {
+ type empty;
+ }
+
+ choice bear {
+ case type {
+ leaf light {
+ type empty;
+ }
+ }
+
+ case add-on {
+ choice snacks {
+ case chips {
+ leaf-list potato {
+ type empty;
+ }
+
+ list banana {
+ config false;
+ leaf l1 {
+ type string;
+ }
+ }
+
+ container cold-drink {
+ leaf-list flavor {
+ type string;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ case latenight {
+ leaf chocolate {
+ type enumeration {
+ enum dark;
+ enum milk;
+ enum first-available;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/runtime/app/src/test/resources/schemaProviderTestYangFiles/food.yang b/runtime/app/src/test/resources/schemaProviderTestYangFiles/food.yang
new file mode 100644
index 0000000..b340438
--- /dev/null
+++ b/runtime/app/src/test/resources/schemaProviderTestYangFiles/food.yang
@@ -0,0 +1,56 @@
+module food {
+
+ yang-version 1;
+
+ namespace "yrt:food";
+
+ prefix "foodType";
+
+ organization "ON-LAB";
+
+ description "This module defines for food.";
+
+ revision "2016-06-24" {
+ description "Initial revision.";
+ }
+
+ container food {
+ choice snack {
+ case sportsarena {
+
+ leaf pretzel {
+ type empty;
+ }
+
+ choice bear {
+ case type {
+ leaf kingfisher {
+ type empty;
+ }
+
+ leaf redbull {
+ type empty;
+ }
+ }
+ }
+ }
+ case latenight {
+ leaf chocolate {
+ type enumeration {
+ enum dark;
+ enum milk;
+ enum first-available;
+ }
+ }
+ }
+ }
+ }
+
+ leaf bool {
+ type boolean;
+ }
+
+ leaf-list boolean {
+ type boolean;
+ }
+}
\ No newline at end of file
diff --git a/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-inet-types.yang b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-inet-types.yang
new file mode 100644
index 0000000..7b50fc3
--- /dev/null
+++ b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-inet-types.yang
@@ -0,0 +1,454 @@
+ module yrt-ietf-inet-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:yrt-ietf-inet-types";
+
+ prefix inet;
+
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+
+ WG Chair: David Kessens
+ <mailto:david.kessens@nsn.com>
+
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+
+ description
+ "This module contains a collection of generally useful derived
+ YANG data types for Internet addresses and related things.
+
+ Copyright (c) 2013 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of RFC 6991; see
+ the RFC itself for full legal notices.";
+
+ revision "2013-07-15" {
+ description
+ "This revision adds the following new data types:
+ - ip-address-no-zone
+ - ipv4-address-no-zone
+ - ipv6-address-no-zone";
+ reference
+ "RFC 6991: Common YANG Data Types";
+
+ }
+
+ revision "2010-09-24" {
+ description "Initial revision.";
+ reference
+ "RFC 6021: Common YANG Data Types";
+
+ }
+
+
+ typedef ip-version {
+ type enumeration {
+ enum "unknown" {
+ value 0;
+ description
+ "An unknown or unspecified version of the Internet
+ protocol.";
+ }
+ enum "ipv4" {
+ value 1;
+ description
+ "The IPv4 protocol as defined in RFC 791.";
+ }
+ enum "ipv6" {
+ value 2;
+ description
+ "The IPv6 protocol as defined in RFC 2460.";
+ }
+ }
+ description
+ "This value represents the version of the IP protocol.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetVersion textual convention of the SMIv2.";
+ reference
+ "RFC 791: Internet Protocol
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef dscp {
+ type uint8 {
+ range "0..63";
+ }
+ description
+ "The dscp type represents a Differentiated Services Code Point
+ that may be used for marking packets in a traffic stream.
+ In the value set and its semantics, this type is equivalent
+ to the Dscp textual convention of the SMIv2.";
+ reference
+ "RFC 3289: Management Information Base for the Differentiated
+ Services Architecture
+ RFC 2474: Definition of the Differentiated Services Field
+ (DS Field) in the IPv4 and IPv6 Headers
+ RFC 2780: IANA Allocation Guidelines For Values In
+ the Internet Protocol and Related Headers";
+
+ }
+
+ typedef ipv6-flow-label {
+ type uint32 {
+ range "0..1048575";
+ }
+ description
+ "The ipv6-flow-label type represents the flow identifier or Flow
+ Label in an IPv6 packet header that may be used to
+ discriminate traffic flows.
+
+ In the value set and its semantics, this type is equivalent
+ to the IPv6FlowLabel textual convention of the SMIv2.";
+ reference
+ "RFC 3595: Textual Conventions for IPv6 Flow Label
+ RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
+
+ }
+
+ typedef port-number {
+ type uint16 {
+ range "0..65535";
+ }
+ description
+ "The port-number type represents a 16-bit port number of an
+ Internet transport-layer protocol such as UDP, TCP, DCCP, or
+ SCTP. Port numbers are assigned by IANA. A current list of
+ all assignments is available from <http://www.iana.org/>.
+
+ Note that the port number value zero is reserved by IANA. In
+ situations where the value zero does not make sense, it can
+ be excluded by subtyping the port-number type.
+ In the value set and its semantics, this type is equivalent
+ to the InetPortNumber textual convention of the SMIv2.";
+ reference
+ "RFC 768: User Datagram Protocol
+ RFC 793: Transmission Control Protocol
+ RFC 4960: Stream Control Transmission Protocol
+ RFC 4340: Datagram Congestion Control Protocol (DCCP)
+ RFC 4001: Textual Conventions for Internet Network Addresses";
+
+ }
+
+ typedef as-number {
+ type uint32;
+ description
+ "The as-number type represents autonomous system numbers
+ which identify an Autonomous System (AS). An AS is a set
+ of routers under a single technical administration, using
+ an interior gateway protocol and common metrics to route
+ packets within the AS, and using an exterior gateway
+ protocol to route packets to other ASes. IANA maintains
+ the AS number space and has delegated large parts to the
+ regional registries.
+
+ Autonomous system numbers were originally limited to 16
+ bits. BGP extensions have enlarged the autonomous system
+ number space to 32 bits. This type therefore uses an uint32
+ base type without a range restriction in order to support
+ a larger autonomous system number space.
+
+ In the value set and its semantics, this type is equivalent
+ to the InetAutonomousSystemNumber textual convention of
+ the SMIv2.";
+ reference
+ "RFC 1930: Guidelines for creation, selection, and registration
+ of an Autonomous System (AS)
+ RFC 4271: A Border Gateway Protocol 4 (BGP-4)
+ RFC 4001: Textual Conventions for Internet Network Addresses
+ RFC 6793: BGP Support for Four-Octet Autonomous System (AS)
+ Number Space";
+
+ }
+
+ typedef ip-address {
+ type union {
+ type ipv4-address;
+ type ipv6-address;
+ }
+ description
+ "The ip-address type represents an IP address and is IP
+ version neutral. The format of the textual representation
+ implies the IP version. This type supports scoped addresses
+ by allowing zone identifiers in the address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(%[\p{N}\p{L}]+)?';
+ }
+ description
+ "The ipv4-address type represents an IPv4 address in
+ dotted-quad notation. The IPv4 address may include a zone
+ index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+ The canonical format for the zone index is the numerical
+ format";
+ }
+
+ typedef ipv6-address {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(%[\p{N}\p{L}]+)?';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(%.+)?';
+ }
+ description
+ "The ipv6-address type represents an IPv6 address in full,
+ mixed, shortened, and shortened-mixed notation. The IPv6
+ address may include a zone index, separated by a % sign.
+
+ The zone index is used to disambiguate identical address
+ values. For link-local addresses, the zone index will
+ typically be the interface index number or the name of an
+ interface. If the zone index is not present, the default
+ zone of the device will be used.
+
+
+
+ The canonical format of IPv6 addresses uses the textual
+ representation defined in Section 4 of RFC 5952. The
+ canonical format for the zone index is the numerical
+ format as described in Section 11.2 of RFC 4007.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-address-no-zone {
+ type union {
+ type ipv4-address-no-zone;
+ type ipv6-address-no-zone;
+ }
+ description
+ "The ip-address-no-zone type represents an IP address and is
+ IP version neutral. The format of the textual representation
+ implies the IP version. This type does not support scoped
+ addresses since it does not allow zone identifiers in the
+ address format.";
+ reference
+ "RFC 4007: IPv6 Scoped Address Architecture";
+
+ }
+
+ typedef ipv4-address-no-zone {
+ type ipv4-address {
+ pattern '[0-9\.]*';
+ }
+ description
+ "An IPv4 address without a zone index. This type, derived from
+ ipv4-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ }
+
+ typedef ipv6-address-no-zone {
+ type ipv6-address {
+ pattern '[0-9a-fA-F:\.]*';
+ }
+ description
+ "An IPv6 address without a zone index. This type, derived from
+ ipv6-address, may be used in situations where the zone is
+ known from the context and hence no zone index is needed.";
+ reference
+ "RFC 4291: IP Version 6 Addressing Architecture
+ RFC 4007: IPv6 Scoped Address Architecture
+ RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef ip-prefix {
+ type union {
+ type ipv4-prefix;
+ type ipv6-prefix;
+ }
+ description
+ "The ip-prefix type represents an IP prefix and is IP
+ version neutral. The format of the textual representations
+ implies the IP version.";
+ }
+
+ typedef ipv4-prefix {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])/(([0-9])|([1-2][0-9])|(3[0-2]))';
+ }
+ description
+ "The ipv4-prefix type represents an IPv4 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 32.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The canonical format of an IPv4 prefix has all bits of
+ the IPv4 address set to zero that are not part of the
+ IPv4 prefix.";
+ }
+
+ typedef ipv6-prefix {
+ type string {
+ pattern
+ '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
+ pattern
+ '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)(/.+)';
+ }
+ description
+ "The ipv6-prefix type represents an IPv6 address prefix.
+ The prefix length is given by the number following the
+ slash character and must be less than or equal to 128.
+
+ A prefix length value of n corresponds to an IP address
+ mask that has n contiguous 1-bits from the most
+ significant bit (MSB) and all other bits set to 0.
+
+ The IPv6 address should have all bits that do not belong
+ to the prefix set to zero.
+
+ The canonical format of an IPv6 prefix has all bits of
+ the IPv6 address set to zero that are not part of the
+ IPv6 prefix. Furthermore, the IPv6 address is represented
+ as defined in Section 4 of RFC 5952.";
+ reference
+ "RFC 5952: A Recommendation for IPv6 Address Text
+ Representation";
+
+ }
+
+ typedef domain-name {
+ type string {
+ length "1..253";
+ pattern
+ '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)|\.';
+ }
+ description
+ "The domain-name type represents a DNS domain name. The
+ name SHOULD be fully qualified whenever possible.
+
+ Internet domain names are only loosely specified. Section
+ 3.5 of RFC 1034 recommends a syntax (modified in Section
+ 2.1 of RFC 1123). The pattern above is intended to allow
+ for current practice in domain name use, and some possible
+ future expansion. It is designed to hold various types of
+ domain names, including names used for A or AAAA records
+ (host names) and other records, such as SRV records. Note
+ that Internet host names have a stricter syntax (described
+ in RFC 952) than the DNS recommendations in RFCs 1034 and
+ 1123, and that systems that want to store host names in
+ schema nodes using the domain-name type are recommended to
+ adhere to this stricter standard to ensure interoperability.
+
+ The encoding of DNS names in the DNS protocol is limited
+ to 255 characters. Since the encoding consists of labels
+ prefixed by a length bytes and there is a trailing NULL
+ byte, only 253 characters can appear in the textual dotted
+ notation.
+
+ The description clause of schema nodes using the domain-name
+ type MUST describe when and how these names are resolved to
+ IP addresses. Note that the resolution of a domain-name value
+ may require to query multiple DNS records (e.g., A for IPv4
+ and AAAA for IPv6). The order of the resolution process and
+ which DNS record takes precedence can either be defined
+ explicitly or may depend on the configuration of the
+ resolver.
+
+ Domain-name values use the US-ASCII encoding. Their canonical
+ format uses lowercase US-ASCII characters. Internationalized
+ domain names MUST be A-labels as per RFC 5890.";
+ reference
+ "RFC 952: DoD Internet Host Table Specification
+ RFC 1034: Domain Names - Concepts and Facilities
+ RFC 1123: Requirements for Internet Hosts -- Application
+ and Support
+ RFC 2782: A DNS RR for specifying the location of services
+ (DNS SRV)
+ RFC 5890: Internationalized Domain Names in Applications
+ (IDNA): Definitions and Document Framework";
+
+ }
+
+ typedef host {
+ type union {
+ type ip-address;
+ type domain-name;
+ }
+ description
+ "The host type represents either an IP address or a DNS
+ domain name.";
+ }
+
+ typedef uri {
+ type string;
+ description
+ "The uri type represents a Uniform Resource Identifier
+ (URI) as defined by STD 66.
+
+ Objects using the uri type MUST be in US-ASCII encoding,
+ and MUST be normalized as described by RFC 3986 Sections
+ 6.2.1, 6.2.2.1, and 6.2.2.2. All unnecessary
+ percent-encoding is removed, and all case-insensitive
+ characters are set to lowercase except for hexadecimal
+ digits, which are normalized to uppercase as described in
+ Section 6.2.2.1.
+
+ The purpose of this normalization is to help provide
+ unique URIs. Note that this normalization is not
+ sufficient to provide uniqueness. Two URIs that are
+ textually distinct after this normalization may still be
+ equivalent.
+
+ Objects using the uri type may restrict the schemes that
+ they permit. For example, 'data:' and 'urn:' schemes
+ might not be appropriate.
+
+ A zero-length URI is not a valid URI. This can be used to
+ express 'URI absent' where required.
+
+ In the value set and its semantics, this type is equivalent
+ to the Uri SMIv2 textual convention defined in RFC 5017.";
+ reference
+ "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
+ RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
+ Group: Uniform Resource Identifiers (URIs), URLs,
+ and Uniform Resource Names (URNs): Clarifications
+ and Recommendations
+ RFC 5017: MIB Textual Conventions for Uniform Resource
+ Identifiers (URIs)";
+
+ }
+ } // module ietf-inet-types
diff --git a/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-network.yang b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-network.yang
new file mode 100644
index 0000000..009a40c
--- /dev/null
+++ b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-network.yang
@@ -0,0 +1,216 @@
+ module yrt-ietf-network {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:yrt-ietf-network";
+ prefix nd;
+
+ import yrt-ietf-inet-types {
+ prefix inet;
+ }
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/i2rs/>
+ WG List: <mailto:i2rs@ietf.org>
+
+ WG Chair: Susan Hares
+ <mailto:shares@ndzh.com>
+
+ WG Chair: Jeffrey Haas
+ <mailto:jhaas@pfrc.org>
+
+ Editor: Alexander Clemm
+ <mailto:alex@cisco.com>
+
+ Editor: Jan Medved
+ <mailto:jmedved@cisco.com>
+
+ Editor: Robert Varga
+ <mailto:rovarga@cisco.com>
+
+ Editor: Tony Tkacik
+ <mailto:ttkacik@cisco.com>
+
+ Editor: Nitin Bahadur
+ <mailto:nitin_bahadur@yahoo.com>
+
+ Editor: Hariharan Ananthakrishnan
+ <mailto:hari@packetdesign.com>";
+
+ description
+ "This module defines a common base model for a collection
+ of nodes in a network. Node definitions are further used
+ in network topologies and inventories.
+
+ Copyright (c) 2015 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of
+ draft-ietf-i2rs-yang-network-topo-02;
+ see the RFC itself for full legal notices.
+
+ NOTE TO RFC EDITOR: Please replace above reference to
+ draft-ietf-i2rs-yang-network-topo-02 with RFC
+ number when published (i.e. RFC xxxx).";
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02";
+ }
+
+ typedef node-id {
+ type inet:uri;
+ description
+ "Identifier for a node.";
+ }
+
+ typedef network-id {
+ type inet:uri;
+ description
+ "Identifier for a network.";
+ }
+ grouping network-ref {
+ description
+ "Contains the information necessary to reference a network,
+ for example an underlay network.";
+ leaf network-ref {
+ type leafref {
+ path "/nd:networks/nd:network/nd:network-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a network, for example an underlay
+ network.";
+ }
+ }
+
+ grouping node-ref {
+ description
+ "Contains the information necessary to reference a node.";
+ leaf node-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/nd:node/nd:node-id";
+ require-instance false;
+ }
+ description
+ "Used to reference a node.
+ Nodes are identified relative to the network they are
+ contained in.";
+ }
+ uses network-ref;
+ }
+
+ container networks {
+ description
+ "Serves as top-level container for a list of networks.";
+ list network {
+ key "network-id";
+ description
+ "Describes a network.
+ A network typically contains an inventory of nodes,
+ topological information (augmented through
+ network-topology model), as well as layering
+ information.";
+ container network-types {
+ description
+ "Serves as an augmentation target.
+ The network type is indicated through corresponding
+ presence containers augmented into this container.";
+ }
+ leaf network-id {
+ type network-id;
+ description
+ "Identifies a network.";
+ }
+ list supporting-network {
+ key "network-ref";
+ description
+ "An underlay network, used to represent layered network
+ topologies.";
+ leaf network-ref {
+ type leafref {
+ path "/networks/network/network-id";
+ require-instance false;
+ }
+ description
+ "References the underlay network.";
+ }
+ }
+ list node {
+ key "node-id";
+ description
+ "The inventory of nodes of this network.";
+ leaf node-id {
+ type node-id;
+ description
+ "Identifies a node uniquely within the containing
+ network.";
+ }
+ list supporting-node {
+ key "network-ref node-ref";
+ description
+ "Represents another node, in an underlay network, that
+ this node is supported by. Used to represent layering
+ structure.";
+ leaf network-ref {
+ type leafref {
+ path "../../../supporting-network/network-ref";
+ require-instance false;
+ }
+ description
+ "References the underlay network that the
+ underlay node is part of.";
+ }
+ leaf node-ref {
+ type leafref {
+ path "/networks/network/node/node-id";
+ require-instance false;
+ }
+ description
+ "References the underlay node itself.";
+ }
+ }
+ }
+ }
+ }
+ container networks-state {
+ config false;
+ description
+ "Serves as top-level container for a list of state information
+ for networks";
+ list network {
+ key "network-ref";
+ description
+ "Data nodes representing operational data and state of
+ networks.
+ An instance is automatically created for every network
+ in the corresponding list under the networks container.";
+ uses network-ref;
+ leaf server-provided {
+ type boolean;
+ description
+ "Indicates whether the information concerning this
+ particular network is populated by the server
+ (server-provided true, the general case for network
+ information discovered from the server),
+ or whether it is configured by a client
+ (server-provided true, possible e.g. for
+ service overlays managed through a controller).";
+ }
+ }
+ }
+ }
diff --git a/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-schedule.yang b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-schedule.yang
new file mode 100644
index 0000000..9e375f9
--- /dev/null
+++ b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-schedule.yang
@@ -0,0 +1,64 @@
+ module yrt-ietf-schedule {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:yrt-ietf-schedule";
+ // replace with IANA namespace when assigned
+
+ prefix "sch";
+
+ import yrt-ietf-yang-types {
+ prefix "yang";
+ }
+
+ organization "TBD";
+ contact "TBD";
+ description
+ "The model allows time scheduling parameters to be specified.";
+
+ revision "2016-03-01" {
+ description "Initial revision";
+ reference "TBD";
+ }
+
+ /*
+ * Groupings
+ */
+
+ grouping schedules {
+ description
+ "A list of schedules defining when a particular
+ configuration takes effect.";
+ container schedules {
+ description
+ "Container of a schedule list defining when a particular
+ configuration takes effect.";
+ list schedule {
+ key "schedule-id";
+ description "A list of schedule elements.";
+
+ leaf schedule-id {
+ type uint32;
+ description "Identifies the schedule element.";
+ }
+ leaf start {
+ type yang:date-and-time;
+ description "Start time.";
+ }
+ leaf schedule-duration {
+ type string {
+ pattern
+ 'P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?(\d+S)?';
+ }
+ description "Schedule duration in ISO 8601 format.";
+ }
+ leaf repeat-interval {
+ type string {
+ pattern
+ 'R\d*/P(\d+Y)?(\d+M)?(\d+W)?(\d+D)?T(\d+H)?(\d+M)?'
+ + '(\d+S)?';
+ }
+ description "Repeat interval in ISO 8601 format.";
+ }
+ }
+ }
+ } // schedules
+ }
diff --git a/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-te-topology.yang b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-te-topology.yang
new file mode 100644
index 0000000..4114566
--- /dev/null
+++ b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-te-topology.yang
@@ -0,0 +1,1112 @@
+module yrt-ietf-te-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:yrt-ietf-te-topology";
+ // replace with IANA namespace when assigned
+
+ prefix "tet";
+
+ import yrt-ietf-inet-types {
+ prefix "inet";
+ }
+
+ import yrt-ietf-schedule {
+ prefix "sch";
+ }
+
+ import yrt-ietf-te-types {
+ prefix "te-types";
+ }
+
+ import yrt-ietf-network {
+ prefix "nw";
+ }
+
+ import yrt-network-topology {
+ prefix "nt";
+ }
+
+ organization
+ "Traffic Engineering Architecture and Signaling (TEAS)
+ Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/teas/>
+ WG List: <mailto:teas@ietf.org>
+ WG Chair: Lou Berger
+ <mailto:lberger@labn.net>
+ WG Chair: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+ Editor: Xufeng Liu
+ <mailto:xliu@kuatrotech.com>
+ Editor: Igor Bryskin
+ <mailto:Igor.Bryskin@huawei.com>
+ Editor: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+ Editor: Tarek Saad
+ <mailto:tsaad@cisco.com>
+ Editor: Himanshu Shah
+ <mailto:hshah@ciena.com>
+ Editor: Oscar Gonzalez De Dios
+ <mailto:oscar.gonzalezdedios@telefonica.com>";
+
+ description "TE topology model";
+
+ revision "2016-03-17" {
+ description "Initial revision";
+ reference "TBD";
+ }
+
+ /*
+ * Features
+ */
+
+ feature configuration-schedule {
+ description
+ "This feature indicates that the system supports
+ configuration scheduling.";
+ }
+
+ feature te-topology-hierarchy {
+ description
+ "This feature indicates that the system allows underlay
+ and/or overlay TE topology hierarchy.";
+ }
+
+ feature te-performance-metric {
+ description
+ "This feature indicates that the system supports
+ TE performance metric defined in
+ RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ }
+
+ feature template {
+ description
+ "This feature indicates that the system supports
+ template configuration.";
+ }
+
+ /*
+ * Typedefs
+ */
+ typedef performance-metric-normality {
+ type enumeration {
+ enum "unknown" {
+ value 0;
+ description
+ "Unknown.";
+ }
+ enum "normal" {
+ value 1;
+ description
+ "Normal.";
+ }
+ enum "abnormal" {
+ value 2;
+ description
+ "Abnormal. The anomalous bit is set.";
+ }
+ }
+ description
+ "Indicates whether a performance metric is normal, abnormal, or
+ unknown.";
+ reference
+ "RFC7471: OSPF Traffic Engineering (TE) Metric Extensions.";
+ }
+
+ typedef te-admin-status {
+ type enumeration {
+ enum up {
+ description
+ "Enabled.";
+ }
+ enum down {
+ description
+ "Disabled.";
+ }
+ enum testing {
+ description
+ "In some test mode.";
+ }
+ enum preparing-maintenance {
+ description
+ "Resource is disabled in the control plane to prepare for
+ graceful shutdown for maintenance purposes.";
+ reference
+ "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
+ Traffic Engineering Networks";
+ }
+ enum maintenance {
+ description
+ "Resource is disabled in the data plane for maintenance
+ purposes.";
+ }
+ }
+ description
+ "Defines a type representing the administrative status of
+ a TE resource.";
+ }
+ typedef te-global-id {
+ type uint32;
+ description
+ "An identifier to uniquely identify an operator, which can be
+ either a provider or a client.
+ The definition of this type is taken from RFC6370 and RFC5003.
+ This attribute type is used solely to provide a globally
+ unique context for TE topologies.";
+ }
+
+ typedef te-link-access-type {
+ type enumeration {
+ enum point-to-point {
+ description
+ "The link is point-to-point.";
+ }
+ enum multi-access {
+ description
+ "The link is multi-access, including broacast and NBMA.";
+ }
+ }
+ description
+ "Defines a type representing the access type of a TE link.";
+ reference
+ "RFC3630: Traffic Engineering (TE) Extensions to OSPF
+ Version 2.";
+ }
+
+ typedef te-node-id {
+ type inet:ip-address;
+ description
+ "An identifier for a node in a topology.
+ The identifier is represented as an IPv4 or IPv6 address.
+ This attribute is mapped to Router ID in
+ RFC3630, RFC5329, RFC5305, and RFC 6119.";
+ }
+
+ typedef te-oper-status {
+ type enumeration {
+ enum up {
+ description
+ "Operational up.";
+ }
+ enum down {
+ description
+ "Operational down.";
+ }
+ enum testing {
+ description
+ "In some test mode.";
+ }
+ enum unknown {
+ description
+ "Status cannot be determined for some reason.";
+ }
+ enum preparing-maintenance {
+ description
+ "Resource is disabled in the control plane to prepare for
+ graceful shutdown for maintenance purposes.";
+ reference
+ "RFC5817: Graceful Shutdown in MPLS and Generalized MPLS
+ Traffic Engineering Networks";
+ }
+ enum maintenance {
+ description
+ "Resource is disabled in the data plane for maintenance
+ purposes.";
+ }
+ }
+ description
+ "Defines a type representing the operational status of
+ a TE resource.";
+ }
+
+ typedef te-recovery-status {
+ type enumeration {
+ enum normal {
+ description
+ "Both the recovery and working spans are fully
+ allocated and active, data traffic is being
+ transported over (or selected from) the working
+ span, and no trigger events are reported.";
+ }
+ enum recovery-started {
+ description
+ "The recovery action has been started, but not completed.";
+ }
+ enum recovery-succeeded {
+ description
+ "The recovery action has succeeded. The working span has
+ reported a failure/degrade condition and the user traffic
+ is being transported (or selected) on the recovery span.";
+ }
+ enum recovery-failed {
+ description
+ "The recovery action has failed.";
+ }
+ enum reversion-started {
+ description
+ "The reversion has started.";
+ }
+ enum reversion-failed {
+ description
+ "The reversion has failed.";
+ }
+ enum recovery-unavailable {
+ description
+ "The recovery is unavailable -- either as a result of an
+ operator Lockout command or a failure condition detected
+ on the recovery span.";
+ }
+ enum recovery-admin {
+ description
+ "The operator has issued a command switching the user
+ traffic to the recovery span.";
+ }
+ enum wait-to-restore {
+ description
+ "The recovery domain is recovering from a failuer/degrade
+ condition on the working span that is being controlled by
+ the Wait-to-Restore (WTR) timer.";
+ }
+ }
+ }
+
+ typedef te-template-name {
+ type string {
+ pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
+ }
+ }
+
+ typedef te-topology-event-type {
+ type enumeration {
+ enum "add" {
+ value 0;
+ }
+ enum "remove" {
+ value 1;
+ }
+ enum "update" {
+ value 2;
+ }
+ }
+ } // te-topology-event-type
+ typedef te-topology-id {
+ type string {
+ pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
+ }
+ }
+
+ typedef te-tp-id {
+ type union {
+ type uint32; // Unnumbered
+ type inet:ip-address; // IPv4 or IPv6 address
+ }
+ }
+
+ /*
+ * Identities
+ */
+
+ /*
+ * Groupings
+ */
+ grouping information-source-attributes {
+ leaf information-source {
+ type enumeration {
+ enum "unknown";
+ enum "locally-configured";
+ enum "ospfv2";
+ enum "ospfv3";
+ enum "isis";
+ enum "system-processed";
+ enum "other";
+ }
+ }
+ container information-source-state {
+ leaf credibility-preference {
+ type uint16;
+ }
+ container topology {
+ uses te-topology-ref;
+ } // topology
+ leaf routing-instance {
+ type string;
+ } // routing-information
+ }
+ } // information-source-attributes
+
+ grouping performance-metric-attributes {
+ leaf unidirectional-delay {
+ type uint32 {
+ range 0..16777215;
+ }
+ }
+ leaf unidirectional-min-delay {
+ type uint32 {
+ range 0..16777215;
+ }
+ }
+ leaf unidirectional-max-delay {
+ type uint32 {
+ range 0..16777215;
+ }
+ }
+ leaf unidirectional-delay-variation {
+ type uint32 {
+ range 0..16777215;
+ }
+ }
+ leaf unidirectional-packet-loss {
+ type decimal64 {
+ fraction-digits 6;
+ range "0 .. 50.331642";
+ }
+ }
+ leaf unidirectional-residual-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ leaf unidirectional-available-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ leaf unidirectional-utilized-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ } // performance-metric-attributes
+ grouping performance-metric-normality-attributes {
+ leaf unidirectional-delay {
+ type performance-metric-normality;
+ }
+ leaf unidirectional-min-delay {
+ type performance-metric-normality;
+ }
+ leaf unidirectional-max-delay {
+ type performance-metric-normality;
+ }
+ leaf unidirectional-delay-variation {
+ type performance-metric-normality;
+ }
+ leaf unidirectional-packet-loss {
+ type performance-metric-normality;
+ }
+ leaf unidirectional-residual-bandwidth {
+ type performance-metric-normality;
+ }
+ leaf unidirectional-available-bandwidth {
+ type performance-metric-normality;
+ }
+ leaf unidirectional-utilized-bandwidth {
+ type performance-metric-normality;
+ }
+ } // performance-metric-normality-attributes
+
+ grouping performance-metric-throttle-container {
+ container performance-metric-throttle {
+ leaf unidirectional-delay-offset {
+ type uint32 {
+ range 0..16777215;
+ }
+ }
+ leaf measure-interval {
+ type uint32;
+ default 30;
+ }
+ leaf advertisement-interval {
+ type uint32;
+ }
+ leaf suppression-interval {
+ type uint32 {
+ range "1 .. max";
+ }
+ default 120;
+ }
+ container threshold-out {
+ uses performance-metric-attributes;
+ }
+ container threshold-in {
+ uses performance-metric-attributes;
+ }
+ container threshold-accelerated-advertisement {
+ uses performance-metric-attributes;
+ }
+ }
+ } // performance-metric-throttle-container
+
+ grouping te-link-augment {
+ container te {
+ presence "TE support.";
+ container config {
+ uses te-link-config;
+ } // config
+ container state {
+ config false;
+ uses te-link-config;
+ uses te-link-state-derived;
+ } // state
+ } // te
+ } // te-link-augment
+
+ grouping te-link-config {
+ choice bundle-stack-level {
+ case bundle {
+ container bundled-links {
+ list bundled-link {
+ key "sequence";
+ leaf sequence {
+ type uint32;
+ }
+ leaf src-tp-ref {
+ type leafref {
+ path "../../../../../../nw:node[nw:node-id = "
+ + "current()/../../../../../nt:source/"
+ + "nt:source-node]/"
+ + "nt:t-point/nt:tp-id";
+ require-instance true;
+ }
+ }
+ leaf des-tp-ref {
+ type leafref {
+ path "../../../../../../nw:node[nw:node-id = "
+ + "current()/../../../../../nt:destination/"
+ + "nt:dest-node]/"
+ + "nt:t-point/nt:tp-id";
+ require-instance true;
+ }
+ }
+ } // list bundled-link
+ }
+ }
+ case component {
+ container component-links {
+ list component-link {
+ key "sequence";
+ leaf sequence {
+ type uint32;
+ }
+ leaf src-interface-ref {
+ type string;
+ }
+ leaf des-interface-ref {
+ type string;
+ }
+ }
+ }
+ }
+ } // bundle-stack-level
+
+ leaf-list te-link-template {
+ if-feature template;
+ type leafref {
+ path "../../../../../te/templates/link-template/name";
+ }
+ }
+ uses te-link-config-attributes;
+ } // te-link-config
+
+ grouping te-link-config-attributes {
+ container te-link-attributes {
+ uses sch:schedules;
+ leaf access-type {
+ type te-link-access-type;
+ }
+ leaf is-abstract {
+ type empty;
+ }
+ leaf name {
+ type string;
+ }
+ container underlay {
+ presence
+ "Indicates the underlay exists for this link.";
+ uses te-link-underlay-attributes;
+ } // underlay
+ leaf admin-status {
+ type te-admin-status;
+ description
+ "The administrative state of the link.";
+ }
+
+ uses performance-metric-throttle-container;
+ uses te-link-info-attributes;
+ } // te-link-attributes
+ } // te-link-config-attributes
+
+ grouping te-link-info-attributes {
+ leaf link-index {
+ type uint64;
+ }
+ leaf administrative-group {
+ type te-types:admin-groups;
+ }
+ leaf max-link-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ leaf max-resv-link-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ list unreserved-bandwidth {
+ key "priority";
+ max-elements "8";
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ }
+ leaf bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ }
+ leaf te-default-metric {
+ type uint32;
+ }
+ container performance-metric {
+ container measurement {
+ uses performance-metric-attributes;
+ }
+ container normality
+ {
+ uses performance-metric-normality-attributes;
+ }
+ }
+ leaf link-protection-type {
+ type enumeration {
+ enum "unprotected";
+ enum "extra-traffic";
+ enum "shared";
+ enum "1-for-1";
+ enum "1-plus-1";
+ enum "enhanced";
+ }
+ }
+ list interface-switching-capability {
+ key "switching-capability";
+ leaf switching-capability {
+ type identityref {
+ base te-types:switching-capabilities;
+ }
+ }
+ leaf encoding {
+ type identityref {
+ base te-types:lsp-encoding-types;
+ }
+ }
+ list max-lsp-bandwidth {
+ key "priority";
+ max-elements "8";
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ }
+ leaf bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ }
+ container time-division-multiplex-capable {
+ leaf minimum-lsp-bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ leaf indication {
+ type enumeration {
+ enum "standard";
+ enum "arbitrary";
+ }
+ }
+ }
+ list interface-adjustment-capability {
+ key "upper-sc";
+ leaf upper-sc {
+ type identityref {
+ base te-types:switching-capabilities;
+ }
+ }
+ leaf upper-encoding {
+ type identityref {
+ base te-types:lsp-encoding-types;
+ }
+ }
+ list max-lsp-bandwidth {
+ key "priority";
+ max-elements "8";
+ leaf priority {
+ type uint8 {
+ range "0..7";
+ }
+ description "Priority.";
+ }
+ leaf bandwidth {
+ type decimal64 {
+ fraction-digits 2;
+ }
+ }
+ }
+ } // interface-adjustment-capability
+ } // interface-switching-capability
+ container te-srlgs {
+ leaf-list values {
+ type te-types:srlg;
+ }
+ }
+ } // te-link-info-attributes
+
+ grouping te-link-state-derived {
+ leaf oper-status {
+ type te-oper-status;
+ }
+ uses information-source-attributes;
+ list alt-information-sources {
+ key "information-source";
+ uses information-source-attributes;
+ uses te-link-info-attributes;
+ }
+ container recovery {
+ leaf restoration-status {
+ type te-recovery-status;
+ }
+ leaf protection-status {
+ type te-recovery-status;
+ }
+ }
+ container underlay {
+ uses te-link-state-underlay-attributes;
+ }
+ } // te-link-state-derived
+ grouping te-link-state-underlay-attributes {
+ leaf dynamic {
+ type boolean;
+ }
+ leaf committed {
+ type boolean;
+ }
+ } // te-link-state-underlay-attributes
+
+ grouping te-link-underlay-attributes {
+ container underlay-primary-path {
+ uses te-topology-ref;
+ list path-element {
+ key "path-element-id";
+ leaf path-element-id {
+ type uint32;
+ }
+ uses te-path-element;
+ }
+ } // underlay-primary-path
+ list underlay-backup-path {
+ key "index";
+ leaf index {
+ type uint32;
+ }
+ uses te-topology-ref;
+ list path-element {
+ key "path-element-id";
+ leaf path-element-id {
+ type uint32;
+ }
+ uses te-path-element;
+ }
+ } // underlay-backup-path
+ leaf underlay-protection-type {
+ type uint16;
+ }
+ container underlay-trail-src {
+ uses nt:tp-ref;
+ }
+ container underlay-trail-des {
+ uses nt:tp-ref;
+ }
+ } // te-link-underlay-attributes
+
+ grouping te-node-augment {
+ container te {
+ presence "TE support.";
+ leaf te-node-id {
+ type te-node-id;
+ }
+
+ container config {
+ description
+ "Configuration data.";
+ uses te-node-config;
+ } // config
+ container state {
+ config false;
+ description
+ "Operational state data.";
+
+ uses te-node-config;
+ uses te-node-state-derived;
+ } // state
+
+ list tunnel-termination-point {
+ key "tunnel-tp-id";
+ leaf tunnel-tp-id {
+ type binary;
+ }
+ container config {
+ uses te-node-tunnel-termination-capability;
+ }
+
+ container state {
+ config false;
+ uses te-node-tunnel-termination-capability;
+ leaf switching-capability {
+ type identityref {
+ base te-types:switching-capabilities;
+ }
+ }
+ leaf encoding {
+ type identityref {
+ base te-types:lsp-encoding-types;
+ }
+ }
+ } // state
+
+ } // tunnel-termination-point
+ } // te
+ } // te-node-augment
+
+ grouping te-node-config {
+ leaf-list te-node-template {
+ if-feature template;
+ type leafref {
+ path "../../../../../te/templates/node-template/name";
+ }
+ }
+ uses te-node-config-attributes;
+ } // te-node-config
+
+ grouping te-node-config-attributes {
+ container te-node-attributes {
+ uses sch:schedules;
+ leaf admin-status {
+ type te-admin-status;
+ description
+ "The administrative state of the link.";
+ }
+ uses te-node-connectivity-matrix;
+ uses te-node-info-attributes;
+ } // te-node-attributes
+ } // te-node-config-attributes
+
+ grouping te-node-config-attributes-notification {
+ container te-node-attributes {
+ uses sch:schedules;
+ leaf admin-status {
+ type te-admin-status;
+ }
+ uses te-node-connectivity-matrix-abs;
+ uses te-node-info-attributes;
+ } // te-node-attributes
+ } // te-node-config-attributes-notification
+
+ grouping te-node-config-attributes-template {
+ container te-node-attributes {
+ uses sch:schedules;
+ leaf admin-status {
+ type te-admin-status;
+ }
+ uses te-node-info-attributes;
+ } // te-node-attributes
+ } // te-node-config-attributes-template
+
+ grouping te-node-connectivity-matrix {
+ list connectivity-matrix {
+ key "id";
+ leaf id {
+ type uint32;
+ }
+ container from {
+ leaf tp-ref {
+ type leafref {
+ path "../../../../../../nt:t-point/nt:tp-id";
+ }
+ }
+ }
+ container to {
+ leaf tp-ref {
+ type leafref {
+ path "../../../../../../nt:t-point/nt:tp-id";
+ }
+ }
+ }
+ leaf is-allowed {
+ type boolean;
+ }
+ }
+ } // te-node-connectivity-matrix
+
+ grouping te-node-connectivity-matrix-abs {
+ list connectivity-matrix {
+ key "id";
+ leaf id {
+ type uint32;
+ }
+ container from {
+ uses nt:tp-ref;
+ }
+ container to {
+ uses nt:tp-ref;
+ }
+ leaf is-allowed {
+ type boolean;
+ }
+ }
+ } // te-node-connectivity-matrix-abs
+
+ grouping te-node-info-attributes {
+ leaf domain-id {
+ type uint32;
+ }
+ leaf is-abstract {
+ type empty;
+ }
+ leaf name {
+ type inet:domain-name;
+ }
+ leaf-list signaling-address {
+ type inet:ip-address;
+ }
+ container underlay-topology {
+ if-feature te-topology-hierarchy;
+ uses te-topology-ref;
+ }
+ } // te-node-info-attributes
+
+ grouping te-node-state-derived {
+ description "Node state attributes in a TE topology.";
+ leaf oper-status {
+ type te-oper-status;
+ }
+ leaf is-multi-access-dr {
+ type empty;
+ }
+ uses information-source-attributes;
+ list alt-information-sources {
+ key "information-source";
+ uses information-source-attributes;
+ uses te-node-connectivity-matrix;
+ uses te-node-info-attributes;
+ }
+ } // te-node-state-derived
+
+ grouping te-node-state-derived-notification {
+ description "Node state attributes in a TE topology.";
+ leaf oper-status {
+ type te-oper-status;
+ }
+ leaf is-multi-access-dr {
+ type empty;
+ }
+ uses information-source-attributes;
+ list alt-information-sources {
+ key "information-source";
+ uses information-source-attributes;
+ uses te-node-connectivity-matrix-abs;
+ uses te-node-info-attributes;
+ }
+ } // te-node-state-derived-notification
+
+ grouping te-node-tunnel-termination-capability {
+ list termination-capability {
+ key "link-tp";
+ leaf link-tp {
+ type leafref {
+ path "../../../../../nt:t-point/nt:tp-id";
+ }
+ }
+ } // termination-capability
+ } // te-node-tunnel-termination-capability
+
+ grouping te-path-element {
+ uses te-types:explicit-route-subobject;
+ } // te-path-element
+
+ grouping te-termination-point-augment {
+
+ container te {
+ presence "TE support.";
+
+ leaf te-tp-id {
+ type te-tp-id;
+ mandatory true;
+ }
+
+ container config {
+ uses te-termination-point-config;
+ } // config
+ container state {
+ config false;
+ uses te-termination-point-config;
+ } // state
+ } // te
+ } // te-termination-point-augment
+
+ grouping te-termination-point-config {
+ uses sch:schedules;
+ } // te-termination-point-config
+
+ grouping te-topologies-augment {
+
+ container te {
+ presence "TE support.";
+
+ container templates {
+ list node-template {
+ if-feature template;
+ key "name";
+ leaf name {
+ type te-template-name;
+ }
+ uses template-attributes;
+ uses te-node-config-attributes-template;
+ } // node-template
+
+ list link-template {
+ if-feature template;
+ key "name";
+ leaf name {
+ type te-template-name;
+ }
+ uses template-attributes;
+ uses te-link-config-attributes;
+ } // link-template
+ } // templates
+ } // te
+ } // te-topologies-augment
+
+ grouping te-topology-augment {
+
+ container te {
+ presence "TE support.";
+ leaf provider-id {
+ type te-global-id;
+ }
+ leaf client-id {
+ type te-global-id;
+ }
+ leaf te-topology-id {
+ type te-topology-id;
+ mandatory true;
+ }
+
+ container config {
+ uses te-topology-config;
+ } // config
+ container state {
+ config false;
+ uses te-topology-config;
+ } // state
+ } // te
+ } // te-topology-augment
+
+ grouping te-topology-config {
+ uses sch:schedules;
+ leaf preference {
+ type uint8 {
+ range "1..255";
+ }
+ }
+ } // te-topology-config
+
+ grouping te-topology-ref {
+ leaf provider-id-ref {
+ type leafref {
+ path "/nw:networks/nw:network[nw:network-id = "
+ + "current()/../network-id-ref]/tet:te/tet:provider-id";
+ require-instance false;
+ }
+ }
+ leaf client-id-ref {
+ type leafref {
+ path "/nw:networks/nw:network[nw:network-id = "
+ + "current()/../network-id-ref]/tet:te/tet:client-id";
+ require-instance false;
+ }
+ }
+ leaf te-topology-id-ref {
+ type leafref {
+ path "/nw:networks/nw:network[nw:network-id = "
+ + "current()/../network-id-ref]/tet:te/tet:te-topology-id";
+ require-instance false;
+ }
+ }
+ leaf network-id-ref {
+ type leafref {
+ path "/nw:networks/nw:network/nw:network-id";
+ require-instance false;
+ }
+ }
+ } // te-topology-ref
+
+ grouping te-topology-type {
+ container te-topology {
+ presence "Indicates TE topology.";
+ }
+ } // te-topology-type
+
+ grouping template-attributes {
+ leaf priority {
+ type uint16;
+ }
+ leaf reference-change-policy {
+ type enumeration {
+ enum no-action;
+ enum not-allowed;
+ enum cascade;
+ }
+ }
+ } // template-attributes
+
+ /*
+ * Configuration data nodes
+ */
+ augment "/nw:networks/nw:network/nw:network-types" {
+ uses te-topology-type;
+ }
+
+ augment "/nw:networks" {
+ uses te-topologies-augment;
+ }
+
+ augment "/nw:networks/nw:network" {
+ uses te-topology-augment;
+ }
+
+ augment "/nw:networks/nw:network/nw:node" {
+ uses te-node-augment;
+ }
+
+ augment "/nw:networks/nw:network/nt:link" {
+ uses te-link-augment;
+ }
+
+ augment "/nw:networks/nw:network/nw:node/"
+ + "nt:t-point" {
+ uses te-termination-point-augment;
+ }
+
+ container te-node-event {
+ leaf event-type {
+ type te-topology-event-type;
+ description "Event type.";
+ }
+ uses nw:node-ref;
+ uses te-topology-type;
+ uses tet:te-node-config-attributes-notification;
+ uses tet:te-node-state-derived-notification;
+ }
+}
\ No newline at end of file
diff --git a/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-te-types.yang b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-te-types.yang
new file mode 100644
index 0000000..9286347
--- /dev/null
+++ b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-te-types.yang
@@ -0,0 +1,870 @@
+ module yrt-ietf-te-types {
+
+ namespace "urn:ietf:params:xml:ns:yang:yrt-ietf-te-types";
+
+ /* Replace with IANA when assigned */
+ prefix "te-types";
+
+ import yrt-ietf-inet-types {
+ prefix inet;
+ }
+
+ organization
+ "IETF Traffic Engineering Architecture and Signaling (TEAS)
+ Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/teas/>
+ WG List: <mailto:teas@ietf.org>
+
+ WG Chair: Lou Berger
+ <mailto:lberger@labn.net>
+
+ WG Chair: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+
+ Editor: Tarek Saad
+ <mailto:tsaad@cisco.com>
+
+ Editor: Rakesh Gandhi
+ <mailto:rgandhi@cisco.com>
+
+ Editor: Vishnu Pavan Beeram
+ <mailto:vbeeram@juniper.net>
+
+ Editor: Himanshu Shah
+ <mailto:hshah@ciena.com>
+
+ Editor: Xufeng Liu
+ <mailto:xufeng.liu@ericsson.com>
+
+ Editor: Xia Chen
+ <mailto:jescia.chenxia@huawei.com>
+
+ Editor: Raqib Jones
+ <mailto:raqib@Brocade.com>
+
+ Editor: Bin Wen
+ <mailto:Bin_Wen@cable.comcast.com>";
+
+ description
+ "This module contains a collection of generally
+ useful TE specific YANG data type defintions.";
+
+ revision 2016-03-20 {
+ description "Latest revision of TE generic types";
+ reference "RFC3209";
+ }
+
+ identity tunnel-type {
+ description
+ "Base identity from which specific tunnel types are
+ derived.";
+ }
+
+ identity tunnel-p2p {
+ base tunnel-type;
+ description
+ "TE point-to-point tunnel type.";
+ }
+
+ identity tunnel-p2mp {
+ base tunnel-type;
+ description
+ "TE point-to-multipoint tunnel type.";
+ }
+
+ identity state-type {
+ description
+ "Base identity for TE states";
+ }
+
+ identity state-up {
+ base state-type;
+ description
+ "State up";
+ }
+
+ identity state-down {
+ base state-type;
+ description
+ "State down";
+ }
+
+ identity lsp-prot-type {
+ description
+ "Base identity from which LSP protection types are
+ derived.";
+ }
+
+ identity lsp-prot-unprotected {
+ description
+ "LSP protection 'Unprotected'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-reroute-extra {
+ description
+ "LSP protection '(Full) Rerouting'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-reroute {
+ description
+ "LSP protection 'Rerouting without Extra-Traffic'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-1-for-n {
+ description
+ "LSP protection '1:N Protection with Extra-Traffic'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-unidir-1-to-1 {
+ description
+ "LSP protection '1+1 Unidirectional Protection'";
+ reference "RFC4872";
+ }
+
+ identity lsp-prot-bidir-1-to-1 {
+ description
+ "LSP protection '1+1 Bidirectional Protection'";
+ reference "RFC4872";
+ }
+
+ identity switching-capabilities {
+ description
+ "Base identity for interface switching capabilities";
+ }
+
+ identity switching-psc1 {
+ base switching-capabilities;
+ description
+ "Packet-Switch Capable-1 (PSC-1)";
+ }
+
+ identity switching-evpl {
+ base switching-capabilities;
+ description
+ "Ethernet Virtual Private Line (EVPL)";
+ }
+
+ identity switching-l2sc {
+ base switching-capabilities;
+ description
+ "Layer-2 Switch Capable (L2SC)";
+ }
+
+ identity switching-tdm {
+ base switching-capabilities;
+ description
+ "Time-Division-Multiplex Capable (TDM)";
+ }
+
+ identity switching-otn {
+ base switching-capabilities;
+ description
+ "OTN-TDM capable";
+ }
+
+ identity switching-dcsc {
+ base switching-capabilities;
+ description
+ "Data Channel Switching Capable (DCSC)";
+ }
+ identity switching-lsc {
+ base switching-capabilities;
+ description
+ "Lambda-Switch Capable (LSC)";
+ }
+
+ identity switching-fsc {
+ base switching-capabilities;
+ description
+ "Fiber-Switch Capable (FSC)";
+ }
+
+ identity lsp-encoding-types {
+ description
+ "Base identity for encoding types";
+ }
+
+ identity lsp-encoding-packet {
+ base lsp-encoding-types;
+ description
+ "Packet LSP encoding";
+ }
+
+ identity lsp-encoding-ethernet {
+ base lsp-encoding-types;
+ description
+ "Ethernet LSP encoding";
+ }
+
+ identity lsp-encoding-pdh {
+ base lsp-encoding-types;
+ description
+ "ANSI/ETSI LSP encoding";
+ }
+
+ identity lsp-encoding-sdh {
+ base lsp-encoding-types;
+ description
+ "SDH ITU-T G.707 / SONET ANSI T1.105 LSP encoding";
+ }
+
+ identity lsp-encoding-digital-wrapper {
+ base lsp-encoding-types;
+ description
+ "Digital Wrapper LSP encoding";
+ }
+
+ identity lsp-encoding-lambda {
+ base lsp-encoding-types;
+ description
+ "Lambda (photonic) LSP encoding";
+ }
+
+ identity lsp-encoding-fiber {
+ base lsp-encoding-types;
+ description
+ "Fiber LSP encoding";
+ }
+
+ identity lsp-encoding-fiber-channel {
+ base lsp-encoding-types;
+ description
+ "FiberChannel LSP encoding";
+ }
+
+ identity lsp-encoding-oduk {
+ base lsp-encoding-types;
+ description
+ "G.709 ODUk (Digital Path)LSP encoding";
+ }
+
+ identity lsp-encoding-optical-channel {
+ base lsp-encoding-types;
+ description
+ "Line (e.g., 8B/10B) LSP encoding";
+ }
+
+ identity lsp-encoding-line {
+ base lsp-encoding-types;
+ description
+ "Line (e.g., 8B/10B) LSP encoding";
+ }
+
+ /* TE basic features */
+ feature p2mp-te {
+ description
+ "Indicates support for P2MP-TE";
+ }
+
+ feature frr-te {
+ description
+ "Indicates support for TE FastReroute (FRR)";
+ }
+
+ feature extended-admin-groups {
+ description
+ "Indicates support for TE link extended admin
+ groups.";
+ }
+
+ feature named-path-affinities {
+ description
+ "Indicates support for named path affinities";
+ }
+
+ feature named-extended-admin-groups {
+ description
+ "Indicates support for named extended admin groups";
+ }
+
+ feature named-srlg-groups {
+ description
+ "Indicates support for named SRLG groups";
+ }
+
+ feature named-path-constraints {
+ description
+ "Indicates support for named path constraints";
+ }
+
+ grouping explicit-route-subobject {
+ description
+ "The explicit route subobject grouping";
+ choice type {
+ description
+ "The explicit route subobject type";
+ case ipv4-address {
+ description
+ "IPv4 address explicit route subobject";
+ leaf v4-address {
+ type inet:ipv4-address;
+ description
+ "An IPv4 address. This address is
+ treated as a prefix based on the
+ prefix length value below. Bits beyond
+ the prefix are ignored on receipt and
+ SHOULD be set to zero on transmission.";
+ }
+ leaf v4-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v4-loose {
+ type boolean;
+ description
+ "Describes whether the object is loose
+ if set, or otherwise strict";
+ }
+ }
+ case ipv6-address {
+ description
+ "IPv6 address Explicit Route Object";
+ leaf v6-address {
+ type inet:ipv6-address;
+ description
+ "An IPv6 address. This address is
+ treated as a prefix based on the
+ prefix length value below. Bits
+ beyond the prefix are ignored on
+ receipt and SHOULD be set to zero
+ on transmission.";
+ }
+ leaf v6-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v6-loose {
+ type boolean;
+ description
+ "Describes whether the object is loose
+ if set, or otherwise strict";
+ }
+ }
+ case as-number {
+ leaf as-number {
+ type uint16;
+ description "AS number";
+ }
+ description
+ "Autonomous System explicit route subobject";
+ }
+ case unnumbered-link {
+ leaf router-id {
+ type inet:ip-address;
+ description
+ "A router-id address";
+ }
+ leaf interface-id {
+ type uint32;
+ description "The interface identifier";
+ }
+ description
+ "Unnumbered link explicit route subobject";
+ reference
+ "RFC3477: Signalling Unnumbered Links in
+ RSVP-TE";
+ }
+ case label {
+ leaf value {
+ type uint32;
+ description "the label value";
+ }
+ description
+ "The Label ERO subobject";
+ }
+ /* AS domain sequence..? */
+ }
+ }
+
+ grouping record-route-subobject {
+ description
+ "The record route subobject grouping";
+ choice type {
+ description
+ "The record route subobject type";
+ case ipv4-address {
+ leaf v4-address {
+ type inet:ipv4-address;
+ description
+ "An IPv4 address. This address is
+ treated as a prefix based on the prefix
+ length value below. Bits beyond the
+ prefix are ignored on receipt and
+ SHOULD be set to zero on transmission.";
+ }
+ leaf v4-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v4-flags {
+ type uint8;
+ description
+ "IPv4 address sub-object flags";
+ reference "RFC3209";
+ }
+ }
+ case ipv6-address {
+ leaf v6-address {
+ type inet:ipv6-address;
+ description
+ "An IPv6 address. This address is
+ treated as a prefix based on the
+ prefix length value below. Bits
+ beyond the prefix are ignored on
+ receipt and SHOULD be set to zero
+ on transmission.";
+ }
+ leaf v6-prefix-length {
+ type uint8;
+ description
+ "Length in bits of the IPv4 prefix";
+ }
+ leaf v6-flags {
+ type uint8;
+ description
+ "IPv6 address sub-object flags";
+ reference "RFC3209";
+ }
+ }
+ case label {
+ leaf value {
+ type uint32;
+ description "the label value";
+ }
+ leaf flags {
+ type uint8;
+ description
+ "Label sub-object flags";
+ reference "RFC3209";
+ }
+ description
+ "The Label ERO subobject";
+ }
+ }
+ }
+
+ identity route-usage-type {
+ description
+ "Base identity for route usage";
+ }
+
+ identity route-include-ero {
+ base route-usage-type;
+ description
+ "Include ERO from route";
+ }
+
+ identity route-exclude-ero {
+ base route-usage-type;
+ description
+ "Exclude ERO from route";
+ }
+
+ identity route-exclude-srlg {
+ base route-usage-type;
+ description
+ "Exclude SRLG from route";
+ }
+
+ identity path-metric-type {
+ description
+ "Base identity for path metric type";
+ }
+
+ identity path-metric-te {
+ base path-metric-type;
+ description
+ "TE path metric";
+ }
+
+ identity path-metric-igp {
+ base path-metric-type;
+ description
+ "IGP path metric";
+ }
+
+ identity path-tiebreaker-type {
+ description
+ "Base identity for path tie-breaker type";
+ }
+
+ identity path-tiebreaker-minfill {
+ base path-tiebreaker-type;
+ description
+ "Min-Fill LSP path placement";
+ }
+
+ identity path-tiebreaker-maxfill {
+ base path-tiebreaker-type;
+ description
+ "Max-Fill LSP path placement";
+ }
+
+ identity path-tiebreaker-randoom {
+ base path-tiebreaker-type;
+ description
+ "Random LSP path placement";
+ }
+
+ identity bidir-provisioning-mode {
+ description
+ "Base identity for bidirectional provisioning
+ mode.";
+ }
+
+ identity bidir-provisioning-single-sided {
+ base bidir-provisioning-mode;
+ description
+ "Single-sided bidirectional provioning mode";
+ }
+
+ identity bidir-provisioning-double-sided {
+ base bidir-provisioning-mode;
+ description
+ "Double-sided bidirectional provioning mode";
+ }
+
+ identity bidir-association-type {
+ description
+ "Base identity for bidirectional association type";
+ }
+
+ identity bidir-assoc-corouted {
+ base bidir-association-type;
+ description
+ "Co-routed bidirectional association type";
+ }
+
+ identity bidir-assoc-non-corouted {
+ base bidir-association-type;
+ description
+ "Non co-routed bidirectional association type";
+ }
+
+ identity resource-affinities-type {
+ description
+ "Base identity for resource affinities";
+ }
+
+ identity resource-aff-include-all {
+ base resource-affinities-type;
+ description
+ "The set of attribute filters associated with a
+ tunnel all of which must be present for a link
+ to be acceptable";
+ }
+
+ identity resource-aff-include-any {
+ base resource-affinities-type;
+ description
+ "The set of attribute filters associated with a
+ tunnel any of which must be present for a link
+ to be acceptable";
+ }
+
+ identity resource-aff-exclude-any {
+ base resource-affinities-type;
+ description
+ "The set of attribute filters associated with a
+ tunnel any of which renders a link unacceptable";
+ }
+
+ typedef admin-group {
+ type binary {
+ length 32;
+ }
+ description
+ "Administrative group/Resource class/Color.";
+ }
+
+ typedef extended-admin-group {
+ type binary;
+ description
+ "Extended administrative group/Resource class/Color.";
+ }
+
+ typedef admin-groups {
+ type union {
+ type admin-group;
+ type extended-admin-group;
+ }
+ description "TE administrative group derived type";
+ }
+
+ typedef srlg {
+ type uint32;
+ description "SRLG type";
+ }
+
+ identity path-computation-srlg-type {
+ description
+ "Base identity for SRLG path computation";
+ }
+
+ identity srlg-ignore {
+ base path-computation-srlg-type;
+ description
+ "Ignores SRLGs in path computation";
+ }
+
+ identity srlg-strict {
+ base path-computation-srlg-type;
+ description
+ "Include strict SRLG check in path computation";
+ }
+
+ identity srlg-preferred {
+ base path-computation-srlg-type;
+ description
+ "Include preferred SRLG check in path computation";
+ }
+
+ identity srlg-weighted {
+ base path-computation-srlg-type;
+ description
+ "Include weighted SRLG check in path computation";
+ }
+
+ typedef te-metric {
+ type uint32;
+ description
+ "TE link metric";
+ }
+
+ typedef topology-id {
+ type string {
+ pattern '/?([a-zA-Z0-9\-_.]+)(/[a-zA-Z0-9\-_.]+)*';
+ }
+ description
+ "An identifier for a topology.";
+ }
+
+ /**
+ * TE tunnel generic groupings
+ **/
+
+ /* Tunnel path selection parameters */
+ grouping tunnel-path-selection {
+ description
+ "Tunnel path selection properties grouping";
+ container path-selection {
+ description
+ "Tunnel path selection properties container";
+ leaf topology {
+ type te-types:topology-id;
+ description
+ "The tunnel path is computed using the specific
+ topology identified by this identifier";
+ }
+ leaf cost-limit {
+ type uint32 {
+ range "1..4294967295";
+ }
+ description
+ "The tunnel path cost limit.";
+ }
+ leaf hop-limit {
+ type uint8 {
+ range "1..255";
+ }
+ description
+ "The tunnel path hop limit.";
+ }
+ leaf metric-type {
+ type identityref {
+ base path-metric-type;
+ }
+ default path-metric-te;
+ description
+ "The tunnel path metric type.";
+ }
+ leaf tiebreaker-type {
+ type identityref {
+ base path-tiebreaker-type;
+ }
+ default path-tiebreaker-maxfill;
+ description
+ "The tunnel path computation tie breakers.";
+ }
+ leaf ignore-overload {
+ type boolean;
+ description
+ "The tunnel path can traverse overloaded node.";
+ }
+ uses tunnel-path-affinities;
+ uses tunnel-path-srlgs;
+ }
+ }
+
+ grouping tunnel-path-affinities {
+ description
+ "Path affinities grouping";
+ container tunnel-path-affinities {
+ if-feature named-path-affinities;
+ description
+ "Path affinities container";
+ choice style {
+ description
+ "Path affinities representation style";
+ case values {
+ leaf value {
+ type uint32 {
+ range "0..4294967295";
+ }
+ description
+ "Affinity value";
+ }
+ leaf mask {
+ type uint32 {
+ range "0..4294967295";
+ }
+ description
+ "Affinity mask";
+ }
+ }
+ case named {
+ list constraints {
+ key "usage";
+ leaf usage {
+ type identityref {
+ base resource-affinities-type;
+ }
+ description "Affinities usage";
+ }
+ container constraint {
+ description
+ "Container for named affinities";
+ list affinity-names {
+ key "name";
+ leaf name {
+ type string;
+ description
+ "Affinity name";
+ }
+ description
+ "List of named affinities";
+ }
+ }
+ description
+ "List of named affinity constraints";
+ }
+ }
+ }
+ }
+ }
+
+ grouping tunnel-path-srlgs {
+ description
+ "Path SRLG properties grouping";
+ container tunnel-path-srlgs {
+ description
+ "Path SRLG properties container";
+ choice style {
+ description
+ "Type of SRLG representation";
+ case values {
+ leaf usage {
+ type identityref {
+ base route-exclude-srlg;
+ }
+ description "SRLG usage";
+ }
+ leaf-list values {
+ type te-types:srlg;
+ description "SRLG value";
+ }
+ }
+ case named {
+ list constraints {
+ key "usage";
+ leaf usage {
+ type identityref {
+ base route-exclude-srlg;
+ }
+ description "SRLG usage";
+ }
+ container constraint {
+ description
+ "Container for named SRLG list";
+ list srlg-names {
+ key "name";
+ leaf name {
+ type string;
+ description
+ "The SRLG name";
+ }
+ description
+ "List named SRLGs";
+ }
+ }
+ description
+ "List of named SRLG constraints";
+ }
+ }
+ }
+ }
+ }
+
+ grouping tunnel-bidir-assoc-properties {
+ description
+ "TE tunnel associated bidirectional properties
+ grouping";
+ container bidirectional {
+ description
+ "TE tunnel associated bidirectional attributes.";
+ container association {
+ description
+ "Tunnel bidirectional association properties";
+ leaf id {
+ type uint16;
+ description
+ "The TE tunnel association identifier.";
+ }
+ leaf source {
+ type inet:ip-address;
+ description
+ "The TE tunnel association source.";
+ }
+ leaf global-source {
+ type inet:ip-address;
+ description
+ "The TE tunnel association global
+ source.";
+ }
+ leaf type {
+ type identityref {
+ base bidir-association-type;
+ }
+ default bidir-assoc-non-corouted;
+ description
+ "The TE tunnel association type.";
+ }
+ leaf provisioing {
+ type identityref {
+ base bidir-provisioning-mode;
+ }
+ description
+ "Describes the provisioning model of the
+ associated bidirectional LSP";
+ reference
+ "draft-ietf-teas-mpls-tp-rsvpte-ext-
+ associated-lsp, section-3.2";
+ }
+ }
+ }
+ }
+ /*** End of TE tunnel groupings ***/
+
+ /**
+ * TE interface generic groupings
+ **/
+ }
diff --git a/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-yang-types.yang b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-yang-types.yang
new file mode 100644
index 0000000..5e27206
--- /dev/null
+++ b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-ietf-yang-types.yang
@@ -0,0 +1,490 @@
+ module yrt-ietf-yang-types {
+
+ yang-version 1;
+
+ namespace
+ "urn:ietf:params:xml:ns:yang:yrt-ietf-yang-types";
+
+ prefix yang;
+
+ organization
+ "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/netmod/>
+ WG List: <mailto:netmod@ietf.org>
+
+ WG Chair: David Kessens
+ <mailto:david.kessens@nsn.com>
+
+ WG Chair: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>
+
+ Editor: Juergen Schoenwaelder
+ <mailto:j.schoenwaelder@jacobs-university.de>";
+
+ description
+ "This module contains a collection of generally useful derived
+ YANG data types.
+
+ Copyright (c) 2013 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of RFC 6991; see
+ the RFC itself for full legal notices.";
+
+ revision "2013-07-15" {
+ description
+ "This revision adds the following new data types:
+ - yang-identifier
+ - hex-string
+ - uuid
+ - dotted-quad";
+ reference
+ "RFC 6991: Common YANG Data Types";
+
+ }
+
+ revision "2010-09-24" {
+ description "Initial revision.";
+ reference
+ "RFC 6021: Common YANG Data Types";
+
+ }
+
+
+ typedef counter32 {
+ type uint32;
+ description
+ "The counter32 type represents a non-negative integer
+ that monotonically increases until it reaches a
+ maximum value of 2^32-1 (4294967295 decimal), when it
+ wraps around and starts increasing again from zero.
+
+ Counters have no defined 'initial' value, and thus, a
+ single value of a counter has (in general) no information
+ content. Discontinuities in the monotonically increasing
+ value normally occur at re-initialization of the
+ management system, and at other times as specified in the
+ description of a schema node using this type. If such
+ other times can occur, for example, the creation of
+ a schema node of type counter32 at times other than
+ re-initialization, then a corresponding schema node
+ should be defined, with an appropriate type, to indicate
+ the last discontinuity.
+
+ The counter32 type should not be used for configuration
+ schema nodes. A default statement SHOULD NOT be used in
+ combination with the type counter32.
+
+ In the value set and its semantics, this type is equivalent
+ to the Counter32 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef zero-based-counter32 {
+ type counter32;
+ default "0";
+ description
+ "The zero-based-counter32 type represents a counter32
+ that has the defined 'initial' value zero.
+
+ A schema node of this type will be set to zero (0) on creation
+ and will thereafter increase monotonically until it reaches
+ a maximum value of 2^32-1 (4294967295 decimal), when it
+ wraps around and starts increasing again from zero.
+
+ Provided that an application discovers a new schema node
+ of this type within the minimum time to wrap, it can use the
+ 'initial' value as a delta. It is important for a management
+ station to be aware of this minimum time and the actual time
+ between polls, and to discard data if the actual time is too
+ long or there is no defined minimum time.
+
+ In the value set and its semantics, this type is equivalent
+ to the ZeroBasedCounter32 textual convention of the SMIv2.";
+ reference
+ "RFC 4502: Remote Network Monitoring Management Information
+ Base Version 2";
+
+ }
+
+ typedef counter64 {
+ type uint64;
+ description
+ "The counter64 type represents a non-negative integer
+ that monotonically increases until it reaches a
+ maximum value of 2^64-1 (18446744073709551615 decimal),
+ when it wraps around and starts increasing again from zero.
+
+ Counters have no defined 'initial' value, and thus, a
+ single value of a counter has (in general) no information
+ content. Discontinuities in the monotonically increasing
+ value normally occur at re-initialization of the
+ management system, and at other times as specified in the
+ description of a schema node using this type. If such
+ other times can occur, for example, the creation of
+ a schema node of type counter64 at times other than
+ re-initialization, then a corresponding schema node
+ should be defined, with an appropriate type, to indicate
+ the last discontinuity.
+
+ The counter64 type should not be used for configuration
+ schema nodes. A default statement SHOULD NOT be used in
+ combination with the type counter64.
+
+ In the value set and its semantics, this type is equivalent
+ to the Counter64 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef zero-based-counter64 {
+ type counter64;
+ default "0";
+ description
+ "The zero-based-counter64 type represents a counter64 that
+ has the defined 'initial' value zero.
+
+
+
+
+ A schema node of this type will be set to zero (0) on creation
+ and will thereafter increase monotonically until it reaches
+ a maximum value of 2^64-1 (18446744073709551615 decimal),
+ when it wraps around and starts increasing again from zero.
+
+ Provided that an application discovers a new schema node
+ of this type within the minimum time to wrap, it can use the
+ 'initial' value as a delta. It is important for a management
+ station to be aware of this minimum time and the actual time
+ between polls, and to discard data if the actual time is too
+ long or there is no defined minimum time.
+
+ In the value set and its semantics, this type is equivalent
+ to the ZeroBasedCounter64 textual convention of the SMIv2.";
+ reference
+ "RFC 2856: Textual Conventions for Additional High Capacity
+ Data Types";
+
+ }
+
+ typedef gauge32 {
+ type uint32;
+ description
+ "The gauge32 type represents a non-negative integer, which
+ may increase or decrease, but shall never exceed a maximum
+ value, nor fall below a minimum value. The maximum value
+ cannot be greater than 2^32-1 (4294967295 decimal), and
+ the minimum value cannot be smaller than 0. The value of
+ a gauge32 has its maximum value whenever the information
+ being modeled is greater than or equal to its maximum
+ value, and has its minimum value whenever the information
+ being modeled is smaller than or equal to its minimum value.
+ If the information being modeled subsequently decreases
+ below (increases above) the maximum (minimum) value, the
+ gauge32 also decreases (increases).
+
+ In the value set and its semantics, this type is equivalent
+ to the Gauge32 type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef gauge64 {
+ type uint64;
+ description
+ "The gauge64 type represents a non-negative integer, which
+ may increase or decrease, but shall never exceed a maximum
+ value, nor fall below a minimum value. The maximum value
+ cannot be greater than 2^64-1 (18446744073709551615), and
+ the minimum value cannot be smaller than 0. The value of
+ a gauge64 has its maximum value whenever the information
+ being modeled is greater than or equal to its maximum
+ value, and has its minimum value whenever the information
+ being modeled is smaller than or equal to its minimum value.
+ If the information being modeled subsequently decreases
+ below (increases above) the maximum (minimum) value, the
+ gauge64 also decreases (increases).
+
+ In the value set and its semantics, this type is equivalent
+ to the CounterBasedGauge64 SMIv2 textual convention defined
+ in RFC 2856";
+ reference
+ "RFC 2856: Textual Conventions for Additional High Capacity
+ Data Types";
+
+ }
+
+ typedef object-identifier {
+ type string {
+ pattern
+ '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))(\.(0|([1-9]\d*)))*';
+ }
+ description
+ "The object-identifier type represents administratively
+ assigned names in a registration-hierarchical-name tree.
+
+ Values of this type are denoted as a sequence of numerical
+ non-negative sub-identifier values. Each sub-identifier
+ value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
+ are separated by single dots and without any intermediate
+ whitespace.
+
+ The ASN.1 standard restricts the value space of the first
+ sub-identifier to 0, 1, or 2. Furthermore, the value space
+ of the second sub-identifier is restricted to the range
+ 0 to 39 if the first sub-identifier is 0 or 1. Finally,
+ the ASN.1 standard requires that an object identifier
+ has always at least two sub-identifiers. The pattern
+ captures these restrictions.
+
+ Although the number of sub-identifiers is not limited,
+ module designers should realize that there may be
+ implementations that stick with the SMIv2 limit of 128
+ sub-identifiers.
+
+ This type is a superset of the SMIv2 OBJECT IDENTIFIER type
+ since it is not restricted to 128 sub-identifiers. Hence,
+ this type SHOULD NOT be used to represent the SMIv2 OBJECT
+ IDENTIFIER type; the object-identifier-128 type SHOULD be
+ used instead.";
+ reference
+ "ISO9834-1: Information technology -- Open Systems
+ Interconnection -- Procedures for the operation of OSI
+ Registration Authorities: General procedures and top
+ arcs of the ASN.1 Object Identifier tree";
+
+ }
+
+ typedef object-identifier-128 {
+ type object-identifier {
+ pattern '\d*(\.\d*){1,127}';
+ }
+ description
+ "This type represents object-identifiers restricted to 128
+ sub-identifiers.
+
+ In the value set and its semantics, this type is equivalent
+ to the OBJECT IDENTIFIER type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef yang-identifier {
+ type string {
+ length "1..max";
+ pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
+ pattern
+ '.|..|[^xX].*|.[^mM].*|..[^lL].*';
+ }
+ description
+ "A YANG identifier string as defined by the 'identifier'
+ rule in Section 12 of RFC 6020. An identifier must
+ start with an alphabetic character or an underscore
+ followed by an arbitrary sequence of alphabetic or
+ numeric characters, underscores, hyphens, or dots.
+
+ A YANG identifier MUST NOT start with any possible
+ combination of the lowercase or uppercase character
+ sequence 'xml'.";
+ reference
+ "RFC 6020: YANG - A Data Modeling Language for the Network
+ Configuration Protocol (NETCONF)";
+
+ }
+
+ typedef date-and-time {
+ type string {
+ pattern
+ '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-]\d{2}:\d{2})';
+ }
+ description
+ "The date-and-time type is a profile of the ISO 8601
+ standard for representation of dates and times using the
+ Gregorian calendar. The profile is defined by the
+ date-time production in Section 5.6 of RFC 3339.
+
+ The date-and-time type is compatible with the dateTime XML
+ schema type with the following notable exceptions:
+
+ (a) The date-and-time type does not allow negative years.
+
+ (b) The date-and-time time-offset -00:00 indicates an unknown
+ time zone (see RFC 3339) while -00:00 and +00:00 and Z
+ all represent the same time zone in dateTime.
+
+ (c) The canonical format (see below) of data-and-time values
+ differs from the canonical format used by the dateTime XML
+ schema type, which requires all times to be in UTC using
+ the time-offset 'Z'.
+
+ This type is not equivalent to the DateAndTime textual
+ convention of the SMIv2 since RFC 3339 uses a different
+ separator between full-date and full-time and provides
+ higher resolution of time-secfrac.
+
+ The canonical format for date-and-time values with a known time
+ zone uses a numeric time zone offset that is calculated using
+ the device's configured known offset to UTC time. A change of
+ the device's offset to UTC time will cause date-and-time values
+ to change accordingly. Such changes might happen periodically
+ in case a server follows automatically daylight saving time
+ (DST) time zone offset changes. The canonical format for
+ date-and-time values with an unknown time zone (usually
+ referring to the notion of local time) uses the time-offset
+ -00:00.";
+ reference
+ "RFC 3339: Date and Time on the Internet: Timestamps
+ RFC 2579: Textual Conventions for SMIv2
+ XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
+
+ }
+
+ typedef timeticks {
+ type uint32;
+ description
+ "The timeticks type represents a non-negative integer that
+ represents the time, modulo 2^32 (4294967296 decimal), in
+ hundredths of a second between two epochs. When a schema
+ node is defined that uses this type, the description of
+ the schema node identifies both of the reference epochs.
+
+ In the value set and its semantics, this type is equivalent
+ to the TimeTicks type of the SMIv2.";
+ reference
+ "RFC 2578: Structure of Management Information Version 2
+ (SMIv2)";
+
+ }
+
+ typedef timestamp {
+ type timeticks;
+ description
+ "The timestamp type represents the value of an associated
+ timeticks schema node at which a specific occurrence
+ happened. The specific occurrence must be defined in the
+ description of any schema node defined using this type. When
+ the specific occurrence occurred prior to the last time the
+ associated timeticks attribute was zero, then the timestamp
+ value is zero. Note that this requires all timestamp values
+ to be reset to zero when the value of the associated timeticks
+ attribute reaches 497+ days and wraps around to zero.
+
+ The associated timeticks schema node must be specified
+ in the description of any schema node using this type.
+
+ In the value set and its semantics, this type is equivalent
+ to the TimeStamp textual convention of the SMIv2.";
+ reference
+ "RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef phys-address {
+ type string {
+ pattern
+ '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
+ }
+ description
+ "Represents media- or physical-level addresses represented
+ as a sequence octets, each octet represented by two hexadecimal
+ numbers. Octets are separated by colons. The canonical
+ representation uses lowercase characters.
+
+ In the value set and its semantics, this type is equivalent
+ to the PhysAddress textual convention of the SMIv2.";
+ reference
+ "RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef mac-address {
+ type string {
+ pattern
+ '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
+ }
+ description
+ "The mac-address type represents an IEEE 802 MAC address.
+ The canonical representation uses lowercase characters.
+
+ In the value set and its semantics, this type is equivalent
+ to the MacAddress textual convention of the SMIv2.";
+ reference
+ "IEEE 802: IEEE Standard for Local and Metropolitan Area
+ Networks: Overview and Architecture
+ RFC 2579: Textual Conventions for SMIv2";
+
+ }
+
+ typedef xpath1.0 {
+ type string;
+ description
+ "This type represents an XPATH 1.0 expression.
+
+ When a schema node is defined that uses this type, the
+ description of the schema node MUST specify the XPath
+ context in which the XPath expression is evaluated.";
+ reference
+ "XPATH: XML Path Language (XPath) Version 1.0";
+
+ }
+
+ typedef hex-string {
+ type string {
+ pattern
+ '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
+ }
+ description
+ "A hexadecimal string with octets represented as hex digits
+ separated by colons. The canonical representation uses
+ lowercase characters.";
+ }
+
+ typedef uuid {
+ type string {
+ pattern
+ '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
+ }
+ description
+ "A Universally Unique IDentifier in the string representation
+ defined in RFC 4122. The canonical representation uses
+ lowercase characters.
+
+ The following is an example of a UUID in string representation:
+ f81d4fae-7dec-11d0-a765-00a0c91e6bf6
+ ";
+ reference
+ "RFC 4122: A Universally Unique IDentifier (UUID) URN
+ Namespace";
+
+ }
+
+ typedef dotted-quad {
+ type string {
+ pattern
+ '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
+ }
+ description
+ "An unsigned 32-bit number expressed in the dotted-quad
+ notation, i.e., four octets written as decimal numbers
+ and separated with the '.' (full stop) character.";
+ }
+ } // module ietf-yang-types
+
diff --git a/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-network-topology.yang b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-network-topology.yang
new file mode 100644
index 0000000..ae5e953
--- /dev/null
+++ b/runtime/app/src/test/resources/schemaProviderTestYangFiles/yrt-network-topology.yang
@@ -0,0 +1,304 @@
+ module yrt-network-topology {
+ yang-version 1;
+ namespace "urn:ietf:params:xml:ns:yang:yrt-ietf-network-topology";
+ prefix lnk;
+
+ import yrt-ietf-inet-types {
+ prefix inet;
+ }
+ import yrt-ietf-network {
+ prefix nd;
+ }
+
+ organization
+ "IETF I2RS (Interface to the Routing System) Working Group";
+
+ contact
+ "WG Web: <http://tools.ietf.org/wg/i2rs/>
+ WG List: <mailto:i2rs@ietf.org>
+
+ WG Chair: Susan Hares
+ <mailto:shares@ndzh.com>
+
+ WG Chair: Jeffrey Haas
+ <mailto:jhaas@pfrc.org>
+
+ Editor: Alexander Clemm
+ <mailto:alex@cisco.com>
+
+ Editor: Jan Medved
+ <mailto:jmedved@cisco.com>
+
+ Editor: Robert Varga
+ <mailto:rovarga@cisco.com>
+
+ Editor: Tony Tkacik
+ <mailto:ttkacik@cisco.com>
+
+ Editor: Nitin Bahadur
+ <mailto:nitin_bahadur@yahoo.com>
+
+ Editor: Hariharan Ananthakrishnan
+ <mailto:hari@packetdesign.com>";
+
+ description
+ "This module defines a common base model for network topology,
+ augmenting the base network model with links to connect nodes,
+ as well as termination points to terminate links on nodes.
+
+ Copyright (c) 2015 IETF Trust and the persons identified as
+ authors of the code. All rights reserved.
+
+ Redistribution and use in source and binary forms, with or
+ without modification, is permitted pursuant to, and subject
+ to the license terms contained in, the Simplified BSD License
+ set forth in Section 4.c of the IETF Trust's Legal Provisions
+ Relating to IETF Documents
+ (http://trustee.ietf.org/license-info).
+
+ This version of this YANG module is part of
+ draft-ietf-i2rs-yang-network-topo-02;
+ see the RFC itself for full legal notices.
+
+ NOTE TO RFC EDITOR: Please replace above reference to
+ draft-ietf-i2rs-yang-network-topo-02 with RFC
+ number when published (i.e. RFC xxxx).";
+
+ revision 2015-12-08 {
+ description
+ "Initial revision.
+ NOTE TO RFC EDITOR: Please replace the following reference
+ to draft-ietf-i2rs-yang-network-topo-02 with
+ RFC number when published (i.e. RFC xxxx).";
+ reference
+ "draft-ietf-i2rs-yang-network-topo-02.";
+ }
+
+ typedef link-id {
+ type inet:uri;
+ description
+ "An identifier for a link in a topology.
+ 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 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.";
+ }
+ grouping link-ref {
+ description
+ "References a link in a specific network.";
+ leaf link-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/lnk:link/lnk:link-id";
+ require-instance false;
+ }
+ 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.)";
+ }
+ uses nd:network-ref;
+ }
+
+ grouping tp-ref {
+ description
+ "References a termination point in a specific node.";
+ leaf tp-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/../"+
+ "network-ref]/nd:node[nd:node-id=current()/../"+
+ "node-ref]/lnk:t-point/lnk:tp-id";
+ require-instance false;
+ }
+ 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.)";
+ }
+ uses nd:node-ref;
+ }
+
+ augment "/nd:networks/nd:network" {
+ description
+ "Add links to the network model.";
+ list link {
+ key "link-id";
+ 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.";
+ container source {
+ description
+ "This container holds the logical source of a particular
+ link.";
+ leaf source-node {
+ type leafref {
+ path "../../../nd:node/nd:node-id";
+ }
+ mandatory true;
+ description
+ "Source node identifier, must be in same topology.";
+ }
+ leaf source-tp {
+ type leafref {
+ path "../../../nd:node[nd:node-id=current()/../"+
+ "source-node]/t-point/tp-id";
+ }
+ description
+ "Termination point within source node that terminates
+ the link.";
+ }
+ }
+ container destination {
+ description
+ "This container holds the logical destination of a
+ particular link.";
+ leaf dest-node {
+ type leafref {
+ path "../../../nd:node/nd:node-id";
+ }
+ mandatory true;
+ description
+ "Destination node identifier, must be in the same
+ network.";
+ }
+ leaf dest-tp {
+ type leafref {
+ path "../../../nd:node[nd:node-id=current()/../"+
+ "dest-node]/t-point/tp-id";
+ }
+ description
+ "Termination point within destination node that
+ terminates the link.";
+ }
+ }
+ 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.";
+ }
+ list supporting-link {
+ key "network-ref link-ref";
+ description
+ "Identifies the link, or links, that this link
+ is dependent on.";
+ leaf network-ref {
+ type leafref {
+ path "../../../nd:supporting-network/nd:network-ref";
+ require-instance false;
+ }
+ description
+ "This leaf identifies in which underlay topology
+ supporting link is present.";
+ }
+ leaf link-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/"+
+ "../network-ref]/link/link-id";
+ require-instance false;
+ }
+ description
+ "This leaf identifies a link which is a part
+ of this link's underlay. Reference loops, in which
+ a link identifies itself as its underlay, either
+ directly or transitively, are not allowed.";
+ }
+ }
+ }
+
+ 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.";
+ }
+ }
+ augment "/nd:networks/nd:network/nd:node" {
+ description
+ "Augment termination points which terminate links.
+ Termination points can ultimately be mapped to interfaces.";
+ list t-point {
+ key "tp-id";
+ 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.";
+ leaf tp-id {
+ type tp-id;
+ description
+ "Termination point identifier.";
+ }
+ list supporting-termination-point {
+ key "network-ref node-ref tp-ref";
+ 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.";
+ leaf network-ref {
+ type leafref {
+ path "../../../nd:supporting-node/nd:network-ref";
+ require-instance false;
+ }
+ description
+ "This leaf identifies in which topology the
+ supporting termination point is present.";
+ }
+ leaf node-ref {
+ type leafref {
+ path "../../../nd:supporting-node/nd:node-ref";
+ require-instance false;
+ }
+ description
+ "This leaf identifies in which node the supporting
+ termination point is present.";
+ }
+ leaf tp-ref {
+ type leafref {
+ path "/nd:networks/nd:network[nd:network-id=current()/"+
+ "../network-ref]/nd:node[nd:node-id=current()/../"+
+ "node-ref]/t-point/tp-id";
+ require-instance false;
+ }
+ description
+ "Reference to the underlay node, must be in a
+ different topology";
+ }
+ }
+ }
+ }
+ }
diff --git a/runtime/utils/pom.xml b/runtime/utils/pom.xml
index 336bd44..cb401e2 100644
--- a/runtime/utils/pom.xml
+++ b/runtime/utils/pom.xml
@@ -1,9 +1,17 @@
<!--
- ~ Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
- ~ Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
- ~ Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
- ~ Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
- ~ Vestibulum commodo. Ut rhoncus gravida arcu.
+ ~ Copyright 2017-present Open Networking Laboratory
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
diff --git a/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/SerializerHelper.java b/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/SerializerHelper.java
index eecae7e..4315c35 100644
--- a/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/SerializerHelper.java
+++ b/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/SerializerHelper.java
@@ -1,9 +1,17 @@
/*
- * Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
- * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
- * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
- * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
- * Vestibulum commodo. Ut rhoncus gravida arcu.
+ * Copyright 2017-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.onosproject.yang.runtime.utils;