janani b
Committed by Patrick Liu

[ONOS-4842] Leafref implementation for augment and uses

Change-Id: I919553a64d683aff65a8f16e2de783702dd5a45f
Showing 89 changed files with 1675 additions and 481 deletions
...@@ -22,8 +22,10 @@ import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; ...@@ -22,8 +22,10 @@ import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
22 /** 22 /**
23 * Abstraction of YANG resolvable information. Abstracted to obtain the 23 * Abstraction of YANG resolvable information. Abstracted to obtain the
24 * information required for linking resolution. 24 * information required for linking resolution.
25 + *
26 + * @param <T> YANG resolvable info
25 */ 27 */
26 -public interface Resolvable { 28 +public interface Resolvable<T> {
27 29
28 /** 30 /**
29 * Returns the status of resolution. If completely resolved returns enum 31 * Returns the status of resolution. If completely resolved returns enum
...@@ -48,8 +50,9 @@ public interface Resolvable { ...@@ -48,8 +50,9 @@ public interface Resolvable {
48 /** 50 /**
49 * Resolves the linking. 51 * Resolves the linking.
50 * 52 *
53 + * @return list of entities to be added for resolution
51 * @throws DataModelException data model exception 54 * @throws DataModelException data model exception
52 */ 55 */
53 - void resolve() 56 + T resolve()
54 throws DataModelException; 57 throws DataModelException;
55 } 58 }
......
...@@ -442,8 +442,9 @@ public class YangAugment ...@@ -442,8 +442,9 @@ public class YangAugment
442 } 442 }
443 443
444 @Override 444 @Override
445 - public void resolve() throws DataModelException { 445 + public Object resolve() throws DataModelException {
446 // Resolving of target node is being done in XPathLinker. 446 // Resolving of target node is being done in XPathLinker.
447 + return null;
447 } 448 }
448 449
449 /** 450 /**
......
...@@ -109,6 +109,7 @@ import java.io.Serializable; ...@@ -109,6 +109,7 @@ import java.io.Serializable;
109 } 109 }
110 110
111 @Override 111 @Override
112 - public void resolve() throws DataModelException { 112 + public Object resolve() throws DataModelException {
113 + return null;
113 } 114 }
114 } 115 }
......
...@@ -18,6 +18,7 @@ package org.onosproject.yangutils.datamodel; ...@@ -18,6 +18,7 @@ package org.onosproject.yangutils.datamodel;
18 import java.util.ArrayList; 18 import java.util.ArrayList;
19 import java.util.LinkedList; 19 import java.util.LinkedList;
20 import java.util.List; 20 import java.util.List;
21 +
21 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 22 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22 import org.onosproject.yangutils.datamodel.utils.Parsable; 23 import org.onosproject.yangutils.datamodel.utils.Parsable;
23 import org.onosproject.yangutils.datamodel.utils.YangConstructType; 24 import org.onosproject.yangutils.datamodel.utils.YangConstructType;
......
...@@ -13,34 +13,39 @@ ...@@ -13,34 +13,39 @@
13 * See the License for the specific language governing permissions and 13 * See the License for the specific language governing permissions and
14 * limitations under the License. 14 * limitations under the License.
15 */ 15 */
16 -package org.onosproject.yangutils.linker.impl; 16 +package org.onosproject.yangutils.datamodel;
17 17
18 import java.io.Serializable; 18 import java.io.Serializable;
19 19
20 -import org.onosproject.yangutils.datamodel.YangEntityToResolveInfo;
21 -import org.onosproject.yangutils.datamodel.YangIfFeature;
22 -import org.onosproject.yangutils.datamodel.YangBase;
23 -import org.onosproject.yangutils.datamodel.YangIdentityRef;
24 -import org.onosproject.yangutils.datamodel.YangNode;
25 -import org.onosproject.yangutils.datamodel.YangType;
26 -import org.onosproject.yangutils.datamodel.YangUses;
27 -import org.onosproject.yangutils.linker.exceptions.LinkerException;
28 -
29 /** 20 /**
30 * Represents implementation of information about entity being resolved. 21 * Represents implementation of information about entity being resolved.
31 * 22 *
32 * @param <T> type of entity being resolved, uses / grouping 23 * @param <T> type of entity being resolved, uses / grouping
33 */ 24 */
34 -public class YangEntityToResolveInfoImpl<T> implements YangEntityToResolveInfo<T>, Serializable { 25 +public class YangEntityToResolveInfoImpl<T> implements YangEntityToResolveInfo<T>, Serializable, LocationInfo {
35 26
36 private static final long serialVersionUID = 806201659L; 27 private static final long serialVersionUID = 806201659L;
37 28
38 - // Parsable node for which resolution is to be performed. 29 + /**
30 + * Parsable node for which resolution is to be performed.
31 + */
39 private T entityToResolve; 32 private T entityToResolve;
40 33
41 - // Holder of the YANG construct for which resolution has to be carried out. 34 + /**
35 + * Holder of the YANG construct for which resolution has to be carried out.
36 + */
42 private YangNode holderOfEntityToResolve; 37 private YangNode holderOfEntityToResolve;
43 38
39 + /**
40 + * Error line number.
41 + */
42 + private transient int lineNumber;
43 +
44 + /**
45 + * Error character position in number.
46 + */
47 + private transient int charPositionInLine;
48 +
44 @Override 49 @Override
45 public T getEntityToResolve() { 50 public T getEntityToResolve() {
46 return entityToResolve; 51 return entityToResolve;
...@@ -61,33 +66,23 @@ public class YangEntityToResolveInfoImpl<T> implements YangEntityToResolveInfo<T ...@@ -61,33 +66,23 @@ public class YangEntityToResolveInfoImpl<T> implements YangEntityToResolveInfo<T
61 this.holderOfEntityToResolve = holderOfEntityToResolve; 66 this.holderOfEntityToResolve = holderOfEntityToResolve;
62 } 67 }
63 68
64 - /** 69 + @Override
65 - * Retrieves the prefix of the entity. 70 + public int getLineNumber() {
66 - * 71 + return lineNumber;
67 - * @return entities prefix 72 + }
68 - * @throws LinkerException linker error
69 - */
70 - public String getEntityPrefix()
71 - throws LinkerException {
72 - if (getEntityToResolve() == null) {
73 - return null;
74 - }
75 73
76 - String prefix; 74 + @Override
77 - T entityToBeResolved = getEntityToResolve(); 75 + public int getCharPosition() {
78 - if (entityToBeResolved instanceof YangType) { 76 + return charPositionInLine;
79 - prefix = ((YangType<?>) entityToBeResolved).getPrefix(); 77 + }
80 - } else if (entityToBeResolved instanceof YangUses) { 78 +
81 - prefix = ((YangUses) entityToBeResolved).getPrefix(); 79 + @Override
82 - } else if (entityToBeResolved instanceof YangIfFeature) { 80 + public void setLineNumber(int lineNumber) {
83 - prefix = ((YangIfFeature) entityToBeResolved).getPrefix(); 81 + this.lineNumber = lineNumber;
84 - } else if (entityToBeResolved instanceof YangBase) { 82 + }
85 - prefix = ((YangBase) entityToBeResolved).getBaseIdentifier().getPrefix(); 83 +
86 - } else if (entityToBeResolved instanceof YangIdentityRef) { 84 + @Override
87 - prefix = ((YangIdentityRef) entityToBeResolved).getBaseIdentity().getPrefix(); 85 + public void setCharPosition(int charPositionInLine) {
88 - } else { 86 + this.charPositionInLine = charPositionInLine;
89 - throw new LinkerException("Linker Exception: Entity to resolved is other than type/uses");
90 - }
91 - return prefix;
92 } 87 }
93 } 88 }
......
...@@ -80,7 +80,7 @@ public class YangIdentityRef extends YangNode implements Parsable, Resolvable, S ...@@ -80,7 +80,7 @@ public class YangIdentityRef extends YangNode implements Parsable, Resolvable, S
80 } 80 }
81 81
82 @Override 82 @Override
83 - public void resolve() throws DataModelException { 83 + public Object resolve() throws DataModelException {
84 84
85 // Check if the derived info is present. 85 // Check if the derived info is present.
86 YangIdentity identity = getReferredIdentity(); 86 YangIdentity identity = getReferredIdentity();
...@@ -92,10 +92,11 @@ public class YangIdentityRef extends YangNode implements Parsable, Resolvable, S ...@@ -92,10 +92,11 @@ public class YangIdentityRef extends YangNode implements Parsable, Resolvable, S
92 while (identity.getBaseNode() != null) { 92 while (identity.getBaseNode() != null) {
93 if (identity.getBaseNode().getResolvableStatus() != ResolvableStatus.RESOLVED) { 93 if (identity.getBaseNode().getResolvableStatus() != ResolvableStatus.RESOLVED) {
94 setResolvableStatus(ResolvableStatus.INTRA_FILE_RESOLVED); 94 setResolvableStatus(ResolvableStatus.INTRA_FILE_RESOLVED);
95 - return; 95 + return null;
96 } 96 }
97 identity = identity.getBaseNode().getReferredIdentity(); 97 identity = identity.getBaseNode().getReferredIdentity();
98 } 98 }
99 + return null;
99 } 100 }
100 101
101 /** 102 /**
......
...@@ -170,7 +170,7 @@ public class YangIfFeature implements Parsable, Resolvable, Serializable { ...@@ -170,7 +170,7 @@ public class YangIfFeature implements Parsable, Resolvable, Serializable {
170 } 170 }
171 171
172 @Override 172 @Override
173 - public void resolve() throws DataModelException { 173 + public Object resolve() throws DataModelException {
174 YangFeature feature = getReferredFeature(); 174 YangFeature feature = getReferredFeature();
175 175
176 // check whether feature has if-feature 176 // check whether feature has if-feature
...@@ -181,9 +181,10 @@ public class YangIfFeature implements Parsable, Resolvable, Serializable { ...@@ -181,9 +181,10 @@ public class YangIfFeature implements Parsable, Resolvable, Serializable {
181 YangIfFeature ifFeature = ifFeatureIterator.next(); 181 YangIfFeature ifFeature = ifFeatureIterator.next();
182 if (ifFeature.getResolvableStatus() != ResolvableStatus.RESOLVED) { 182 if (ifFeature.getResolvableStatus() != ResolvableStatus.RESOLVED) {
183 setResolvableStatus(ResolvableStatus.INTRA_FILE_RESOLVED); 183 setResolvableStatus(ResolvableStatus.INTRA_FILE_RESOLVED);
184 - return; 184 + return null;
185 } 185 }
186 } 186 }
187 } 187 }
188 + return null;
188 } 189 }
189 } 190 }
......
...@@ -16,17 +16,18 @@ ...@@ -16,17 +16,18 @@
16 16
17 package org.onosproject.yangutils.datamodel; 17 package org.onosproject.yangutils.datamodel;
18 18
19 -import java.io.Serializable;
20 -import java.util.Iterator;
21 -import java.util.LinkedList;
22 -import java.util.List;
23 -
24 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
25 import org.onosproject.yangutils.datamodel.utils.Parsable; 20 import org.onosproject.yangutils.datamodel.utils.Parsable;
26 import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; 21 import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
27 import org.onosproject.yangutils.datamodel.utils.YangConstructType; 22 import org.onosproject.yangutils.datamodel.utils.YangConstructType;
28 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; 23 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
29 24
25 +import java.io.Serializable;
26 +import java.util.Iterator;
27 +import java.util.LinkedList;
28 +import java.util.List;
29 +import java.util.Map;
30 +
30 import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.INTRA_FILE_RESOLVED; 31 import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.INTRA_FILE_RESOLVED;
31 import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED; 32 import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED;
32 import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.DATA_MISSING_ERROR_TAG; 33 import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.DATA_MISSING_ERROR_TAG;
...@@ -47,7 +48,7 @@ import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.INST ...@@ -47,7 +48,7 @@ import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.INST
47 * @param <T> YANG leafref info 48 * @param <T> YANG leafref info
48 */ 49 */
49 public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangIfFeatureHolder, 50 public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangIfFeatureHolder,
50 - YangXPathResolver, YangAppErrorHolder { 51 + YangXPathResolver, YangAppErrorHolder, LocationInfo {
51 52
52 private static final long serialVersionUID = 286201644L; 53 private static final long serialVersionUID = 286201644L;
53 54
...@@ -100,6 +101,61 @@ public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangI ...@@ -100,6 +101,61 @@ public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangI
100 private List<YangIfFeature> ifFeatureList; 101 private List<YangIfFeature> ifFeatureList;
101 102
102 /** 103 /**
104 + * Parent node of the leafref's leaf.
105 + */
106 + private YangNode parentNodeOfLeafref;
107 +
108 + /**
109 + * Error line number.
110 + */
111 + private transient int lineNumber;
112 +
113 + /**
114 + * Error character position in number.
115 + */
116 + private transient int charPositionInLine;
117 +
118 + /**
119 + * Prefix in the nodes of the leafref path and its imported node name.
120 + */
121 + private Map<String, String> prefixAndItsImportedModule;
122 +
123 + /**
124 + * Returns the prefix in the leafref path and its imported node name.
125 + *
126 + * @return the list of leafref prefix and imported node name
127 + */
128 + public Map<String, String> getPrefixAndItsImportedModule() {
129 + return prefixAndItsImportedModule;
130 + }
131 +
132 + /**
133 + * Sets the prefix in the leafref path and its imported node name.
134 + *
135 + * @param prefixAndItsImportedModule the list of leafref prefix and imported node name
136 + */
137 + public void setPrefixAndItsImportedModule(Map<String, String> prefixAndItsImportedModule) {
138 + this.prefixAndItsImportedModule = prefixAndItsImportedModule;
139 + }
140 +
141 + /**
142 + * Returns the parent node from the leafref's leaf.
143 + *
144 + * @return parent node of the leafref
145 + */
146 + public YangNode getParentNodeOfLeafref() {
147 + return parentNodeOfLeafref;
148 + }
149 +
150 + /**
151 + * Sets the parent node from the leafref's leaf.
152 + *
153 + * @param parentNodeOfLeafref parent node of the leafref
154 + */
155 + public void setParentNodeOfLeafref(YangNode parentNodeOfLeafref) {
156 + this.parentNodeOfLeafref = parentNodeOfLeafref;
157 + }
158 + /**
103 * YANG application error information. 159 * YANG application error information.
104 */ 160 */
105 private YangAppErrorInfo yangAppErrorInfo; 161 private YangAppErrorInfo yangAppErrorInfo;
...@@ -294,7 +350,7 @@ public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangI ...@@ -294,7 +350,7 @@ public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangI
294 } 350 }
295 351
296 @Override 352 @Override
297 - public void resolve() throws DataModelException { 353 + public Object resolve() throws DataModelException {
298 354
299 if (getReferredLeafOrLeafList() == null) { 355 if (getReferredLeafOrLeafList() == null) {
300 throw new DataModelException("Linker Error: The leafref does not refer to any leaf/leaf-list."); 356 throw new DataModelException("Linker Error: The leafref does not refer to any leaf/leaf-list.");
...@@ -306,6 +362,7 @@ public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangI ...@@ -306,6 +362,7 @@ public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangI
306 } catch (DataModelException e) { 362 } catch (DataModelException e) {
307 throw new DataModelException(e.getMessage()); 363 throw new DataModelException(e.getMessage());
308 } 364 }
365 + return null;
309 } 366 }
310 367
311 /** 368 /**
...@@ -443,4 +500,24 @@ public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangI ...@@ -443,4 +500,24 @@ public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangI
443 throw new DataModelException("Linker Error: The leafref must refer only to leaf/leaf-list."); 500 throw new DataModelException("Linker Error: The leafref must refer only to leaf/leaf-list.");
444 } 501 }
445 } 502 }
503 +
504 + @Override
505 + public int getLineNumber() {
506 + return lineNumber;
507 + }
508 +
509 + @Override
510 + public int getCharPosition() {
511 + return charPositionInLine;
512 + }
513 +
514 + @Override
515 + public void setLineNumber(int lineNumber) {
516 + this.lineNumber = lineNumber;
517 + }
518 +
519 + @Override
520 + public void setCharPosition(int charPositionInLine) {
521 + this.charPositionInLine = charPositionInLine;
522 + }
446 } 523 }
......
...@@ -16,15 +16,15 @@ ...@@ -16,15 +16,15 @@
16 16
17 package org.onosproject.yangutils.datamodel; 17 package org.onosproject.yangutils.datamodel;
18 18
19 -import java.util.ArrayList;
20 -import java.util.LinkedList;
21 -import java.util.List;
22 -
23 import org.onosproject.yangutils.datamodel.exceptions.DataModelException; 19 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
24 import org.onosproject.yangutils.datamodel.utils.Parsable; 20 import org.onosproject.yangutils.datamodel.utils.Parsable;
25 import org.onosproject.yangutils.datamodel.utils.YangConstructType; 21 import org.onosproject.yangutils.datamodel.utils.YangConstructType;
26 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; 22 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
27 23
24 +import java.util.ArrayList;
25 +import java.util.LinkedList;
26 +import java.util.List;
27 +
28 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; 28 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
29 29
30 /* 30 /*
...@@ -119,6 +119,26 @@ public class YangList ...@@ -119,6 +119,26 @@ public class YangList
119 private List<String> keyList; 119 private List<String> keyList;
120 120
121 /** 121 /**
122 + * Reference RFC 6020.
123 + *
124 + * The "unique" statement is used to put constraints on valid list
125 + * entries. It takes as an argument a string that contains a space-
126 + * separated list of schema node identifiers, which MUST be given in the
127 + * descendant form. Each such schema node identifier MUST refer to a leaf.
128 + *
129 + * If one of the referenced leafs represents configuration data, then
130 + * all of the referenced leafs MUST represent configuration data.
131 + *
132 + * The "unique" constraint specifies that the combined values of all the
133 + * leaf instances specified in the argument string, including leafs with
134 + * default values, MUST be unique within all list entry instances in
135 + * which all referenced leafs exist.
136 + *
137 + * List of unique leaf/leaf-list names
138 + */
139 + private List<String> uniqueList;
140 +
141 + /**
122 * List of leaves. 142 * List of leaves.
123 */ 143 */
124 private List<YangLeaf> listOfLeaf; 144 private List<YangLeaf> listOfLeaf;
...@@ -271,6 +291,24 @@ public class YangList ...@@ -271,6 +291,24 @@ public class YangList
271 } 291 }
272 292
273 /** 293 /**
294 + * Returns the list of unique field names.
295 + *
296 + * @return the list of unique field names
297 + */
298 + public List<String> getUniqueList() {
299 + return uniqueList;
300 + }
301 +
302 + /**
303 + * Sets the list of unique field names.
304 + *
305 + * @param uniqueList the list of unique field names
306 + */
307 + private void setUniqueList(List<String> uniqueList) {
308 + this.uniqueList = uniqueList;
309 + }
310 +
311 + /**
274 * Returns the list of key field names. 312 * Returns the list of key field names.
275 * 313 *
276 * @return the list of key field names 314 * @return the list of key field names
...@@ -309,6 +347,24 @@ public class YangList ...@@ -309,6 +347,24 @@ public class YangList
309 } 347 }
310 348
311 /** 349 /**
350 + * Adds a unique field name.
351 + *
352 + * @param unique unique field name.
353 + * @throws DataModelException a violation of data model rules
354 + */
355 + public void addUnique(String unique)
356 + throws DataModelException {
357 + if (getUniqueList() == null) {
358 + setUniqueList(new LinkedList<>());
359 + }
360 + if (getUniqueList().contains(unique)) {
361 + throw new DataModelException("A leaf identifier must not appear more than once in the\n" +
362 + " unique");
363 + }
364 + getUniqueList().add(unique);
365 + }
366 +
367 + /**
312 * Returns the list of leaves. 368 * Returns the list of leaves.
313 * 369 *
314 * @return the list of leaves 370 * @return the list of leaves
...@@ -489,11 +545,11 @@ public class YangList ...@@ -489,11 +545,11 @@ public class YangList
489 validateConfig(leaves, leafLists); 545 validateConfig(leaves, leafLists);
490 546
491 /* A list must have atleast one key leaf if config is true */ 547 /* A list must have atleast one key leaf if config is true */
492 - if (isConfig && (keys == null || leaves == null && leafLists == null) && !isUsesPresentInList() 548 + if (isConfig && (keys == null || leaves == null) && !isUsesPresentInList()
493 && !isListPresentInGrouping()) { 549 && !isListPresentInGrouping()) {
494 throw new DataModelException("A list must have atleast one key leaf if config is true;"); 550 throw new DataModelException("A list must have atleast one key leaf if config is true;");
495 } else if (keys != null) { 551 } else if (keys != null) {
496 - validateKey(leaves, leafLists, keys); 552 + validateKey(leaves, keys);
497 } 553 }
498 } 554 }
499 555
...@@ -501,7 +557,7 @@ public class YangList ...@@ -501,7 +557,7 @@ public class YangList
501 * Sets the config's value to all leaf if leaf's config statement is not 557 * Sets the config's value to all leaf if leaf's config statement is not
502 * specified. 558 * specified.
503 * 559 *
504 - * @param leaves list of leaf attributes of YANG list 560 + * @param leaves list of leaf attributes of YANG list
505 * @param leafLists list of leaf-list attributes of YANG list 561 * @param leafLists list of leaf-list attributes of YANG list
506 */ 562 */
507 private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) { 563 private void setDefaultConfigValueToChild(List<YangLeaf> leaves, List<YangLeafList> leafLists) {
...@@ -534,7 +590,7 @@ public class YangList ...@@ -534,7 +590,7 @@ public class YangList
534 /** 590 /**
535 * Validates config statement of YANG list. 591 * Validates config statement of YANG list.
536 * 592 *
537 - * @param leaves list of leaf attributes of YANG list 593 + * @param leaves list of leaf attributes of YANG list
538 * @param leafLists list of leaf-list attributes of YANG list 594 * @param leafLists list of leaf-list attributes of YANG list
539 * @throws DataModelException a violation of data model rules 595 * @throws DataModelException a violation of data model rules
540 */ 596 */
...@@ -567,16 +623,15 @@ public class YangList ...@@ -567,16 +623,15 @@ public class YangList
567 /** 623 /**
568 * Validates key statement of list. 624 * Validates key statement of list.
569 * 625 *
570 - * @param leaves list of leaf attributes of list 626 + * @param leaves list of leaf attributes of list
571 * @param leafLists list of leaf-list attributes of list 627 * @param leafLists list of leaf-list attributes of list
572 - * @param keys list of key attributes of list 628 + * @param keys list of key attributes of list
573 * @throws DataModelException a violation of data model rules 629 * @throws DataModelException a violation of data model rules
574 */ 630 */
575 - private void validateKey(List<YangLeaf> leaves, List<YangLeafList> leafLists, List<String> keys) 631 + private void validateKey(List<YangLeaf> leaves, List<String> keys)
576 throws DataModelException { 632 throws DataModelException {
577 boolean leafFound = false; 633 boolean leafFound = false;
578 List<YangLeaf> keyLeaves = new LinkedList<>(); 634 List<YangLeaf> keyLeaves = new LinkedList<>();
579 - List<YangLeafList> keyLeafLists = new LinkedList<>();
580 635
581 /* 636 /*
582 * 1. Leaf identifier must refer to a child leaf of the list 2. A leaf 637 * 1. Leaf identifier must refer to a child leaf of the list 2. A leaf
...@@ -597,20 +652,6 @@ public class YangList ...@@ -597,20 +652,6 @@ public class YangList
597 } 652 }
598 } 653 }
599 654
600 - if (leafLists != null && !leafLists.isEmpty()) {
601 - for (YangLeafList leafList : leafLists) {
602 - if (key.equals(leafList.getName())) {
603 - if (leafList.getDataType().getDataType() == YangDataTypes.EMPTY) {
604 - throw new DataModelException(" A leaf-list that is part of the key" +
605 - " must not be the built-in type \"empty\".");
606 - }
607 - leafFound = true;
608 - keyLeafLists.add(leafList);
609 - break;
610 - }
611 - }
612 - }
613 -
614 if (!leafFound && !isUsesPresentInList() && !isListPresentInGrouping()) { 655 if (!leafFound && !isUsesPresentInList() && !isListPresentInGrouping()) {
615 throw new DataModelException("An identifier, in key, must refer to a child leaf of the list"); 656 throw new DataModelException("An identifier, in key, must refer to a child leaf of the list");
616 } 657 }
...@@ -627,17 +668,6 @@ public class YangList ...@@ -627,17 +668,6 @@ public class YangList
627 " \"config\" as the list itself."); 668 " \"config\" as the list itself.");
628 } 669 }
629 } 670 }
630 -
631 - /*
632 - * All key leafs in a list MUST have the same value for their "config"
633 - * as the list itself.
634 - */
635 - for (YangLeafList keyLeafList : keyLeafLists) {
636 - if (isConfig() != keyLeafList.isConfig()) {
637 - throw new DataModelException("All key leaf-lists in a list must have the same value for their" +
638 - " \"config\" as the list itself.");
639 - }
640 - }
641 } 671 }
642 672
643 @Override 673 @Override
......
...@@ -272,12 +272,12 @@ public abstract class YangNode ...@@ -272,12 +272,12 @@ public abstract class YangNode
272 * @throws CloneNotSupportedException clone is not supported by the referred 272 * @throws CloneNotSupportedException clone is not supported by the referred
273 * node 273 * node
274 */ 274 */
275 - public YangNode clone() 275 + public YangNode clone(YangUses yangUses)
276 throws CloneNotSupportedException { 276 throws CloneNotSupportedException {
277 YangNode clonedNode = (YangNode) super.clone(); 277 YangNode clonedNode = (YangNode) super.clone();
278 if (clonedNode instanceof YangLeavesHolder) { 278 if (clonedNode instanceof YangLeavesHolder) {
279 try { 279 try {
280 - cloneLeaves((YangLeavesHolder) clonedNode); 280 + cloneLeaves((YangLeavesHolder) clonedNode, yangUses);
281 } catch (DataModelException e) { 281 } catch (DataModelException e) {
282 throw new CloneNotSupportedException(e.getMessage()); 282 throw new CloneNotSupportedException(e.getMessage());
283 } 283 }
...@@ -299,7 +299,7 @@ public abstract class YangNode ...@@ -299,7 +299,7 @@ public abstract class YangNode
299 * @param dstRootNode destination node where the sub tree needs to be cloned 299 * @param dstRootNode destination node where the sub tree needs to be cloned
300 * @throws DataModelException data model error 300 * @throws DataModelException data model error
301 */ 301 */
302 - public static void cloneSubTree(YangNode srcRootNode, YangNode dstRootNode) 302 + public static void cloneSubTree(YangNode srcRootNode, YangNode dstRootNode, YangUses yangUses)
303 throws DataModelException { 303 throws DataModelException {
304 304
305 YangNode nextNodeToClone = srcRootNode; 305 YangNode nextNodeToClone = srcRootNode;
...@@ -327,7 +327,7 @@ public abstract class YangNode ...@@ -327,7 +327,7 @@ public abstract class YangNode
327 throw new DataModelException("Internal error: Cloning failed, source tree null pointer reached"); 327 throw new DataModelException("Internal error: Cloning failed, source tree null pointer reached");
328 } 328 }
329 if (curTraversal != PARENT) { 329 if (curTraversal != PARENT) {
330 - newNode = nextNodeToClone.clone(); 330 + newNode = nextNodeToClone.clone(yangUses);
331 detectCollisionWhileCloning(clonedTreeCurNode, newNode, curTraversal); 331 detectCollisionWhileCloning(clonedTreeCurNode, newNode, curTraversal);
332 } 332 }
333 333
......
...@@ -239,7 +239,7 @@ public class YangType<T> ...@@ -239,7 +239,7 @@ public class YangType<T>
239 } 239 }
240 240
241 @Override 241 @Override
242 - public void resolve() 242 + public Object resolve()
243 throws DataModelException { 243 throws DataModelException {
244 /* 244 /*
245 * Check whether the data type is derived. 245 * Check whether the data type is derived.
...@@ -260,6 +260,7 @@ public class YangType<T> ...@@ -260,6 +260,7 @@ public class YangType<T>
260 } catch (DataModelException e) { 260 } catch (DataModelException e) {
261 throw new DataModelException(e.getMessage()); 261 throw new DataModelException(e.getMessage());
262 } 262 }
263 + return null;
263 } 264 }
264 265
265 /** 266 /**
......
...@@ -26,6 +26,8 @@ import org.onosproject.yangutils.datamodel.utils.YangConstructType; ...@@ -26,6 +26,8 @@ import org.onosproject.yangutils.datamodel.utils.YangConstructType;
26 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; 26 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
27 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode; 27 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.getParentNodeInGenCode;
28 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.updateClonedLeavesUnionEnumRef; 28 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.updateClonedLeavesUnionEnumRef;
29 +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLeafrefUnderGroupingForLeaf;
30 +import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLeafrefUnderGroupingForLeafList;
29 31
30 /*- 32 /*-
31 * Reference RFC 6020. 33 * Reference RFC 6020.
...@@ -126,6 +128,16 @@ public class YangUses ...@@ -126,6 +128,16 @@ public class YangUses
126 private List<List<YangLeafList>> resolvedGroupingLeafLists; 128 private List<List<YangLeafList>> resolvedGroupingLeafLists;
127 129
128 /** 130 /**
131 + * Effective list of leaf lists of grouping that needs to replicated at YANG uses.
132 + */
133 + private List<YangEntityToResolveInfoImpl> entityToResolveInfoList;
134 +
135 + /**
136 + * Current grouping depth for uses.
137 + */
138 + private int currentGroupingDepth;
139 +
140 + /**
129 * Creates an YANG uses node. 141 * Creates an YANG uses node.
130 */ 142 */
131 public YangUses() { 143 public YangUses() {
...@@ -138,6 +150,38 @@ public class YangUses ...@@ -138,6 +150,38 @@ public class YangUses
138 } 150 }
139 151
140 /** 152 /**
153 + * Returns the list of entity to resolve.
154 + *
155 + * @return the list of entity to resolve
156 + */
157 + public List<YangEntityToResolveInfoImpl> getEntityToResolveInfoList() {
158 + return entityToResolveInfoList;
159 + }
160 +
161 + /**
162 + * Sets the list of entity to resolve.
163 + *
164 + * @param entityToResolveInfoList the list of entity to resolve
165 + */
166 + public void setEntityToResolveInfoList(List<YangEntityToResolveInfoImpl> entityToResolveInfoList) {
167 + this.entityToResolveInfoList = entityToResolveInfoList;
168 + }
169 +
170 + /**
171 + * Adds an entity to resolve in list.
172 + *
173 + * @param entityToResolve entity to resolved
174 + * @throws DataModelException a violation of data model rules
175 + */
176 + public void addEntityToResolve(YangEntityToResolveInfoImpl entityToResolve)
177 + throws DataModelException {
178 + if (getEntityToResolveInfoList() == null) {
179 + setEntityToResolveInfoList(new LinkedList<YangEntityToResolveInfoImpl>());
180 + }
181 + getEntityToResolveInfoList().add(entityToResolve);
182 + }
183 +
184 + /**
141 * Returns the referred group. 185 * Returns the referred group.
142 * 186 *
143 * @return the referred group 187 * @return the referred group
...@@ -314,7 +358,7 @@ public class YangUses ...@@ -314,7 +358,7 @@ public class YangUses
314 } 358 }
315 359
316 @Override 360 @Override
317 - public void resolve() 361 + public Object resolve()
318 throws DataModelException { 362 throws DataModelException {
319 363
320 YangGrouping referredGrouping = getRefGroup(); 364 YangGrouping referredGrouping = getRefGroup();
...@@ -337,7 +381,13 @@ public class YangUses ...@@ -337,7 +381,13 @@ public class YangUses
337 ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leaf.getName(), 381 ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leaf.getName(),
338 YangConstructType.LEAF_DATA); 382 YangConstructType.LEAF_DATA);
339 clonedLeaf = leaf.clone(); 383 clonedLeaf = leaf.clone();
340 - 384 + if (getCurrentGroupingDepth() == 0) {
385 + YangEntityToResolveInfoImpl resolveInfo = resolveLeafrefUnderGroupingForLeaf(clonedLeaf,
386 + usesParentLeavesHolder, this);
387 + if (resolveInfo != null) {
388 + addEntityToResolve(resolveInfo);
389 + }
390 + }
341 } catch (CloneNotSupportedException | DataModelException e) { 391 } catch (CloneNotSupportedException | DataModelException e) {
342 throw new DataModelException(e.getMessage()); 392 throw new DataModelException(e.getMessage());
343 } 393 }
...@@ -353,7 +403,13 @@ public class YangUses ...@@ -353,7 +403,13 @@ public class YangUses
353 ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leafList.getName(), 403 ((CollisionDetector) usesParentLeavesHolder).detectCollidingChild(leafList.getName(),
354 YangConstructType.LEAF_LIST_DATA); 404 YangConstructType.LEAF_LIST_DATA);
355 clonedLeafList = leafList.clone(); 405 clonedLeafList = leafList.clone();
356 - 406 + if (getCurrentGroupingDepth() == 0) {
407 + YangEntityToResolveInfoImpl resolveInfo =
408 + resolveLeafrefUnderGroupingForLeafList(clonedLeafList, usesParentLeavesHolder);
409 + if (resolveInfo != null) {
410 + addEntityToResolve(resolveInfo);
411 + }
412 + }
357 } catch (CloneNotSupportedException | DataModelException e) { 413 } catch (CloneNotSupportedException | DataModelException e) {
358 throw new DataModelException(e.getMessage()); 414 throw new DataModelException(e.getMessage());
359 } 415 }
...@@ -364,11 +420,12 @@ public class YangUses ...@@ -364,11 +420,12 @@ public class YangUses
364 } 420 }
365 421
366 try { 422 try {
367 - YangNode.cloneSubTree(referredGrouping, usesParentNode); 423 + YangNode.cloneSubTree(referredGrouping, usesParentNode, this);
368 } catch (DataModelException e) { 424 } catch (DataModelException e) {
369 throw new DataModelException(e.getMessage()); 425 throw new DataModelException(e.getMessage());
370 } 426 }
371 updateClonedLeavesUnionEnumRef(usesParentLeavesHolder); 427 updateClonedLeavesUnionEnumRef(usesParentLeavesHolder);
428 + return getEntityToResolveInfoList();
372 } 429 }
373 430
374 /** 431 /**
...@@ -378,7 +435,7 @@ public class YangUses ...@@ -378,7 +435,7 @@ public class YangUses
378 * @param usesHolder holder of uses 435 * @param usesHolder holder of uses
379 */ 436 */
380 private void addResolvedUsesInfoOfGrouping(YangUses usesInGrouping, 437 private void addResolvedUsesInfoOfGrouping(YangUses usesInGrouping,
381 - YangLeavesHolder usesHolder) throws DataModelException { 438 + YangLeavesHolder usesHolder) throws DataModelException {
382 for (YangNode usesResolvedNode : usesInGrouping.getUsesResolvedNodeList()) { 439 for (YangNode usesResolvedNode : usesInGrouping.getUsesResolvedNodeList()) {
383 addNodeOfGrouping(usesResolvedNode); 440 addNodeOfGrouping(usesResolvedNode);
384 } 441 }
...@@ -402,7 +459,7 @@ public class YangUses ...@@ -402,7 +459,7 @@ public class YangUses
402 * @throws DataModelException a violation in data model rule 459 * @throws DataModelException a violation in data model rule
403 */ 460 */
404 private List<YangLeaf> cloneLeavesList(List<YangLeaf> listOfLeaves, 461 private List<YangLeaf> cloneLeavesList(List<YangLeaf> listOfLeaves,
405 - YangLeavesHolder usesParentNode) throws DataModelException { 462 + YangLeavesHolder usesParentNode) throws DataModelException {
406 if (listOfLeaves == null || listOfLeaves.size() == 0) { 463 if (listOfLeaves == null || listOfLeaves.size() == 0) {
407 throw new DataModelException("No leaves to clone"); 464 throw new DataModelException("No leaves to clone");
408 } 465 }
...@@ -433,7 +490,7 @@ public class YangUses ...@@ -433,7 +490,7 @@ public class YangUses
433 * @return cloned list of leaf list 490 * @return cloned list of leaf list
434 */ 491 */
435 private List<YangLeafList> cloneListOfLeafList(List<YangLeafList> listOfLeafList, 492 private List<YangLeafList> cloneListOfLeafList(List<YangLeafList> listOfLeafList,
436 - YangLeavesHolder usesParentNode) throws DataModelException { 493 + YangLeavesHolder usesParentNode) throws DataModelException {
437 if (listOfLeafList == null || listOfLeafList.size() == 0) { 494 if (listOfLeafList == null || listOfLeafList.size() == 0) {
438 throw new DataModelException("No leaf lists to clone"); 495 throw new DataModelException("No leaf lists to clone");
439 } 496 }
...@@ -556,4 +613,13 @@ public class YangUses ...@@ -556,4 +613,13 @@ public class YangUses
556 public void setIfFeatureList(List<YangIfFeature> ifFeatureList) { 613 public void setIfFeatureList(List<YangIfFeature> ifFeatureList) {
557 this.ifFeatureList = ifFeatureList; 614 this.ifFeatureList = ifFeatureList;
558 } 615 }
616 +
617 + public void setCurrentGroupingDepth(int currentGroupingDepth) {
618 + this.currentGroupingDepth = currentGroupingDepth;
619 + }
620 +
621 + public int getCurrentGroupingDepth() {
622 + return currentGroupingDepth;
623 + }
624 +
559 } 625 }
......
...@@ -177,11 +177,11 @@ public class YangLinkerManager ...@@ -177,11 +177,11 @@ public class YangLinkerManager
177 ((YangReferenceResolver) yangNode) 177 ((YangReferenceResolver) yangNode)
178 .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE); 178 .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
179 ((YangReferenceResolver) yangNode) 179 ((YangReferenceResolver) yangNode)
180 - .resolveInterFileLinking(ResolvableType.YANG_LEAFREF);
181 - ((YangReferenceResolver) yangNode)
182 .resolveInterFileLinking(ResolvableType.YANG_BASE); 180 .resolveInterFileLinking(ResolvableType.YANG_BASE);
183 ((YangReferenceResolver) yangNode) 181 ((YangReferenceResolver) yangNode)
184 .resolveInterFileLinking(ResolvableType.YANG_IDENTITYREF); 182 .resolveInterFileLinking(ResolvableType.YANG_IDENTITYREF);
183 + ((YangReferenceResolver) yangNode)
184 + .resolveInterFileLinking(ResolvableType.YANG_LEAFREF);
185 } catch (DataModelException e) { 185 } catch (DataModelException e) {
186 String errorInfo = "Error in file: " + yangNode.getName() + " at line: " 186 String errorInfo = "Error in file: " + yangNode.getName() + " at line: "
187 + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE + e.getMessage(); 187 + e.getLineNumber() + " at position: " + e.getCharPositionInLine() + NEW_LINE + e.getMessage();
......
...@@ -16,18 +16,28 @@ ...@@ -16,18 +16,28 @@
16 16
17 package org.onosproject.yangutils.linker.impl; 17 package org.onosproject.yangutils.linker.impl;
18 18
19 -import java.util.List;
20 -
21 import org.onosproject.yangutils.datamodel.YangAugment; 19 import org.onosproject.yangutils.datamodel.YangAugment;
22 import org.onosproject.yangutils.datamodel.YangAugmentableNode; 20 import org.onosproject.yangutils.datamodel.YangAugmentableNode;
23 import org.onosproject.yangutils.datamodel.YangAugmentedInfo; 21 import org.onosproject.yangutils.datamodel.YangAugmentedInfo;
22 +import org.onosproject.yangutils.datamodel.YangCase;
24 import org.onosproject.yangutils.datamodel.YangChoice; 23 import org.onosproject.yangutils.datamodel.YangChoice;
25 import org.onosproject.yangutils.datamodel.YangLeaf; 24 import org.onosproject.yangutils.datamodel.YangLeaf;
26 import org.onosproject.yangutils.datamodel.YangLeafList; 25 import org.onosproject.yangutils.datamodel.YangLeafList;
26 +import org.onosproject.yangutils.datamodel.YangLeafRef;
27 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 27 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
28 import org.onosproject.yangutils.datamodel.YangNode; 28 import org.onosproject.yangutils.datamodel.YangNode;
29 +import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
30 +import org.onosproject.yangutils.datamodel.utils.YangConstructType;
29 import org.onosproject.yangutils.linker.exceptions.LinkerException; 31 import org.onosproject.yangutils.linker.exceptions.LinkerException;
30 32
33 +import java.util.ArrayList;
34 +import java.util.List;
35 +import java.util.regex.Pattern;
36 +
37 +import static org.onosproject.yangutils.utils.UtilConstants.COLON;
38 +import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
39 +import static org.onosproject.yangutils.utils.UtilConstants.SLASH_FOR_STRING;
40 +
31 /** 41 /**
32 * Represent utilities for YANG linker. 42 * Represent utilities for YANG linker.
33 */ 43 */
...@@ -36,6 +46,10 @@ public final class YangLinkerUtils { ...@@ -36,6 +46,10 @@ public final class YangLinkerUtils {
36 private YangLinkerUtils() { 46 private YangLinkerUtils() {
37 } 47 }
38 48
49 + private static final int IDENTIFIER_LENGTH = 64;
50 + private static final Pattern IDENTIFIER_PATTERN = Pattern.compile("[a-zA-Z_][a-zA-Z0-9_.-]*");
51 + private static final String XML = "xml";
52 +
39 /** 53 /**
40 * Detects collision between target nodes leaf/leaf-list or child node with augmented leaf/leaf-list or child node. 54 * Detects collision between target nodes leaf/leaf-list or child node with augmented leaf/leaf-list or child node.
41 * 55 *
...@@ -119,4 +133,99 @@ public final class YangLinkerUtils { ...@@ -119,4 +133,99 @@ public final class YangLinkerUtils {
119 detectCollision((YangAugment) info, augment); 133 detectCollision((YangAugment) info, augment);
120 } 134 }
121 } 135 }
136 +
137 + /**
138 + * Returns list of path names that are needed from augment.
139 + *
140 + * @param augment instance of YANG augment
141 + * @param remainingAncestors ancestor count to move in augment path
142 + * @return list of path names needed in leafref
143 + */
144 + public static List<String> getPathWithAugment(YangAugment augment, int remainingAncestors) {
145 + String augmentName = augment.getName();
146 + List<String> listOfPathName = new ArrayList<>();
147 + if (augmentName.contains(SLASH_FOR_STRING)) {
148 + String[] augmentNodeNames = augmentName.split(SLASH_FOR_STRING);
149 + for (String valueInAugment : augmentNodeNames) {
150 + if (valueInAugment != null && valueInAugment != EMPTY_STRING && !valueInAugment.isEmpty()) {
151 + listOfPathName.add(valueInAugment);
152 + }
153 + }
154 + }
155 + for (int countOfAncestor = 0; countOfAncestor < remainingAncestors; countOfAncestor++) {
156 + listOfPathName.remove(listOfPathName.size() - 1);
157 + }
158 + return listOfPathName;
159 + }
160 +
161 + /**
162 + * Skips the invalid nodes which cannot have data from YANG.
163 + *
164 + * @param currentParent current parent node reference
165 + * @param leafref instance of YANG leafref
166 + * @return parent node which can hold data
167 + * @throws LinkerException a violation of linker rules
168 + */
169 + public static YangNode skipInvalidDataNodes(YangNode currentParent, YangLeafRef leafref) throws LinkerException {
170 + while (currentParent instanceof YangChoice || currentParent instanceof YangCase) {
171 + if (currentParent.getParent() == null) {
172 + throw new LinkerException("YANG file error: The target node, in the leafref path " +
173 + leafref.getPath() + ", is invalid.");
174 + }
175 + currentParent = currentParent.getParent();
176 + }
177 + return currentParent;
178 + }
179 +
180 + /**
181 + * Checks and return valid node identifier.
182 + *
183 + * @param nodeIdentifierString string from yang file
184 + * @param yangConstruct yang construct for creating error message
185 + * @return valid node identifier
186 + */
187 + public static YangNodeIdentifier getValidNodeIdentifier(String nodeIdentifierString,
188 + YangConstructType yangConstruct) {
189 + String[] tmpData = nodeIdentifierString.split(Pattern.quote(COLON));
190 + if (tmpData.length == 1) {
191 + YangNodeIdentifier nodeIdentifier = new YangNodeIdentifier();
192 + nodeIdentifier.setName(getValidIdentifier(tmpData[0], yangConstruct));
193 + return nodeIdentifier;
194 + } else if (tmpData.length == 2) {
195 + YangNodeIdentifier nodeIdentifier = new YangNodeIdentifier();
196 + nodeIdentifier.setPrefix(getValidIdentifier(tmpData[0], yangConstruct));
197 + nodeIdentifier.setName(getValidIdentifier(tmpData[1], yangConstruct));
198 + return nodeIdentifier;
199 + } else {
200 + throw new LinkerException("YANG file error : " +
201 + YangConstructType.getYangConstructType(yangConstruct) + " name " + nodeIdentifierString +
202 + " is not valid.");
203 + }
204 + }
205 +
206 + /**
207 + * Validates identifier and returns concatenated string if string contains plus symbol.
208 + *
209 + * @param identifier string from yang file
210 + * @param yangConstruct yang construct for creating error message=
211 + * @return concatenated string after removing double quotes
212 + */
213 + public static String getValidIdentifier(String identifier, YangConstructType yangConstruct) {
214 +
215 + if (identifier.length() > IDENTIFIER_LENGTH) {
216 + throw new LinkerException("YANG file error : " +
217 + YangConstructType.getYangConstructType(yangConstruct) + " name " + identifier + " is " +
218 + "greater than 64 characters.");
219 + } else if (!IDENTIFIER_PATTERN.matcher(identifier).matches()) {
220 + throw new LinkerException("YANG file error : " +
221 + YangConstructType.getYangConstructType(yangConstruct) + " name " + identifier + " is not " +
222 + "valid.");
223 + } else if (identifier.toLowerCase().startsWith(XML)) {
224 + throw new LinkerException("YANG file error : " +
225 + YangConstructType.getYangConstructType(yangConstruct) + " identifier " + identifier +
226 + " must not start with (('X'|'x') ('M'|'m') ('L'|'l')).");
227 + } else {
228 + return identifier;
229 + }
230 + }
122 } 231 }
......
...@@ -16,31 +16,41 @@ ...@@ -16,31 +16,41 @@
16 16
17 package org.onosproject.yangutils.linker.impl; 17 package org.onosproject.yangutils.linker.impl;
18 18
19 -import java.util.ArrayList;
20 -import java.util.HashMap;
21 -import java.util.Iterator;
22 -import java.util.List;
23 -import java.util.Map;
24 -import java.util.Stack;
25 -
26 import org.onosproject.yangutils.datamodel.YangAtomicPath; 19 import org.onosproject.yangutils.datamodel.YangAtomicPath;
27 import org.onosproject.yangutils.datamodel.YangAugment; 20 import org.onosproject.yangutils.datamodel.YangAugment;
21 +import org.onosproject.yangutils.datamodel.YangCase;
22 +import org.onosproject.yangutils.datamodel.YangChoice;
23 +import org.onosproject.yangutils.datamodel.YangGrouping;
28 import org.onosproject.yangutils.datamodel.YangImport; 24 import org.onosproject.yangutils.datamodel.YangImport;
29 import org.onosproject.yangutils.datamodel.YangInclude; 25 import org.onosproject.yangutils.datamodel.YangInclude;
26 +import org.onosproject.yangutils.datamodel.YangInput;
30 import org.onosproject.yangutils.datamodel.YangLeaf; 27 import org.onosproject.yangutils.datamodel.YangLeaf;
31 import org.onosproject.yangutils.datamodel.YangLeafList; 28 import org.onosproject.yangutils.datamodel.YangLeafList;
29 +import org.onosproject.yangutils.datamodel.YangLeafRef;
32 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 30 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
33 import org.onosproject.yangutils.datamodel.YangModule; 31 import org.onosproject.yangutils.datamodel.YangModule;
34 import org.onosproject.yangutils.datamodel.YangNode; 32 import org.onosproject.yangutils.datamodel.YangNode;
35 import org.onosproject.yangutils.datamodel.YangNodeIdentifier; 33 import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
34 +import org.onosproject.yangutils.datamodel.YangOutput;
36 import org.onosproject.yangutils.datamodel.YangSubModule; 35 import org.onosproject.yangutils.datamodel.YangSubModule;
36 +import org.onosproject.yangutils.datamodel.YangTypeDef;
37 +import org.onosproject.yangutils.datamodel.YangUses;
37 import org.onosproject.yangutils.linker.exceptions.LinkerException; 38 import org.onosproject.yangutils.linker.exceptions.LinkerException;
38 39
40 +import java.util.ArrayList;
41 +import java.util.HashMap;
42 +import java.util.Iterator;
43 +import java.util.List;
44 +import java.util.Map;
45 +import java.util.Stack;
46 +
39 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTER; 47 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTER;
40 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTRA; 48 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTER_TO_INTRA;
41 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTRA_TO_INTER; 49 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.INTRA_TO_INTER;
42 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.NO_PREFIX_CHANGE_FOR_INTER; 50 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.NO_PREFIX_CHANGE_FOR_INTER;
43 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.NO_PREFIX_CHANGE_FOR_INTRA; 51 import static org.onosproject.yangutils.linker.impl.PrefixResolverType.NO_PREFIX_CHANGE_FOR_INTRA;
52 +import static org.onosproject.yangutils.utils.UtilConstants.INPUT;
53 +import static org.onosproject.yangutils.utils.UtilConstants.OUTPUT;
44 54
45 /** 55 /**
46 * Represents x-path linking. 56 * Represents x-path linking.
...@@ -194,31 +204,35 @@ public class YangXpathLinker<T> { ...@@ -194,31 +204,35 @@ public class YangXpathLinker<T> {
194 /** 204 /**
195 * Process absolute node path for target leaf. 205 * Process absolute node path for target leaf.
196 * 206 *
197 - * @param absPaths absolute path node list 207 + * @param atomicPaths atomic path node list
198 - * @param root root node 208 + * @param root root node
209 + * @param leafref instance of YANG leafref
199 * @return linked target node 210 * @return linked target node
200 */ 211 */
201 - T processLeafRefXpathLinking(List<YangAtomicPath> absPaths, YangNode root) { 212 + public T processLeafRefXpathLinking(List<YangAtomicPath> atomicPaths, YangNode root, YangLeafRef leafref) {
202 213
203 YangNode targetNode = null; 214 YangNode targetNode = null;
204 setRootNode(root); 215 setRootNode(root);
205 setPrefixResolverTypes(new HashMap<>()); 216 setPrefixResolverTypes(new HashMap<>());
206 - parsePrefixResolverList(absPaths); 217 + parsePrefixResolverList(atomicPaths);
207 - YangAtomicPath leafRefPath = absPaths.get(absPaths.size() - 1); 218 + YangAtomicPath leafRefPath = atomicPaths.get(atomicPaths.size() - 1);
208 219
209 // When leaf-ref path contains only one absolute path. 220 // When leaf-ref path contains only one absolute path.
210 - if (absPaths.size() == 1) { 221 + if (atomicPaths.size() == 1) {
211 - targetNode = getTargetNodewhenSizeIsOne(absPaths); 222 + targetNode = getTargetNodewhenSizeIsOne(atomicPaths);
212 } else { 223 } else {
213 - absPaths.remove(absPaths.size() - 1); 224 + atomicPaths.remove(atomicPaths.size() - 1);
214 225
215 - setAbsPaths(absPaths); 226 + setAbsPaths(atomicPaths);
216 targetNode = parseData(root); 227 targetNode = parseData(root);
217 } 228 }
218 if (targetNode == null) { 229 if (targetNode == null) {
219 targetNode = searchInSubModule(root); 230 targetNode = searchInSubModule(root);
220 } 231 }
221 232
233 + // Invalid path presence in the node list is checked.
234 + validateInvalidNodesInThePath(leafref);
235 +
222 if (targetNode != null) { 236 if (targetNode != null) {
223 YangLeaf targetLeaf = searchReferredLeaf(targetNode, leafRefPath.getNodeIdentifier().getName()); 237 YangLeaf targetLeaf = searchReferredLeaf(targetNode, leafRefPath.getNodeIdentifier().getName());
224 if (targetLeaf == null) { 238 if (targetLeaf == null) {
...@@ -227,9 +241,12 @@ public class YangXpathLinker<T> { ...@@ -227,9 +241,12 @@ public class YangXpathLinker<T> {
227 if (targetLeafList != null) { 241 if (targetLeafList != null) {
228 return (T) targetLeafList; 242 return (T) targetLeafList;
229 } else { 243 } else {
230 - throw new LinkerException( 244 + LinkerException linkerException = new LinkerException("YANG file error: Unable to find base " +
231 - "YANG file error: Unable to find base leaf/leaf-list for given leafref " 245 + "leaf/leaf-list for given leafref path "
232 - + leafRefPath.getNodeIdentifier().getName()); 246 + + leafref.getPath());
247 + linkerException.setCharPosition(leafref.getCharPosition());
248 + linkerException.setLine(leafref.getLineNumber());
249 + throw linkerException;
233 } 250 }
234 } 251 }
235 return (T) targetLeaf; 252 return (T) targetLeaf;
...@@ -238,6 +255,30 @@ public class YangXpathLinker<T> { ...@@ -238,6 +255,30 @@ public class YangXpathLinker<T> {
238 } 255 }
239 256
240 /** 257 /**
258 + * Validates the nodes in the path for any invalid node.
259 + *
260 + * @param leafref instance of YANG leafref
261 + */
262 + private void validateInvalidNodesInThePath(YangLeafRef leafref) {
263 + Map<YangAtomicPath, YangNode> nodes = getResolvedNodes();
264 + Iterator<Map.Entry<YangAtomicPath, YangNode>> nodesIterator = nodes.entrySet().iterator();
265 + while (nodesIterator.hasNext()) {
266 + Map.Entry<YangAtomicPath, YangNode> nodeInList = nodesIterator.next();
267 + YangNode nodeInPath = nodeInList.getValue();
268 +
269 + if (nodeInPath instanceof YangGrouping || nodeInPath instanceof YangUses
270 + || nodeInPath instanceof YangTypeDef || nodeInPath instanceof YangCase
271 + || nodeInPath instanceof YangChoice) {
272 + LinkerException linkerException = new LinkerException("YANG file error: The target node, in the " +
273 + "leafref path " + leafref.getPath() + ", is invalid.");
274 + linkerException.setCharPosition(leafref.getCharPosition());
275 + linkerException.setLine(leafref.getLineNumber());
276 + throw linkerException;
277 + }
278 + }
279 + }
280 +
281 + /**
241 * Returns target node when leaf-ref has only one absolute path in list. 282 * Returns target node when leaf-ref has only one absolute path in list.
242 * 283 *
243 * @param absPaths absolute paths 284 * @param absPaths absolute paths
...@@ -289,9 +330,13 @@ public class YangXpathLinker<T> { ...@@ -289,9 +330,13 @@ public class YangXpathLinker<T> {
289 } 330 }
290 YangLeavesHolder holder = (YangLeavesHolder) targetNode; 331 YangLeavesHolder holder = (YangLeavesHolder) targetNode;
291 List<YangLeaf> leaves = holder.getListOfLeaf(); 332 List<YangLeaf> leaves = holder.getListOfLeaf();
292 - for (YangLeaf leaf : leaves) { 333 + if (leaves != null && !leaves.isEmpty()) {
293 - if (leaf.getName().equals(leafName)) { 334 + Iterator<YangLeaf> leafIterator = leaves.listIterator();
294 - return leaf; 335 + while (leafIterator.hasNext()) {
336 + YangLeaf leaf = leafIterator.next();
337 + if (leaf.getName().equals(leafName)) {
338 + return leaf;
339 + }
295 } 340 }
296 } 341 }
297 return null; 342 return null;
...@@ -311,9 +356,13 @@ public class YangXpathLinker<T> { ...@@ -311,9 +356,13 @@ public class YangXpathLinker<T> {
311 } 356 }
312 YangLeavesHolder holder = (YangLeavesHolder) targetNode; 357 YangLeavesHolder holder = (YangLeavesHolder) targetNode;
313 List<YangLeafList> leavesList = holder.getListOfLeafList(); 358 List<YangLeafList> leavesList = holder.getListOfLeafList();
314 - for (YangLeafList leafList : leavesList) { 359 + if (leavesList != null && !leavesList.isEmpty()) {
315 - if (leafList.getName().equals(leafListName)) { 360 + Iterator<YangLeafList> leafListIterator = leavesList.listIterator();
316 - return leafList; 361 + while (leafListIterator.hasNext()) {
362 + YangLeafList leafList = leafListIterator.next();
363 + if (leafList.getName().equals(leafListName)) {
364 + return leafList;
365 + }
317 } 366 }
318 } 367 }
319 return null; 368 return null;
...@@ -709,6 +758,15 @@ public class YangXpathLinker<T> { ...@@ -709,6 +758,15 @@ public class YangXpathLinker<T> {
709 } 758 }
710 759
711 while (node != null) { 760 while (node != null) {
761 + if (node instanceof YangInput) {
762 + if (curNodeId.getName().equalsIgnoreCase(INPUT)) {
763 + return node;
764 + }
765 + } else if (node instanceof YangOutput) {
766 + if (curNodeId.getName().equalsIgnoreCase(OUTPUT)) {
767 + return node;
768 + }
769 + }
712 if (node.getName().equals(curNodeId.getName())) { 770 if (node.getName().equals(curNodeId.getName())) {
713 return node; 771 return node;
714 } 772 }
......
...@@ -16,8 +16,6 @@ ...@@ -16,8 +16,6 @@
16 16
17 package org.onosproject.yangutils.parser.impl; 17 package org.onosproject.yangutils.parser.impl;
18 18
19 -import java.util.Stack;
20 -
21 import org.antlr.v4.runtime.ParserRuleContext; 19 import org.antlr.v4.runtime.ParserRuleContext;
22 import org.antlr.v4.runtime.tree.ErrorNode; 20 import org.antlr.v4.runtime.tree.ErrorNode;
23 import org.antlr.v4.runtime.tree.TerminalNode; 21 import org.antlr.v4.runtime.tree.TerminalNode;
...@@ -42,12 +40,14 @@ import org.onosproject.yangutils.parser.impl.listeners.DefaultListener; ...@@ -42,12 +40,14 @@ import org.onosproject.yangutils.parser.impl.listeners.DefaultListener;
42 import org.onosproject.yangutils.parser.impl.listeners.DescriptionListener; 40 import org.onosproject.yangutils.parser.impl.listeners.DescriptionListener;
43 import org.onosproject.yangutils.parser.impl.listeners.EnumListener; 41 import org.onosproject.yangutils.parser.impl.listeners.EnumListener;
44 import org.onosproject.yangutils.parser.impl.listeners.EnumerationListener; 42 import org.onosproject.yangutils.parser.impl.listeners.EnumerationListener;
43 +import org.onosproject.yangutils.parser.impl.listeners.ErrorAppTagListener;
44 +import org.onosproject.yangutils.parser.impl.listeners.ErrorMessageListener;
45 import org.onosproject.yangutils.parser.impl.listeners.FeatureListener; 45 import org.onosproject.yangutils.parser.impl.listeners.FeatureListener;
46 import org.onosproject.yangutils.parser.impl.listeners.FractionDigitsListener; 46 import org.onosproject.yangutils.parser.impl.listeners.FractionDigitsListener;
47 import org.onosproject.yangutils.parser.impl.listeners.GroupingListener; 47 import org.onosproject.yangutils.parser.impl.listeners.GroupingListener;
48 +import org.onosproject.yangutils.parser.impl.listeners.IdentityListener;
48 import org.onosproject.yangutils.parser.impl.listeners.IdentityrefListener; 49 import org.onosproject.yangutils.parser.impl.listeners.IdentityrefListener;
49 import org.onosproject.yangutils.parser.impl.listeners.IfFeatureListener; 50 import org.onosproject.yangutils.parser.impl.listeners.IfFeatureListener;
50 -import org.onosproject.yangutils.parser.impl.listeners.IdentityListener;
51 import org.onosproject.yangutils.parser.impl.listeners.ImportListener; 51 import org.onosproject.yangutils.parser.impl.listeners.ImportListener;
52 import org.onosproject.yangutils.parser.impl.listeners.IncludeListener; 52 import org.onosproject.yangutils.parser.impl.listeners.IncludeListener;
53 import org.onosproject.yangutils.parser.impl.listeners.InputListener; 53 import org.onosproject.yangutils.parser.impl.listeners.InputListener;
...@@ -83,13 +83,15 @@ import org.onosproject.yangutils.parser.impl.listeners.SubModuleListener; ...@@ -83,13 +83,15 @@ import org.onosproject.yangutils.parser.impl.listeners.SubModuleListener;
83 import org.onosproject.yangutils.parser.impl.listeners.TypeDefListener; 83 import org.onosproject.yangutils.parser.impl.listeners.TypeDefListener;
84 import org.onosproject.yangutils.parser.impl.listeners.TypeListener; 84 import org.onosproject.yangutils.parser.impl.listeners.TypeListener;
85 import org.onosproject.yangutils.parser.impl.listeners.UnionListener; 85 import org.onosproject.yangutils.parser.impl.listeners.UnionListener;
86 +import org.onosproject.yangutils.parser.impl.listeners.UniqueListener;
86 import org.onosproject.yangutils.parser.impl.listeners.UnitsListener; 87 import org.onosproject.yangutils.parser.impl.listeners.UnitsListener;
87 import org.onosproject.yangutils.parser.impl.listeners.UsesListener; 88 import org.onosproject.yangutils.parser.impl.listeners.UsesListener;
88 import org.onosproject.yangutils.parser.impl.listeners.ValueListener; 89 import org.onosproject.yangutils.parser.impl.listeners.ValueListener;
89 import org.onosproject.yangutils.parser.impl.listeners.VersionListener; 90 import org.onosproject.yangutils.parser.impl.listeners.VersionListener;
90 import org.onosproject.yangutils.parser.impl.listeners.WhenListener; 91 import org.onosproject.yangutils.parser.impl.listeners.WhenListener;
91 -import org.onosproject.yangutils.parser.impl.listeners.ErrorMessageListener; 92 +
92 -import org.onosproject.yangutils.parser.impl.listeners.ErrorAppTagListener; 93 +import java.util.Stack;
94 +
93 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.handleUnsupportedYangConstruct; 95 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.handleUnsupportedYangConstruct;
94 import static org.onosproject.yangutils.utils.UtilConstants.CURRENTLY_UNSUPPORTED; 96 import static org.onosproject.yangutils.utils.UtilConstants.CURRENTLY_UNSUPPORTED;
95 import static org.onosproject.yangutils.utils.UtilConstants.UNSUPPORTED_YANG_CONSTRUCT; 97 import static org.onosproject.yangutils.utils.UtilConstants.UNSUPPORTED_YANG_CONSTRUCT;
...@@ -109,6 +111,34 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -109,6 +111,34 @@ public class TreeWalkListener implements GeneratedYangListener {
109 private YangNode rootNode; 111 private YangNode rootNode;
110 112
111 /** 113 /**
114 + * Parent depth of grouping count for any node.
115 + */
116 + private int groupingDepth;
117 +
118 + /**
119 + * Returns number of grouping parents, by a node, at any level.
120 + *
121 + * @return depth of grouping
122 + */
123 + public int getGroupingDepth() {
124 + return groupingDepth;
125 + }
126 +
127 + /**
128 + * Sets number of grouping parents by a node at any level.
129 + */
130 + public void increaseGroupingDepth() {
131 + groupingDepth++;
132 + }
133 +
134 + /**
135 + * Sets number of grouping parents by a node at any level.
136 + */
137 + public void decreaseGroupingDepth() {
138 + groupingDepth--;
139 + }
140 +
141 + /**
112 * Returns stack of parsable data. 142 * Returns stack of parsable data.
113 * 143 *
114 * @return stack of parsable data 144 * @return stack of parsable data
...@@ -956,7 +986,7 @@ public class TreeWalkListener implements GeneratedYangListener { ...@@ -956,7 +986,7 @@ public class TreeWalkListener implements GeneratedYangListener {
956 986
957 @Override 987 @Override
958 public void enterUniqueStatement(GeneratedYangParser.UniqueStatementContext ctx) { 988 public void enterUniqueStatement(GeneratedYangParser.UniqueStatementContext ctx) {
959 - handleUnsupportedYangConstruct(YangConstructType.UNIQUE_DATA, ctx, CURRENTLY_UNSUPPORTED); 989 + UniqueListener.processUniqueEntry(this, ctx);
960 } 990 }
961 991
962 @Override 992 @Override
......
...@@ -106,6 +106,8 @@ public final class GroupingListener { ...@@ -106,6 +106,8 @@ public final class GroupingListener {
106 // Validate sub statement cardinality. 106 // Validate sub statement cardinality.
107 validateSubStatementsCardinality(ctx); 107 validateSubStatementsCardinality(ctx);
108 108
109 + // Increase the grouping count by one.
110 + listener.increaseGroupingDepth();
109 Parsable curData = listener.getParsedDataStack().peek(); 111 Parsable curData = listener.getParsedDataStack().peek();
110 112
111 // Check for identifier collision 113 // Check for identifier collision
...@@ -149,6 +151,8 @@ public final class GroupingListener { ...@@ -149,6 +151,8 @@ public final class GroupingListener {
149 // Check for stack to be non empty. 151 // Check for stack to be non empty.
150 checkStackIsNotEmpty(listener, MISSING_HOLDER, GROUPING_DATA, ctx.identifier().getText(), EXIT); 152 checkStackIsNotEmpty(listener, MISSING_HOLDER, GROUPING_DATA, ctx.identifier().getText(), EXIT);
151 153
154 + // Decrease the grouping count by one.
155 + listener.decreaseGroupingDepth();
152 if (listener.getParsedDataStack().peek() instanceof YangGrouping) { 156 if (listener.getParsedDataStack().peek() instanceof YangGrouping) {
153 listener.getParsedDataStack().pop(); 157 listener.getParsedDataStack().pop();
154 } else { 158 } else {
......
...@@ -100,6 +100,8 @@ public final class LeafrefListener { ...@@ -100,6 +100,8 @@ public final class LeafrefListener {
100 100
101 YangLeafRef<?> leafRef = new YangLeafRef<>(); 101 YangLeafRef<?> leafRef = new YangLeafRef<>();
102 102
103 + leafRef.setLineNumber(errorLine);
104 + leafRef.setCharPosition(errorPosition);
103 Parsable typeData = listener.getParsedDataStack().pop(); 105 Parsable typeData = listener.getParsedDataStack().pop();
104 106
105 if (!(typeData instanceof YangType)) { 107 if (!(typeData instanceof YangType)) {
...@@ -130,11 +132,13 @@ public final class LeafrefListener { ...@@ -130,11 +132,13 @@ public final class LeafrefListener {
130 } 132 }
131 133
132 leafRef.setResolvableStatus(UNRESOLVED); 134 leafRef.setResolvableStatus(UNRESOLVED);
133 - 135 + leafRef.setParentNodeOfLeafref((YangNode) parentNodeOfLeaf);
134 - // Add resolution information to the list. 136 + if (listener.getGroupingDepth() == 0) {
135 - YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangLeafRef>(leafRef, 137 + // Add resolution information to the list.
136 - (YangNode) parentNodeOfLeaf, errorLine, errorPosition); 138 + YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangLeafRef>(leafRef,
137 - addToResolutionList(resolutionInfo); 139 + (YangNode) parentNodeOfLeaf, errorLine, errorPosition);
140 + addToResolutionList(resolutionInfo);
141 + }
138 break; 142 break;
139 143
140 case LEAF_LIST_DATA: 144 case LEAF_LIST_DATA:
...@@ -151,14 +155,19 @@ public final class LeafrefListener { ...@@ -151,14 +155,19 @@ public final class LeafrefListener {
151 } 155 }
152 156
153 leafRef.setResolvableStatus(UNRESOLVED); 157 leafRef.setResolvableStatus(UNRESOLVED);
158 + leafRef.setParentNodeOfLeafref((YangNode) parentNodeOfLeafList);
154 159
155 - // Add resolution information to the list. 160 + if (listener.getGroupingDepth() == 0) {
156 - YangResolutionInfoImpl resolutionInfoImpl = new YangResolutionInfoImpl<YangLeafRef>(leafRef, 161 + // Add resolution information to the list.
157 - (YangNode) parentNodeOfLeafList, errorLine, errorPosition); 162 + YangResolutionInfoImpl resolutionInfoImpl = new YangResolutionInfoImpl<YangLeafRef>(leafRef,
158 - addToResolutionList(resolutionInfoImpl); 163 + (YangNode) parentNodeOfLeafList, errorLine, errorPosition);
164 + addToResolutionList(resolutionInfoImpl);
165 + }
159 break; 166 break;
160 167
161 case TYPEDEF_DATA: 168 case TYPEDEF_DATA:
169 + Parsable parentNodeOfLeafref = listener.getParsedDataStack().peek();
170 + leafRef.setParentNodeOfLeafref((YangNode) parentNodeOfLeafref);
162 /* 171 /*
163 * Do not add the leaf ref to resolution list. It needs to be 172 * Do not add the leaf ref to resolution list. It needs to be
164 * added to resolution list, when leaf/leaf list references to 173 * added to resolution list, when leaf/leaf list references to
......
...@@ -54,6 +54,7 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp ...@@ -54,6 +54,7 @@ import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorTyp
54 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER; 54 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
55 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA; 55 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
56 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier; 56 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier;
57 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.validateUniqueInList;
57 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty; 58 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
58 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne; 59 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityMaxOne;
59 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityNonZero; 60 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.validateCardinalityNonZero;
...@@ -174,6 +175,7 @@ public final class ListListener { ...@@ -174,6 +175,7 @@ public final class ListListener {
174 YangList yangList = (YangList) listener.getParsedDataStack().peek(); 175 YangList yangList = (YangList) listener.getParsedDataStack().peek();
175 try { 176 try {
176 yangList.validateDataOnExit(); 177 yangList.validateDataOnExit();
178 + validateUniqueInList(yangList, ctx);
177 } catch (DataModelException e) { 179 } catch (DataModelException e) {
178 throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA, 180 throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
179 LIST_DATA, ctx.identifier().getText(), EXIT, e.getMessage())); 181 LIST_DATA, ctx.identifier().getText(), EXIT, e.getMessage()));
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.onosproject.yangutils.datamodel.YangList;
20 +import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
21 +import org.onosproject.yangutils.datamodel.utils.Parsable;
22 +import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
23 +import org.onosproject.yangutils.parser.exceptions.ParserException;
24 +import org.onosproject.yangutils.parser.impl.TreeWalkListener;
25 +
26 +import static org.onosproject.yangutils.datamodel.utils.YangConstructType.UNIQUE_DATA;
27 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
28 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
29 + .constructExtendedListenerErrorMessage;
30 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction
31 + .constructListenerErrorMessage;
32 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
33 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
34 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
35 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
36 +import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
37 +
38 +/*
39 + * Reference: RFC6020 and YANG ANTLR Grammar
40 + *
41 + * ABNF grammar as per RFC6020
42 + * unique-stmt = unique-keyword sep unique-arg-str stmtend
43 + *
44 + * ANTLR grammar rule
45 + * uniqueStatement: UNIQUE_KEYWORD unique STMTEND;
46 + * unique : string;
47 + */
48 +
49 +/**
50 + * Represesnts listener based call back function corresponding to the "unique" rule
51 + * defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
52 + */
53 +public final class UniqueListener {
54 +
55 + /**
56 + * Creates a new unique listener.
57 + */
58 + private UniqueListener() {
59 + }
60 +
61 + /**
62 + * It is called when parser receives an input matching the grammar rule
63 + * (unique), perform validations and updates the data model tree.
64 + *
65 + * @param listener listener's object
66 + * @param ctx context object of the grammar rule
67 + */
68 + public static void processUniqueEntry(TreeWalkListener listener,
69 + GeneratedYangParser.UniqueStatementContext ctx) {
70 +
71 + // Check for stack to be non empty.
72 + checkStackIsNotEmpty(listener, MISSING_HOLDER, UNIQUE_DATA, ctx.unique().getText(), ENTRY);
73 +
74 + Parsable tmpData = listener.getParsedDataStack().peek();
75 + if (listener.getParsedDataStack().peek() instanceof YangList) {
76 + YangList yangList = (YangList) tmpData;
77 + String tmpUniqueValue = removeQuotesAndHandleConcat(ctx.unique().getText());
78 +
79 + if (tmpUniqueValue.contains(" ")) {
80 + String[] uniqueValues = tmpUniqueValue.split(" ");
81 + for (String uniqueValue : uniqueValues) {
82 + try {
83 + yangList.addUnique(uniqueValue);
84 + } catch (DataModelException e) {
85 + throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
86 + UNIQUE_DATA,
87 + ctx.unique().getText(), ENTRY, e.getMessage()));
88 + }
89 + }
90 + } else {
91 + try {
92 + yangList.addUnique(tmpUniqueValue);
93 + } catch (DataModelException e) {
94 + throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA, UNIQUE_DATA,
95 + ctx.unique().getText(), ENTRY, e.getMessage()));
96 + }
97 + }
98 + } else {
99 + throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, UNIQUE_DATA, ctx.unique().getText(),
100 + ENTRY));
101 + }
102 + }
103 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -137,6 +137,7 @@ public final class UsesListener { ...@@ -137,6 +137,7 @@ public final class UsesListener {
137 YangUses usesNode = getYangUsesNode(JAVA_GENERATION); 137 YangUses usesNode = getYangUsesNode(JAVA_GENERATION);
138 YangNodeIdentifier nodeIdentifier = getValidNodeIdentifier(ctx.string().getText(), USES_DATA, ctx); 138 YangNodeIdentifier nodeIdentifier = getValidNodeIdentifier(ctx.string().getText(), USES_DATA, ctx);
139 usesNode.setNodeIdentifier(nodeIdentifier); 139 usesNode.setNodeIdentifier(nodeIdentifier);
140 + usesNode.setCurrentGroupingDepth(listener.getGroupingDepth());
140 YangNode curNode = (YangNode) curData; 141 YangNode curNode = (YangNode) curData;
141 142
142 try { 143 try {
......
...@@ -444,33 +444,6 @@ public class ConfigListenerTest { ...@@ -444,33 +444,6 @@ public class ConfigListenerTest {
444 * config statement's value. 444 * config statement's value.
445 */ 445 */
446 @Test 446 @Test
447 - public void processNoConfigListSubStatementLeafList() throws IOException, ParserException {
448 -
449 - YangNode node = manager.getDataModel("src/test/resources/NoConfigListSubStatementLeafList.yang");
450 -
451 - assertThat((node instanceof YangModule), is(true));
452 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
453 - YangModule yangNode = (YangModule) node;
454 - assertThat(yangNode.getName(), is("Test"));
455 -
456 - // Check whether the config value is set correctly.
457 - YangList list1 = (YangList) yangNode.getChild();
458 - assertThat(list1.getName(), is("valid"));
459 - assertThat(list1.isConfig(), is(true));
460 -
461 - ListIterator<YangLeafList> leafListIterator = list1.getListOfLeafList().listIterator();
462 - YangLeafList leafListInfo = leafListIterator.next();
463 -
464 - // Check whether config value is set correctly.
465 - assertThat(leafListInfo.getName(), is("invalid-interval"));
466 - assertThat(leafListInfo.isConfig(), is(true));
467 - }
468 -
469 - /**
470 - * Checks when config is not specified, the default is same as the parent's schema node's
471 - * config statement's value.
472 - */
473 - @Test
474 public void processNoConfigListSubStatementLeaf() throws IOException, ParserException { 447 public void processNoConfigListSubStatementLeaf() throws IOException, ParserException {
475 448
476 YangNode node = manager.getDataModel("src/test/resources/NoConfigListSubStatementLeaf.yang"); 449 YangNode node = manager.getDataModel("src/test/resources/NoConfigListSubStatementLeaf.yang");
......
...@@ -143,26 +143,6 @@ public class KeyListenerTest { ...@@ -143,26 +143,6 @@ public class KeyListenerTest {
143 } 143 }
144 144
145 /** 145 /**
146 - * Checks key values are set correctly.
147 - */
148 - @Test
149 - public void processConfigFalseValidKeyValidLeafList() throws IOException, ParserException {
150 - YangNode node = manager.getDataModel("src/test/resources/ConfigFalseValidKeyValidLeafList.yang");
151 -
152 - assertThat((node instanceof YangModule), is(true));
153 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
154 - YangModule yangNode = (YangModule) node;
155 - assertThat(yangNode.getName(), is("Test"));
156 -
157 - // Check whether the list is child of module
158 - YangList yangList = (YangList) yangNode.getChild();
159 - assertThat(yangList.getName(), is("valid"));
160 -
161 - ListIterator<String> keyList = yangList.getKeyList().listIterator();
162 - assertThat(keyList.next(), is("invalid-interval"));
163 - }
164 -
165 - /**
166 * Checks whether exception is thrown when list's config is set to true and there is no key. 146 * Checks whether exception is thrown when list's config is set to true and there is no key.
167 */ 147 */
168 @Test 148 @Test
...@@ -233,26 +213,6 @@ public class KeyListenerTest { ...@@ -233,26 +213,6 @@ public class KeyListenerTest {
233 } 213 }
234 214
235 /** 215 /**
236 - * Checks whether exception is thrown when key leaf-list identifier is not found in list.
237 - */
238 - @Test
239 - public void processInvalidLeafListIdentifier() throws IOException, ParserException {
240 - thrown.expect(ParserException.class);
241 - thrown.expectMessage("An identifier, in key, must refer to a child leaf of the list");
242 - YangNode node = manager.getDataModel("src/test/resources/InvalidLeafListIdentifier.yang");
243 - }
244 -
245 - /**
246 - * Checks whether exception is thrown when key leaf-list is of type empty.
247 - */
248 - @Test
249 - public void processKeyLeafListTypeEmpty() throws IOException, ParserException {
250 - thrown.expect(ParserException.class);
251 - thrown.expectMessage("A leaf-list that is part of the key must not be the built-in type \"empty\".");
252 - YangNode node = manager.getDataModel("src/test/resources/KeyLeafListTypeEmpty.yang");
253 - }
254 -
255 - /**
256 * Checks whether exception is thrown when key leaf is of type empty. 216 * Checks whether exception is thrown when key leaf is of type empty.
257 */ 217 */
258 @Test 218 @Test
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +import org.junit.rules.ExpectedException;
22 +import org.onosproject.yangutils.datamodel.YangList;
23 +import org.onosproject.yangutils.datamodel.YangModule;
24 +import org.onosproject.yangutils.datamodel.YangNode;
25 +import org.onosproject.yangutils.datamodel.YangNodeType;
26 +import org.onosproject.yangutils.parser.exceptions.ParserException;
27 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
28 +
29 +import java.io.IOException;
30 +import java.util.ListIterator;
31 +
32 +import static org.hamcrest.MatcherAssert.assertThat;
33 +import static org.hamcrest.core.Is.is;
34 +
35 +/**
36 + * Test cases for unique listener.
37 + */
38 +public class UniqueListenerTest {
39 +
40 + @Rule
41 + public ExpectedException thrown = ExpectedException.none();
42 +
43 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
44 +
45 + /**
46 + * Checks unique statement as sub-statement of list.
47 + */
48 + @Test
49 + public void processListSubStatementUnique() throws IOException, ParserException {
50 +
51 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementUnique.yang");
52 +
53 + assertThat((node instanceof YangModule), is(true));
54 +
55 + // Check whether the node type is set properly to module.
56 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
57 +
58 + // Check whether the module name is set correctly.
59 + YangModule yangNode = (YangModule) node;
60 + assertThat(yangNode.getName(), is("Test"));
61 +
62 + // Check whether the list is child of module
63 + YangList yangList = (YangList) yangNode.getChild();
64 + assertThat(yangList.getName(), is("valid"));
65 + assertThat(yangList.getUniqueList().listIterator().next(), is("invalid-interval"));
66 + }
67 +
68 + /**
69 + * Check multiple unique values.
70 + */
71 + @Test
72 + public void processMultipleUniqueValues() throws IOException, ParserException {
73 +
74 + YangNode node = manager.getDataModel("src/test/resources/MultipleUniqueValues.yang");
75 +
76 + assertThat((node instanceof YangModule), is(true));
77 +
78 + // Check whether the node type is set properly to module.
79 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
80 +
81 + // Check whether the module name is set correctly.
82 + YangModule yangNode = (YangModule) node;
83 + assertThat(yangNode.getName(), is("Test"));
84 +
85 + // Check whether the list is child of module
86 + YangList yangList = (YangList) yangNode.getChild();
87 + assertThat(yangList.getName(), is("valid"));
88 + ListIterator<String> listIterator;
89 + String list;
90 + listIterator = yangList.getUniqueList().listIterator();
91 + list = listIterator.next();
92 + assertThat(list, is("ospf"));
93 + list = listIterator.next();
94 + assertThat(list, is("isis"));
95 + }
96 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -16,17 +16,11 @@ ...@@ -16,17 +16,11 @@
16 16
17 package org.onosproject.yangutils.plugin.manager; 17 package org.onosproject.yangutils.plugin.manager;
18 18
19 -import java.io.IOException;
20 -import java.util.List;
21 -import java.util.ListIterator;
22 -
23 import org.junit.Test; 19 import org.junit.Test;
24 import org.onosproject.yangutils.datamodel.YangContainer; 20 import org.onosproject.yangutils.datamodel.YangContainer;
25 -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
26 import org.onosproject.yangutils.datamodel.YangFeature; 21 import org.onosproject.yangutils.datamodel.YangFeature;
27 import org.onosproject.yangutils.datamodel.YangIfFeature; 22 import org.onosproject.yangutils.datamodel.YangIfFeature;
28 import org.onosproject.yangutils.datamodel.YangLeaf; 23 import org.onosproject.yangutils.datamodel.YangLeaf;
29 -import org.onosproject.yangutils.datamodel.YangLeafRef;
30 import org.onosproject.yangutils.datamodel.YangModule; 24 import org.onosproject.yangutils.datamodel.YangModule;
31 import org.onosproject.yangutils.datamodel.YangNode; 25 import org.onosproject.yangutils.datamodel.YangNode;
32 import org.onosproject.yangutils.datamodel.YangNodeType; 26 import org.onosproject.yangutils.datamodel.YangNodeType;
...@@ -35,6 +29,9 @@ import org.onosproject.yangutils.datamodel.utils.ResolvableStatus; ...@@ -35,6 +29,9 @@ import org.onosproject.yangutils.datamodel.utils.ResolvableStatus;
35 import org.onosproject.yangutils.parser.exceptions.ParserException; 29 import org.onosproject.yangutils.parser.exceptions.ParserException;
36 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 30 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
37 31
32 +import java.io.IOException;
33 +import java.util.List;
34 +
38 import static org.hamcrest.MatcherAssert.assertThat; 35 import static org.hamcrest.MatcherAssert.assertThat;
39 import static org.hamcrest.core.Is.is; 36 import static org.hamcrest.core.Is.is;
40 37
...@@ -221,111 +218,4 @@ public class IntraFileIfFeatureLinkingTest { ...@@ -221,111 +218,4 @@ public class IntraFileIfFeatureLinkingTest {
221 assertThat(ifFeature.getName().getName(), is("local-storage")); 218 assertThat(ifFeature.getName().getName(), is("local-storage"));
222 assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.RESOLVED)); 219 assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
223 } 220 }
224 -
225 - /**
226 - * Checks addition of if-feature list to leafref.
227 - */
228 - @Test
229 - public void processSelfFileLinkingWithFeatureReferredByLeafref()
230 - throws IOException, ParserException {
231 -
232 - YangNode node = manager
233 - .getDataModel("src/test/resources/SelfFileLinkingWithFeatureReferredByLeafref.yang");
234 -
235 - // Check whether the data model tree returned is of type module.
236 - assertThat((node instanceof YangModule), is(true));
237 -
238 - // Check whether the node type is set properly to module.
239 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
240 -
241 - // Check whether the module name is set correctly.
242 - YangModule yangNode = (YangModule) node;
243 - assertThat(yangNode.getName(), is("syslog"));
244 -
245 - List<YangFeature> featureList = yangNode.getFeatureList();
246 - YangFeature feature = featureList.iterator().next();
247 - assertThat(feature.getName(), is("local-storage"));
248 -
249 - YangContainer container = (YangContainer) yangNode.getChild();
250 - assertThat(container.getName(), is("speed"));
251 -
252 - List<YangLeaf> listOfLeaf = container.getListOfLeaf();
253 - YangLeaf leaf = listOfLeaf.iterator().next();
254 - assertThat(leaf.getName(), is("local-storage-limit"));
255 -
256 - List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
257 - YangIfFeature ifFeature = ifFeatureList.iterator().next();
258 - assertThat(ifFeature.getName().getName(), is("local-storage"));
259 - assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
260 -
261 - ListIterator<YangLeaf> listOfLeafInModule = yangNode.getListOfLeaf().listIterator();
262 - YangLeaf yangLeaf = listOfLeafInModule.next();
263 - assertThat(yangLeaf.getName(), is("storage-value"));
264 -
265 - YangLeafRef leafRef = (YangLeafRef) yangLeaf.getDataType().getDataTypeExtendedInfo();
266 -
267 - assertThat(leafRef.getEffectiveDataType().getDataType(), is(YangDataTypes.UINT64));
268 -
269 - List<YangIfFeature> ifFeatureListInLeafref = leafRef.getIfFeatureList();
270 - YangIfFeature ifFeatureInLeafref = ifFeatureListInLeafref.iterator().next();
271 - assertThat(ifFeatureInLeafref.getName().getName(), is("local-storage"));
272 - assertThat(ifFeatureInLeafref.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
273 - }
274 -
275 - /**
276 - * Checks addition of if-feature list to leafref when referred leaf is again having leafref in it.
277 - */
278 - @Test
279 - public void processSelfFileLinkingWithFeatureReferredByMultiLeafref()
280 - throws IOException, ParserException {
281 -
282 - YangNode node = manager
283 - .getDataModel("src/test/resources/SelfFileLinkingWithFeatureReferredByMultiLeafref.yang");
284 -
285 - // Check whether the data model tree returned is of type module.
286 - assertThat((node instanceof YangModule), is(true));
287 -
288 - // Check whether the node type is set properly to module.
289 - assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
290 -
291 - // Check whether the module name is set correctly.
292 - YangModule yangNode = (YangModule) node;
293 - assertThat(yangNode.getName(), is("syslog"));
294 -
295 - List<YangFeature> featureList = yangNode.getFeatureList();
296 - YangFeature feature = featureList.iterator().next();
297 - assertThat(feature.getName(), is("local-storage"));
298 -
299 - YangContainer container = (YangContainer) yangNode.getChild();
300 - assertThat(container.getName(), is("speed"));
301 -
302 - List<YangLeaf> listOfLeaf = container.getListOfLeaf();
303 - YangLeaf leaf = listOfLeaf.iterator().next();
304 - assertThat(leaf.getName(), is("local-storage-limit"));
305 -
306 - List<YangIfFeature> ifFeatureList = leaf.getIfFeatureList();
307 - YangIfFeature ifFeature = ifFeatureList.iterator().next();
308 - assertThat(ifFeature.getName().getName(), is("local-storage"));
309 - assertThat(ifFeature.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
310 -
311 - ListIterator<YangLeaf> listOfLeafInModule = yangNode.getListOfLeaf().listIterator();
312 - YangLeaf yangLeaf = listOfLeafInModule.next();
313 - assertThat(yangLeaf.getName(), is("storage-value"));
314 -
315 - YangLeafRef leafRef = (YangLeafRef) yangLeaf.getDataType().getDataTypeExtendedInfo();
316 -
317 - assertThat(leafRef.getEffectiveDataType().getDataType(), is(YangDataTypes.UINT64));
318 -
319 - List<YangIfFeature> ifFeatureListInLeafref = leafRef.getIfFeatureList();
320 - YangIfFeature ifFeatureInLeafref = ifFeatureListInLeafref.iterator().next();
321 -
322 - assertThat(ifFeatureInLeafref.getName().getName(), is("main-storage"));
323 - assertThat(ifFeatureInLeafref.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
324 -
325 - YangIfFeature ifFeatureInLeafref1 = ifFeatureListInLeafref.iterator().next();
326 -
327 - assertThat(ifFeatureInLeafref1.getName().getName(), is("main-storage"));
328 - assertThat(ifFeatureInLeafref1.getResolvableStatus(), is(ResolvableStatus.RESOLVED));
329 -
330 - }
331 } 221 }
......
1 -module Test {
2 - yang-version 1;
3 - namespace http://huawei.com;
4 - prefix Ant;
5 - list valid {
6 - key "invalid-interval";
7 - leaf-list invalid {
8 - type "string";
9 - units "seconds";
10 - status current;
11 - reference "RFC 6020";
12 - }
13 - }
14 -}
...\ No newline at end of file ...\ No newline at end of file
1 -module Test {
2 - yang-version 1;
3 - namespace http://huawei.com;
4 - prefix Ant;
5 - list valid {
6 - key "invalid-interval";
7 - leaf-list invalid-interval {
8 - type "empty";
9 - units "seconds";
10 - status current;
11 - reference "RFC 6020";
12 - }
13 - }
14 -}
...\ No newline at end of file ...\ No newline at end of file
...@@ -4,7 +4,7 @@ module Test { ...@@ -4,7 +4,7 @@ module Test {
4 namespace http://huawei.com; 4 namespace http://huawei.com;
5 prefix Ant; 5 prefix Ant;
6 list valid { 6 list valid {
7 - key "invalid-interval"; 7 + key "invalid";
8 leaf-list invalid-interval { 8 leaf-list invalid-interval {
9 type "uint16"; 9 type "uint16";
10 units "seconds"; 10 units "seconds";
...@@ -13,5 +13,8 @@ module Test { ...@@ -13,5 +13,8 @@ module Test {
13 status current; 13 status current;
14 reference "RFC 6020"; 14 reference "RFC 6020";
15 } 15 }
16 + leaf invalid {
17 + type "uint16";
18 + }
16 } 19 }
17 } 20 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,12 +3,15 @@ module Test { ...@@ -3,12 +3,15 @@ module Test {
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 list valid { 5 list valid {
6 - key "invalid-interval"; 6 + key "invalid";
7 max-elements 3; 7 max-elements 3;
8 leaf-list invalid-interval { 8 leaf-list invalid-interval {
9 type "uint16"; 9 type "uint16";
10 units "seconds"; 10 units "seconds";
11 description "Interval before a route is declared invalid"; 11 description "Interval before a route is declared invalid";
12 } 12 }
13 + leaf invalid {
14 + type "uint16";
15 + }
13 } 16 }
14 } 17 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,12 +3,15 @@ module Test { ...@@ -3,12 +3,15 @@ module Test {
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 list valid { 5 list valid {
6 - key "invalid-interval"; 6 + key "invalid";
7 min-elements 3; 7 min-elements 3;
8 leaf-list invalid-interval { 8 leaf-list invalid-interval {
9 type "uint16"; 9 type "uint16";
10 units "seconds"; 10 units "seconds";
11 description "Interval before a route is declared invalid"; 11 description "Interval before a route is declared invalid";
12 } 12 }
13 + leaf invalid {
14 + type "uint16";
15 + }
13 } 16 }
14 } 17 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,12 +3,13 @@ module Test { ...@@ -3,12 +3,13 @@ module Test {
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 list valid { 5 list valid {
6 + unique "invalid-interval";
6 key "invalid-interval"; 7 key "invalid-interval";
7 - leaf-list invalid-interval { 8 + leaf invalid-interval {
8 type "uint16"; 9 type "uint16";
9 units "seconds"; 10 units "seconds";
10 status current; 11 status current;
11 reference "RFC 6020"; 12 reference "RFC 6020";
12 } 13 }
13 } 14 }
14 -}
...\ No newline at end of file ...\ No newline at end of file
15 +}
......
...@@ -3,9 +3,16 @@ module Test { ...@@ -3,9 +3,16 @@ module Test {
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 list valid { 5 list valid {
6 - key "invalid-interval"; 6 + key "ospf";
7 - leaf-list invalid-interval { 7 + unique "ospf isis";
8 - type "string"; 8 + leaf ospf {
9 + type "uint16";
10 + units "seconds";
11 + status current;
12 + reference "RFC 6020";
13 + }
14 + leaf isis {
15 + type "uint16";
9 units "seconds"; 16 units "seconds";
10 status current; 17 status current;
11 reference "RFC 6020"; 18 reference "RFC 6020";
......
...@@ -3,7 +3,7 @@ module Test { ...@@ -3,7 +3,7 @@ module Test {
3 namespace http://huawei.com; 3 namespace http://huawei.com;
4 prefix Ant; 4 prefix Ant;
5 list valid { 5 list valid {
6 - key "invalid-interval"; 6 + key "invalid";
7 leaf-list invalid-interval { 7 leaf-list invalid-interval {
8 type union { 8 type union {
9 type int32; 9 type int32;
...@@ -12,5 +12,8 @@ module Test { ...@@ -12,5 +12,8 @@ module Test {
12 } 12 }
13 } 13 }
14 } 14 }
15 + leaf invalid {
16 + type string;
17 + }
15 } 18 }
16 } 19 }
......
1 -module ietf-network {
2 - yang-version 1;
3 - namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 - prefix nd;
5 - container networks {
6 - description
7 - "Serves as top-level container for a list of networks.";
8 - leaf network-id {
9 - type uint8;
10 - description
11 - "Identifies a network.";
12 - }
13 - }
14 - leaf network-ref {
15 - type leafref {
16 - path "/define/network-id";
17 - }
18 - }
19 -}
...\ No newline at end of file ...\ No newline at end of file
...@@ -103,7 +103,11 @@ ...@@ -103,7 +103,11 @@
103 description 103 description
104 "References a link in a specific network."; 104 "References a link in a specific network.";
105 leaf link-ref { 105 leaf link-ref {
106 - type link-id; 106 + type leafref {
107 + path "/nd:networks/nd:network[nd:network-id=current()/../"+
108 + "network-ref]/lnk:link/lnk:link-id";
109 + require-instance false;
110 + }
107 description 111 description
108 "A type for an absolute reference a link instance. 112 "A type for an absolute reference a link instance.
109 (This type should not be used for relative references. 113 (This type should not be used for relative references.
...@@ -116,7 +120,12 @@ ...@@ -116,7 +120,12 @@
116 description 120 description
117 "References a termination point in a specific node."; 121 "References a termination point in a specific node.";
118 leaf tp-ref { 122 leaf tp-ref {
119 - type tp-id; 123 + type leafref {
124 + path "/nd:networks/nd:network[nd:network-id=current()/../"+
125 + "network-ref]/nd:node[nd:node-id=current()/../"+
126 + "node-ref]/lnk:termination-point/lnk:tp-id";
127 + require-instance false;
128 + }
120 description 129 description
121 "A type for an absolute reference to a termination point. 130 "A type for an absolute reference to a termination point.
122 (This type should not be used for relative references. 131 (This type should not be used for relative references.
...@@ -150,13 +159,18 @@ ...@@ -150,13 +159,18 @@
150 "This container holds the logical source of a particular 159 "This container holds the logical source of a particular
151 link."; 160 link.";
152 leaf source-node { 161 leaf source-node {
153 - type nd:node-id; 162 + type leafref {
163 + path "../../../nd:node/nd:node-id";
164 + }
154 mandatory true; 165 mandatory true;
155 description 166 description
156 "Source node identifier, must be in same topology."; 167 "Source node identifier, must be in same topology.";
157 } 168 }
158 leaf source-tp { 169 leaf source-tp {
159 - type tp-id; 170 + type leafref {
171 + path "../../../nd:node[nd:node-id=current()/../"+
172 + "source-node]/termination-point/tp-id";
173 + }
160 description 174 description
161 "Termination point within source node that terminates 175 "Termination point within source node that terminates
162 the link."; 176 the link.";
...@@ -167,14 +181,19 @@ ...@@ -167,14 +181,19 @@
167 "This container holds the logical destination of a 181 "This container holds the logical destination of a
168 particular link."; 182 particular link.";
169 leaf dest-node { 183 leaf dest-node {
170 - type nd:node-id; 184 + type leafref {
185 + path "../../../nd:node/nd:node-id";
186 + }
171 mandatory true; 187 mandatory true;
172 description 188 description
173 "Destination node identifier, must be in the same 189 "Destination node identifier, must be in the same
174 network."; 190 network.";
175 } 191 }
176 leaf dest-tp { 192 leaf dest-tp {
177 - type tp-id; 193 + type leafref {
194 + path "../../../nd:node[nd:node-id=current()/../"+
195 + "dest-node]/termination-point/tp-id";
196 + }
178 description 197 description
179 "Termination point within destination node that 198 "Termination point within destination node that
180 terminates the link."; 199 terminates the link.";
...@@ -192,13 +211,20 @@ ...@@ -192,13 +211,20 @@
192 "Identifies the link, or links, that this link 211 "Identifies the link, or links, that this link
193 is dependent on."; 212 is dependent on.";
194 leaf network-ref { 213 leaf network-ref {
195 - type nd:network-id; 214 + type leafref {
215 + path "../../../nd:supporting-network/nd:network-ref";
216 + require-instance false;
217 + }
196 description 218 description
197 "This leaf identifies in which underlay topology 219 "This leaf identifies in which underlay topology
198 supporting link is present."; 220 supporting link is present.";
199 } 221 }
200 leaf link-ref { 222 leaf link-ref {
201 - type link-id; 223 + type leafref {
224 + path "/nd:networks/nd:network[nd:network-id=current()/"+
225 + "../network-ref]/link/link-id";
226 + require-instance false;
227 + }
202 description 228 description
203 "This leaf identifies a link which is a part 229 "This leaf identifies a link which is a part
204 of this link's underlay. Reference loops, in which 230 of this link's underlay. Reference loops, in which
...@@ -237,19 +263,30 @@ ...@@ -237,19 +263,30 @@
237 The corresponding information is simply provided by the 263 The corresponding information is simply provided by the
238 implementing system."; 264 implementing system.";
239 leaf network-ref { 265 leaf network-ref {
240 - type nd:network-id; 266 + type leafref {
267 + path "../../../nd:supporting-node/nd:network-ref";
268 + require-instance false;
269 + }
241 description 270 description
242 "This leaf identifies in which topology the 271 "This leaf identifies in which topology the
243 supporting termination point is present."; 272 supporting termination point is present.";
244 } 273 }
245 leaf node-ref { 274 leaf node-ref {
246 - type nd:node-id; 275 + type leafref {
276 + path "../../../nd:supporting-node/nd:node-ref";
277 + require-instance false;
278 + }
247 description 279 description
248 "This leaf identifies in which node the supporting 280 "This leaf identifies in which node the supporting
249 termination point is present."; 281 termination point is present.";
250 } 282 }
251 leaf tp-ref { 283 leaf tp-ref {
252 - type tp-id; 284 + type leafref {
285 + path "/nd:networks/nd:network[nd:network-id=current()/"+
286 + "../network-ref]/nd:node[nd:node-id=current()/../"+
287 + "node-ref]/termination-point/tp-id";
288 + require-instance false;
289 + }
253 description 290 description
254 "Reference to the underlay node, must be in a 291 "Reference to the underlay node, must be in a
255 different topology"; 292 different topology";
......
...@@ -87,7 +87,10 @@ ...@@ -87,7 +87,10 @@
87 "Contains the information necessary to reference a network, 87 "Contains the information necessary to reference a network,
88 for example an underlay network."; 88 for example an underlay network.";
89 leaf network-ref { 89 leaf network-ref {
90 - type network-id; 90 + type leafref {
91 + path "/nd:networks/nd:network/nd:network-id";
92 + require-instance false;
93 + }
91 description 94 description
92 "Used to reference a network, for example an underlay 95 "Used to reference a network, for example an underlay
93 network."; 96 network.";
...@@ -98,7 +101,11 @@ ...@@ -98,7 +101,11 @@
98 description 101 description
99 "Contains the information necessary to reference a node."; 102 "Contains the information necessary to reference a node.";
100 leaf node-ref { 103 leaf node-ref {
101 - type node-id; 104 + type leafref {
105 + path "/nd:networks/nd:network[nd:network-id=current()/../"+
106 + "network-ref]/nd:node/nd:node-id";
107 + require-instance false;
108 + }
102 description 109 description
103 "Used to reference a node. 110 "Used to reference a node.
104 Nodes are identified relative to the network they are 111 Nodes are identified relative to the network they are
...@@ -135,7 +142,10 @@ ...@@ -135,7 +142,10 @@
135 "An underlay network, used to represent layered network 142 "An underlay network, used to represent layered network
136 topologies."; 143 topologies.";
137 leaf network-ref { 144 leaf network-ref {
138 - type network-id; 145 + type leafref {
146 + path "/networks/network/network-id";
147 + require-instance false;
148 + }
139 description 149 description
140 "References the underlay network."; 150 "References the underlay network.";
141 } 151 }
...@@ -157,13 +167,19 @@ ...@@ -157,13 +167,19 @@
157 this node is supported by. Used to represent layering 167 this node is supported by. Used to represent layering
158 structure."; 168 structure.";
159 leaf network-ref { 169 leaf network-ref {
160 - type network-id; 170 + type leafref {
171 + path "../../../supporting-network/network-ref";
172 + require-instance false;
173 + }
161 description 174 description
162 "References the underlay network that the 175 "References the underlay network that the
163 underlay node is part of."; 176 underlay node is part of.";
164 } 177 }
165 leaf node-ref { 178 leaf node-ref {
166 - type node-id; 179 + type leafref {
180 + path "/networks/network/node/node-id";
181 + require-instance false;
182 + }
167 description 183 description
168 "References the underlay node itself."; 184 "References the underlay node itself.";
169 } 185 }
......
...@@ -515,14 +515,14 @@ ...@@ -515,14 +515,14 @@
515 "A container controlling performance metric throttle."; 515 "A container controlling performance metric throttle.";
516 container performance-metric-throttle { 516 container performance-metric-throttle {
517 if-feature te-performance-metric; 517 if-feature te-performance-metric;
518 - /*must "suppression-interval >= measure-interval" { 518 + must "suppression-interval >= measure-interval" {
519 error-message 519 error-message
520 "suppression-interval cannot be less then 520 "suppression-interval cannot be less then
521 measure-interval."; 521 measure-interval.";
522 description 522 description
523 "Constraint on suppression-interval and 523 "Constraint on suppression-interval and
524 measure-interval."; 524 measure-interval.";
525 - }*/ 525 + }
526 description 526 description
527 "Link performance information in real time."; 527 "Link performance information in real time.";
528 reference 528 reference
...@@ -549,7 +549,7 @@ ...@@ -549,7 +549,7 @@
549 } 549 }
550 leaf suppression-interval { 550 leaf suppression-interval {
551 type uint32 { 551 type uint32 {
552 - range "1..max"; 552 + range "1 .. max";
553 } 553 }
554 default 120; 554 default 120;
555 description 555 description
...@@ -633,13 +633,25 @@ ...@@ -633,13 +633,25 @@
633 "Identify the sequence in the bundle."; 633 "Identify the sequence in the bundle.";
634 } 634 }
635 leaf src-tp-ref { 635 leaf src-tp-ref {
636 - type nt:tp-id; 636 + type leafref {
637 + path "../../../../../../nw:node[nw:node-id = "
638 + + "current()/../../../../../nt:source/"
639 + + "nt:source-node]/"
640 + + "nt:termination-point/nt:tp-id";
641 + require-instance true;
642 + }
637 description 643 description
638 "Reference to another TE termination point on the 644 "Reference to another TE termination point on the
639 same souruce node."; 645 same souruce node.";
640 } 646 }
641 leaf des-tp-ref { 647 leaf des-tp-ref {
642 - type nt:tp-id; 648 + type leafref {
649 + path "../../../../../../nw:node[nw:node-id = "
650 + + "current()/../../../../../nt:destination/"
651 + + "nt:dest-node]/"
652 + + "nt:termination-point/nt:tp-id";
653 + require-instance true;
654 + }
643 description 655 description
644 "Reference to another TE termination point on the 656 "Reference to another TE termination point on the
645 same destination node."; 657 same destination node.";
...@@ -682,7 +694,9 @@ ...@@ -682,7 +694,9 @@
682 694
683 leaf-list te-link-template { 695 leaf-list te-link-template {
684 if-feature template; 696 if-feature template;
685 - type te-template-name; 697 + type leafref {
698 + path "../../../../../te/templates/link-template/name";
699 + }
686 description 700 description
687 "The reference to a TE link template."; 701 "The reference to a TE link template.";
688 } 702 }
...@@ -862,12 +876,16 @@ ...@@ -862,12 +876,16 @@
862 RFC4203: OSPF Extensions in Support of Generalized 876 RFC4203: OSPF Extensions in Support of Generalized
863 Multi-Protocol Label Switching (GMPLS)."; 877 Multi-Protocol Label Switching (GMPLS).";
864 leaf switching-capability { 878 leaf switching-capability {
865 - type string; 879 + type identityref {
880 + base te-types:switching-capabilities;
881 + }
866 description 882 description
867 "Switching Capability for this interface."; 883 "Switching Capability for this interface.";
868 } 884 }
869 leaf encoding { 885 leaf encoding {
870 - type string; 886 + type identityref {
887 + base te-types:lsp-encoding-types;
888 + }
871 description 889 description
872 "Encoding supported by this interface."; 890 "Encoding supported by this interface.";
873 } 891 }
...@@ -929,12 +947,16 @@ ...@@ -929,12 +947,16 @@
929 "RFC6001: Generalized MPLS (GMPLS) Protocol Extensions 947 "RFC6001: Generalized MPLS (GMPLS) Protocol Extensions
930 for Multi-Layer and Multi-Region Networks (MLN/MRN)."; 948 for Multi-Layer and Multi-Region Networks (MLN/MRN).";
931 leaf upper-sc { 949 leaf upper-sc {
932 - type string; 950 + type identityref {
951 + base te-types:switching-capabilities;
952 + }
933 description 953 description
934 "Switching Capability for this interface."; 954 "Switching Capability for this interface.";
935 } 955 }
936 leaf upper-encoding { 956 leaf upper-encoding {
937 - type string; 957 + type identityref {
958 + base te-types:lsp-encoding-types;
959 + }
938 description 960 description
939 "Encoding supported by this interface."; 961 "Encoding supported by this interface.";
940 } 962 }
...@@ -1140,13 +1162,17 @@ ...@@ -1140,13 +1162,17 @@
1140 1162
1141 uses te-node-tunnel-termination-capability; 1163 uses te-node-tunnel-termination-capability;
1142 leaf switching-capability { 1164 leaf switching-capability {
1143 - type string; 1165 + type identityref {
1166 + base te-types:switching-capabilities;
1167 + }
1144 mandatory true; 1168 mandatory true;
1145 description 1169 description
1146 "Switching Capability."; 1170 "Switching Capability.";
1147 } 1171 }
1148 leaf encoding { 1172 leaf encoding {
1149 - type string; 1173 + type identityref {
1174 + base te-types:lsp-encoding-types;
1175 + }
1150 mandatory true; 1176 mandatory true;
1151 description 1177 description
1152 "Encoding type."; 1178 "Encoding type.";
...@@ -1162,7 +1188,9 @@ ...@@ -1162,7 +1188,9 @@
1162 1188
1163 leaf-list te-node-template { 1189 leaf-list te-node-template {
1164 if-feature template; 1190 if-feature template;
1165 - type te-template-name; 1191 + type leafref {
1192 + path "../../../../../te/templates/node-template/name";
1193 + }
1166 description 1194 description
1167 "The reference to a TE node template."; 1195 "The reference to a TE node template.";
1168 } 1196 }
...@@ -1231,7 +1259,9 @@ ...@@ -1231,7 +1259,9 @@
1231 } 1259 }
1232 container from { 1260 container from {
1233 leaf tp-ref { 1261 leaf tp-ref {
1234 - type nt:tp-id; 1262 + type leafref {
1263 + path "../../../../../../nt:termination-point/nt:tp-id";
1264 + }
1235 description 1265 description
1236 "Relative reference to source termination point."; 1266 "Relative reference to source termination point.";
1237 } 1267 }
...@@ -1240,7 +1270,9 @@ ...@@ -1240,7 +1270,9 @@
1240 } 1270 }
1241 container to { 1271 container to {
1242 leaf tp-ref { 1272 leaf tp-ref {
1243 - type nt:tp-id; 1273 + type leafref {
1274 + path "../../../../../../nt:termination-point/nt:tp-id";
1275 + }
1244 description 1276 description
1245 "Relative reference to destination termination point."; 1277 "Relative reference to destination termination point.";
1246 } 1278 }
...@@ -1402,7 +1434,9 @@ ...@@ -1402,7 +1434,9 @@
1402 The capability information can be used to compute 1434 The capability information can be used to compute
1403 the tunnel path."; 1435 the tunnel path.";
1404 leaf link-tp { 1436 leaf link-tp {
1405 - type nt:tp-id; 1437 + type leafref {
1438 + path "../../../../../nt:termination-point/nt:tp-id";
1439 + }
1406 description 1440 description
1407 "Link termination point."; 1441 "Link termination point.";
1408 } 1442 }
...@@ -1562,22 +1596,37 @@ ...@@ -1562,22 +1596,37 @@
1562 description 1596 description
1563 "References a TE topology."; 1597 "References a TE topology.";
1564 leaf provider-id-ref { 1598 leaf provider-id-ref {
1565 - type te-global-id; 1599 + type leafref {
1600 + path "/nw:networks/nw:network[nw:network-id = "
1601 + + "current()/../network-id-ref]/tet:te/tet:provider-id";
1602 + require-instance false;
1603 + }
1566 description 1604 description
1567 "A reference to a provider-id."; 1605 "A reference to a provider-id.";
1568 } 1606 }
1569 leaf client-id-ref { 1607 leaf client-id-ref {
1570 - type te-global-id; 1608 + type leafref {
1609 + path "/nw:networks/nw:network[nw:network-id = "
1610 + + "current()/../network-id-ref]/tet:te/tet:client-id";
1611 + require-instance false;
1612 + }
1571 description 1613 description
1572 "A reference to a client-id."; 1614 "A reference to a client-id.";
1573 } 1615 }
1574 leaf te-topology-id-ref { 1616 leaf te-topology-id-ref {
1575 - type tet:te-topology-id; 1617 + type leafref {
1618 + path "/nw:networks/nw:network[nw:network-id = "
1619 + + "current()/../network-id-ref]/tet:te/tet:te-topology-id";
1620 + require-instance false;
1621 + }
1576 description 1622 description
1577 "A reference to a te-topology-id."; 1623 "A reference to a te-topology-id.";
1578 } 1624 }
1579 leaf network-id-ref { 1625 leaf network-id-ref {
1580 - type nw:network-id; 1626 + type leafref {
1627 + path "/nw:networks/nw:network/nw:network-id";
1628 + require-instance false;
1629 + }
1581 description 1630 description
1582 "A reference to a network-id in base ietf-network module."; 1631 "A reference to a network-id in base ietf-network module.";
1583 } 1632 }
......
...@@ -580,7 +580,7 @@ ...@@ -580,7 +580,7 @@
580 580
581 typedef admin-group { 581 typedef admin-group {
582 type binary { 582 type binary {
583 - length 32; 583 + length 32;
584 } 584 }
585 description 585 description
586 "Administrative group/Resource class/Color."; 586 "Administrative group/Resource class/Color.";
...@@ -680,12 +680,18 @@ ...@@ -680,12 +680,18 @@
680 "The tunnel path hop limit."; 680 "The tunnel path hop limit.";
681 } 681 }
682 leaf metric-type { 682 leaf metric-type {
683 - type string; 683 + type identityref {
684 + base path-metric-type;
685 + }
686 + default path-metric-te;
684 description 687 description
685 "The tunnel path metric type."; 688 "The tunnel path metric type.";
686 } 689 }
687 leaf tiebreaker-type { 690 leaf tiebreaker-type {
688 - type string; 691 + type identityref {
692 + base path-tiebreaker-type;
693 + }
694 + default path-tiebreaker-maxfill;
689 description 695 description
690 "The tunnel path computation tie breakers."; 696 "The tunnel path computation tie breakers.";
691 } 697 }
...@@ -729,7 +735,9 @@ ...@@ -729,7 +735,9 @@
729 list constraints { 735 list constraints {
730 key "usage"; 736 key "usage";
731 leaf usage { 737 leaf usage {
732 - type string; 738 + type identityref {
739 + base resource-affinities-type;
740 + }
733 description "Affinities usage"; 741 description "Affinities usage";
734 } 742 }
735 container constraint { 743 container constraint {
...@@ -765,7 +773,9 @@ ...@@ -765,7 +773,9 @@
765 "Type of SRLG representation"; 773 "Type of SRLG representation";
766 case values { 774 case values {
767 leaf usage { 775 leaf usage {
768 - type string; 776 + type identityref {
777 + base route-exclude-srlg;
778 + }
769 description "SRLG usage"; 779 description "SRLG usage";
770 } 780 }
771 leaf-list values { 781 leaf-list values {
...@@ -777,7 +787,9 @@ ...@@ -777,7 +787,9 @@
777 list constraints { 787 list constraints {
778 key "usage"; 788 key "usage";
779 leaf usage { 789 leaf usage {
780 - type string; 790 + type identityref {
791 + base route-exclude-srlg;
792 + }
781 description "SRLG usage"; 793 description "SRLG usage";
782 } 794 }
783 container constraint { 795 container constraint {
...@@ -829,12 +841,17 @@ ...@@ -829,12 +841,17 @@
829 source."; 841 source.";
830 } 842 }
831 leaf type { 843 leaf type {
832 - type string; 844 + type identityref {
845 + base bidir-association-type;
846 + }
847 + default bidir-assoc-non-corouted;
833 description 848 description
834 "The TE tunnel association type."; 849 "The TE tunnel association type.";
835 } 850 }
836 leaf provisioing { 851 leaf provisioing {
837 - type string; 852 + type identityref {
853 + base bidir-provisioning-mode;
854 + }
838 description 855 description
839 "Describes the provisioning model of the 856 "Describes the provisioning model of the
840 associated bidirectional LSP"; 857 associated bidirectional LSP";
......
1 -module ietf-network {
2 - yang-version 1;
3 - namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 - prefix nd;
5 - container networks {
6 - description
7 - "Serves as top-level container for a list of networks.";
8 - leaf network-id {
9 - type status;
10 - description
11 - "Identifies a network.";
12 - }
13 - }
14 - typedef status {
15 - type uint8;
16 - }
17 - leaf network-ref {
18 - type leafref {
19 - path "/networks";
20 - }
21 - }
22 -}
...\ No newline at end of file ...\ No newline at end of file
...@@ -5,7 +5,7 @@ module module1 { ...@@ -5,7 +5,7 @@ module module1 {
5 import module2 { 5 import module2 {
6 prefix "nt"; 6 prefix "nt";
7 } 7 }
8 - grouping te-node-tunnel-termination-capability { 8 + container te-node-tunnel-termination-capability {
9 description 9 description
10 "Termination capability of a tunnel termination point on a 10 "Termination capability of a tunnel termination point on a
11 TE node."; 11 TE node.";
...@@ -25,4 +25,4 @@ module module1 { ...@@ -25,4 +25,4 @@ module module1 {
25 } 25 }
26 } // termination-capability 26 } // termination-capability
27 } // te-node-tunnel-termination-capability 27 } // te-node-tunnel-termination-capability
28 -}
...\ No newline at end of file ...\ No newline at end of file
28 +}
......
...@@ -5,7 +5,7 @@ module ietf-network-topology { ...@@ -5,7 +5,7 @@ module ietf-network-topology {
5 import ietf-network { 5 import ietf-network {
6 prefix "nt"; 6 prefix "nt";
7 } 7 }
8 - grouping te-node-tunnel-termination-capability { 8 + container te-node-tunnel-termination-capability {
9 description 9 description
10 "Termination capability of a tunnel termination point on a 10 "Termination capability of a tunnel termination point on a
11 TE node."; 11 TE node.";
...@@ -25,4 +25,4 @@ module ietf-network-topology { ...@@ -25,4 +25,4 @@ module ietf-network-topology {
25 } 25 }
26 } // termination-capability 26 } // termination-capability
27 } // te-node-tunnel-termination-capability 27 } // te-node-tunnel-termination-capability
28 -}
...\ No newline at end of file ...\ No newline at end of file
28 +}
......
1 +module GroupingCopiedInModule2 {
2 + yang-version 1;
3 + namespace "onos-yang-19:level1:newlevel";
4 + prefix test;
5 + import LeafrefInGroupingOfModule1 {
6 + prefix module1;
7 + }
8 + description "leaf scenario";
9 + container value {
10 + uses "module1:network-ref";
11 + }
12 +}
...\ No newline at end of file ...\ No newline at end of file
1 -module ietf-network { 1 +module LeafrefInGroupingOfModule1 {
2 yang-version 1; 2 yang-version 1;
3 - namespace "urn:ietf:params:xml:ns:yang:ietf-network"; 3 + namespace "onos-yang-19:level1:newlevel";
4 - prefix nd; 4 + prefix test2;
5 - rpc networks { 5 + description "leaf scenario";
6 - description 6 + container networks {
7 - "Serves as top-level container for a list of networks."; 7 + list network {
8 - grouping input { 8 + key "network-id";
9 - leaf network-id { 9 + description
10 - type string; 10 + "Describes a network.
11 + A network typically contains an inventory of nodes,
12 + topological information (augmented through
13 + network-topology model), as well as layering
14 + information.";
15 + container network-types {
11 description 16 description
12 - "Identifies a network."; 17 + "Serves as an augmentation target.
18 + The network type is indicated through corresponding
19 + presence containers augmented into this container.";
13 } 20 }
14 - }
15 - input {
16 leaf network-id { 21 leaf network-id {
17 - type uint8; 22 + type string;
18 description 23 description
19 "Identifies a network."; 24 "Identifies a network.";
20 } 25 }
21 } 26 }
22 - output { 27 + leaf network-ip {
28 + type uint8;
29 + description
30 + "Identifies a network.";
23 } 31 }
24 } 32 }
25 - leaf network-ref { 33 + grouping network-ref {
26 - type leafref { 34 + leaf network-ref {
27 - path "/networks/input/network-id"; 35 + type leafref {
36 + path "/test2:networks/test2:network/test2:network-id";
37 + }
28 } 38 }
29 } 39 }
30 } 40 }
...\ No newline at end of file ...\ No newline at end of file
......
1 +module ietf-te-topology {
2 + yang-version 1;
3 + namespace "onos-yang-19:level1:newlevel";
4 + prefix test;
5 + import ietf-network {
6 + prefix "nw";
7 + }
8 + description "leaf scenario";
9 + typedef te-topology-event-type {
10 + type enumeration {
11 + enum "add" {
12 + value 0;
13 + description
14 + "A TE node or te-link has been added.";
15 + }
16 + enum "remove" {
17 + value 1;
18 + description
19 + "A TE node or te-link has been removed.";
20 + }
21 + enum "update" {
22 + value 2;
23 + description
24 + "A TE node or te-link has been updated.";
25 + }
26 + }
27 + description "TE Event type for notifications";
28 + } // te-topology-event-type
29 + container te-node-event {
30 + leaf event-type {
31 + type te-topology-event-type;
32 + description "Event type.";
33 + }
34 + description "Notification event for TE node.";
35 + uses nw:node-ref;
36 + }
37 +}
1 + module ietf-network {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 + prefix nd;
5 +
6 + organization
7 + "IETF I2RS (Interface to the Routing System) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
11 + WG List: <mailto:i2rs@ietf.org>
12 +
13 + WG Chair: Susan Hares
14 + <mailto:shares@ndzh.com>
15 +
16 + WG Chair: Jeffrey Haas
17 + <mailto:jhaas@pfrc.org>
18 +
19 + Editor: Alexander Clemm
20 + <mailto:alex@cisco.com>
21 +
22 + Editor: Jan Medved
23 + <mailto:jmedved@cisco.com>
24 +
25 + Editor: Robert Varga
26 + <mailto:rovarga@cisco.com>
27 +
28 + Editor: Tony Tkacik
29 + <mailto:ttkacik@cisco.com>
30 +
31 + Editor: Nitin Bahadur
32 + <mailto:nitin_bahadur@yahoo.com>
33 +
34 + Editor: Hariharan Ananthakrishnan
35 + <mailto:hari@packetdesign.com>";
36 +
37 + description
38 + "This module defines a common base model for a collection
39 + of nodes in a network. Node definitions are further used
40 + in network topologies and inventories.
41 +
42 + Copyright (c) 2015 IETF Trust and the persons identified as
43 + authors of the code. All rights reserved.
44 +
45 + Redistribution and use in source and binary forms, with or
46 + without modification, is permitted pursuant to, and subject
47 + to the license terms contained in, the Simplified BSD License
48 + set forth in Section 4.c of the IETF Trust's Legal Provisions
49 + Relating to IETF Documents
50 + (http://trustee.ietf.org/license-info).
51 +
52 + This version of this YANG module is part of
53 + draft-ietf-i2rs-yang-network-topo-02;
54 + see the RFC itself for full legal notices.
55 +
56 + NOTE TO RFC EDITOR: Please replace above reference to
57 + draft-ietf-i2rs-yang-network-topo-02 with RFC
58 + number when published (i.e. RFC xxxx).";
59 +
60 + revision 2015-12-08 {
61 + description
62 + "Initial revision.
63 + NOTE TO RFC EDITOR: Please replace the following reference
64 + to draft-ietf-i2rs-yang-network-topo-02 with
65 + RFC number when published (i.e. RFC xxxx).";
66 + reference
67 + "draft-ietf-i2rs-yang-network-topo-02";
68 + }
69 +
70 + typedef node-id {
71 + type string;
72 + description
73 + "Identifier for a node.";
74 + }
75 +
76 + typedef network-id {
77 + type string;
78 + description
79 + "Identifier for a network.";
80 + }
81 + grouping network-ref {
82 + description
83 + "Contains the information necessary to reference a network,
84 + for example an underlay network.";
85 + leaf network-ref {
86 + type leafref {
87 + path "/nd:networks/nd:network/nd:network-id";
88 + require-instance false;
89 + }
90 + description
91 + "Used to reference a network, for example an underlay
92 + network.";
93 + }
94 + }
95 +
96 + grouping node-ref {
97 + description
98 + "Contains the information necessary to reference a node.";
99 + leaf node-ref {
100 + type leafref {
101 + path "/nd:networks/nd:network[nd:network-id=current()/../"+
102 + "network-ref]/nd:node/nd:node-id";
103 + require-instance false;
104 + }
105 + description
106 + "Used to reference a node.
107 + Nodes are identified relative to the network they are
108 + contained in.";
109 + }
110 + uses network-ref;
111 + }
112 +
113 + container networks {
114 + description
115 + "Serves as top-level container for a list of networks.";
116 + list network {
117 + key "network-id";
118 + description
119 + "Describes a network.
120 + A network typically contains an inventory of nodes,
121 + topological information (augmented through
122 + network-topology model), as well as layering
123 + information.";
124 + container network-types {
125 + description
126 + "Serves as an augmentation target.
127 + The network type is indicated through corresponding
128 + presence containers augmented into this container.";
129 + }
130 + leaf network-id {
131 + type network-id;
132 + description
133 + "Identifies a network.";
134 + }
135 + list supporting-network {
136 + key "network-ref";
137 + description
138 + "An underlay network, used to represent layered network
139 + topologies.";
140 + leaf network-ref {
141 + type leafref {
142 + path "/networks/network/network-id";
143 + require-instance false;
144 + }
145 + description
146 + "References the underlay network.";
147 + }
148 + }
149 + list node {
150 + key "node-id";
151 + description
152 + "The inventory of nodes of this network.";
153 + leaf node-id {
154 + type node-id;
155 + description
156 + "Identifies a node uniquely within the containing
157 + network.";
158 + }
159 + list supporting-node {
160 + key "network-ref node-ref";
161 + description
162 + "Represents another node, in an underlay network, that
163 + this node is supported by. Used to represent layering
164 + structure.";
165 + leaf network-ref {
166 + type leafref {
167 + path "../../../supporting-network/network-ref";
168 + require-instance false;
169 + }
170 + description
171 + "References the underlay network that the
172 + underlay node is part of.";
173 + }
174 + leaf node-ref {
175 + type leafref {
176 + path "/networks/network/node/node-id";
177 + require-instance false;
178 + }
179 + description
180 + "References the underlay node itself.";
181 + }
182 + }
183 + }
184 + }
185 + }
186 + container networks-state {
187 + config false;
188 + description
189 + "Serves as top-level container for a list of state information
190 + for networks";
191 + list network {
192 + key "network-ref";
193 + description
194 + "Data nodes representing operational data and state of
195 + networks.
196 + An instance is automatically created for every network
197 + in the corresponding list under the networks container.";
198 + uses network-ref;
199 + leaf server-provided {
200 + type boolean;
201 + description
202 + "Indicates whether the information concerning this
203 + particular network is populated by the server
204 + (server-provided true, the general case for network
205 + information discovered from the server),
206 + or whether it is configured by a client
207 + (server-provided true, possible e.g. for
208 + service overlays managed through a controller).";
209 + }
210 + }
211 + }
212 + }
1 -module ietf-network { 1 +module SelfResolutionWhenLeafrefInModuleReferToGroupingInModule {
2 yang-version 1; 2 yang-version 1;
3 namespace "urn:ietf:params:xml:ns:yang:ietf-network"; 3 namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 prefix nd; 4 prefix nd;
...@@ -16,4 +16,4 @@ module ietf-network { ...@@ -16,4 +16,4 @@ module ietf-network {
16 } 16 }
17 } 17 }
18 } 18 }
19 -}
...\ No newline at end of file ...\ No newline at end of file
19 +}
......
1 -module ietf-network { 1 +module SelfResolutionWhenLeafrefInModuleReferToInvalidNode {
2 yang-version 1; 2 yang-version 1;
3 namespace "urn:ietf:params:xml:ns:yang:ietf-network"; 3 namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 prefix nd; 4 prefix nd;
...@@ -16,4 +16,4 @@ module ietf-network { ...@@ -16,4 +16,4 @@ module ietf-network {
16 path "/define/network-id"; 16 path "/define/network-id";
17 } 17 }
18 } 18 }
19 -}
...\ No newline at end of file ...\ No newline at end of file
19 +}
......
1 +module topology {
2 + yang-version 1;
3 + namespace "onos-yang-19:level1:newlevel";
4 + prefix test;
5 + organization "huawei";
6 + contact "adarsh.m@huawei.com";
7 + description "leaf scenario";
8 + container networks {
9 + list network {
10 + key "network-id";
11 + description
12 + "Describes a network.
13 + A network typically contains an inventory of nodes,
14 + topological information (augmented through
15 + network-topology model), as well as layering
16 + information.";
17 + container network-types {
18 + description
19 + "Serves as an augmentation target.
20 + The network type is indicated through corresponding
21 + presence containers augmented into this container.";
22 + }
23 + leaf network-id {
24 + type string;
25 + description
26 + "Identifies a network.";
27 + }
28 + }
29 + leaf network-ip {
30 + type uint8;
31 + description
32 + "Identifies a network.";
33 + }
34 + }
35 + augment "/networks/network" {
36 + container config {
37 + description
38 + "Configuration data.";
39 + choice bundle-stack-level {
40 + description
41 + "The TE link can be partitioned into bundled
42 + links, or component links.";
43 + case bundle {
44 + container bundled-links {
45 + description
46 + "A set of bundled links.";
47 + reference
48 + "RFC4201: Link Bundling in MPLS Traffic Engineering
49 + (TE).";
50 + list bundled-link {
51 + key "src-tp-ref";
52 + leaf src-tp-ref {
53 + type leafref {
54 + path "../../../../../network-ip";
55 + require-instance true;
56 + }
57 + }
58 + }
59 + }
60 + }
61 + }
62 + }
63 + }
64 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module ietf-network {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 + prefix nd;
5 +
6 + import ietf-inet-types {
7 + prefix inet;
8 + }
9 + typedef node-id {
10 + type inet:uri;
11 + description
12 + "Identifier for a node.";
13 + }
14 +
15 + leaf xyz {
16 + type string;
17 + }
18 + typedef network-id {
19 + type inet:uri;
20 + description
21 + "Identifier for a network.";
22 + }
23 + grouping network-ref {
24 + description
25 + "Contains the information necessary to reference a network,
26 + for example an underlay network.";
27 + leaf network-ref {
28 + type leafref {
29 + path "/nd:xyz";
30 + require-instance false;
31 + }
32 + description
33 + "Used to reference a network, for example an underlay
34 + network.";
35 + }
36 + }
37 + }
1 +module ietf-network {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 + prefix nd;
5 + import network {
6 + prefix "nw";
7 + }
8 + grouping xyz {
9 + leaf network-id-ref {
10 + type leafref {
11 + path "/nw:networks/nw:network/nw:network-id";
12 + require-instance false;
13 + }
14 + description
15 + "A reference to a network-id in base ietf-network module.";
16 + }
17 + }
18 + grouping yzx {
19 + container hi {
20 + uses xyz;
21 + }
22 + }
23 + container fine {
24 + uses yzx;
25 + }
26 + container networks {
27 + leaf network {
28 + type string;
29 + }
30 + }
31 +}
32 +
33 +
1 + module network {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 + prefix nd;
5 +
6 + organization
7 + "IETF I2RS (Interface to the Routing System) Working Group";
8 +
9 + contact
10 + "WG Web: <http://tools.ietf.org/wg/i2rs/>
11 + WG List: <mailto:i2rs@ietf.org>
12 +
13 + WG Chair: Susan Hares
14 + <mailto:shares@ndzh.com>
15 +
16 + WG Chair: Jeffrey Haas
17 + <mailto:jhaas@pfrc.org>
18 +
19 + Editor: Alexander Clemm
20 + <mailto:alex@cisco.com>
21 +
22 + Editor: Jan Medved
23 + <mailto:jmedved@cisco.com>
24 +
25 + Editor: Robert Varga
26 + <mailto:rovarga@cisco.com>
27 +
28 + Editor: Tony Tkacik
29 + <mailto:ttkacik@cisco.com>
30 +
31 + Editor: Nitin Bahadur
32 + <mailto:nitin_bahadur@yahoo.com>
33 +
34 + Editor: Hariharan Ananthakrishnan
35 + <mailto:hari@packetdesign.com>";
36 +
37 + description
38 + "This module defines a common base model for a collection
39 + of nodes in a network. Node definitions are further used
40 + in network topologies and inventories.
41 +
42 + Copyright (c) 2015 IETF Trust and the persons identified as
43 + authors of the code. All rights reserved.
44 +
45 + Redistribution and use in source and binary forms, with or
46 + without modification, is permitted pursuant to, and subject
47 + to the license terms contained in, the Simplified BSD License
48 + set forth in Section 4.c of the IETF Trust's Legal Provisions
49 + Relating to IETF Documents
50 + (http://trustee.ietf.org/license-info).
51 +
52 + This version of this YANG module is part of
53 + draft-ietf-i2rs-yang-network-topo-02;
54 + see the RFC itself for full legal notices.
55 +
56 + NOTE TO RFC EDITOR: Please replace above reference to
57 + draft-ietf-i2rs-yang-network-topo-02 with RFC
58 + number when published (i.e. RFC xxxx).";
59 +
60 + revision 2015-12-08 {
61 + description
62 + "Initial revision.
63 + NOTE TO RFC EDITOR: Please replace the following reference
64 + to draft-ietf-i2rs-yang-network-topo-02 with
65 + RFC number when published (i.e. RFC xxxx).";
66 + reference
67 + "draft-ietf-i2rs-yang-network-topo-02";
68 + }
69 +
70 + typedef node-id {
71 + type string;
72 + description
73 + "Identifier for a node.";
74 + }
75 +
76 + typedef network-id {
77 + type string;
78 + description
79 + "Identifier for a network.";
80 + }
81 + grouping network-ref {
82 + description
83 + "Contains the information necessary to reference a network,
84 + for example an underlay network.";
85 + leaf network-ref {
86 + type leafref {
87 + path "/nd:networks/nd:network/nd:network-id";
88 + require-instance false;
89 + }
90 + description
91 + "Used to reference a network, for example an underlay
92 + network.";
93 + }
94 + }
95 +
96 + grouping node-ref {
97 + description
98 + "Contains the information necessary to reference a node.";
99 + leaf node-ref {
100 + type leafref {
101 + path "/nd:networks/nd:network[nd:network-id=current()/../"+
102 + "network-ref]/nd:node/nd:node-id";
103 + require-instance false;
104 + }
105 + description
106 + "Used to reference a node.
107 + Nodes are identified relative to the network they are
108 + contained in.";
109 + }
110 + uses network-ref;
111 + }
112 +
113 + container networks {
114 + description
115 + "Serves as top-level container for a list of networks.";
116 + list network {
117 + key "network-id";
118 + description
119 + "Describes a network.
120 + A network typically contains an inventory of nodes,
121 + topological information (augmented through
122 + network-topology model), as well as layering
123 + information.";
124 + container network-types {
125 + description
126 + "Serves as an augmentation target.
127 + The network type is indicated through corresponding
128 + presence containers augmented into this container.";
129 + }
130 + leaf network-id {
131 + type network-id;
132 + description
133 + "Identifies a network.";
134 + }
135 + list supporting-network {
136 + key "network-ref";
137 + description
138 + "An underlay network, used to represent layered network
139 + topologies.";
140 + leaf network-ref {
141 + type leafref {
142 + path "/networks/network/network-id";
143 + require-instance false;
144 + }
145 + description
146 + "References the underlay network.";
147 + }
148 + }
149 + list node {
150 + key "node-id";
151 + description
152 + "The inventory of nodes of this network.";
153 + leaf node-id {
154 + type node-id;
155 + description
156 + "Identifies a node uniquely within the containing
157 + network.";
158 + }
159 + list supporting-node {
160 + key "network-ref node-ref";
161 + description
162 + "Represents another node, in an underlay network, that
163 + this node is supported by. Used to represent layering
164 + structure.";
165 + leaf network-ref {
166 + type leafref {
167 + path "../../../supporting-network/network-ref";
168 + require-instance false;
169 + }
170 + description
171 + "References the underlay network that the
172 + underlay node is part of.";
173 + }
174 + leaf node-ref {
175 + type leafref {
176 + path "/networks/network/node/node-id";
177 + require-instance false;
178 + }
179 + description
180 + "References the underlay node itself.";
181 + }
182 + }
183 + }
184 + }
185 + }
186 + container networks-state {
187 + config false;
188 + description
189 + "Serves as top-level container for a list of state information
190 + for networks";
191 + list network {
192 + key "network-ref";
193 + description
194 + "Data nodes representing operational data and state of
195 + networks.
196 + An instance is automatically created for every network
197 + in the corresponding list under the networks container.";
198 + uses network-ref;
199 + leaf server-provided {
200 + type boolean;
201 + description
202 + "Indicates whether the information concerning this
203 + particular network is populated by the server
204 + (server-provided true, the general case for network
205 + information discovered from the server),
206 + or whether it is configured by a client
207 + (server-provided true, possible e.g. for
208 + service overlays managed through a controller).";
209 + }
210 + }
211 + }
212 + }
...\ No newline at end of file ...\ No newline at end of file
1 +module ietf-network {
2 + yang-version 1;
3 + namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 + prefix nd;
5 +
6 + organization
7 + "IETF I2RS (Interface to the Routing System) Working Group";
8 + grouping node-ref {
9 + description
10 + "Contains the information necessary to reference a node.";
11 + container node-from-grouping {
12 + leaf node-ref {
13 + type leafref {
14 + path "/networks/network/node/node-id";
15 + require-instance false;
16 + }
17 + }
18 + }
19 + }
20 + container networks {
21 + description
22 + "Serves as top-level container for a list of networks.";
23 + list network {
24 + key "network-id";
25 + description
26 + "Describes a network.
27 + A network typically contains an inventory of nodes,
28 + topological information (augmented through
29 + network-topology model), as well as layering
30 + information.";
31 + container network-types {
32 + description
33 + "Serves as an augmentation target.
34 + The network type is indicated through corresponding
35 + presence containers augmented into this container.";
36 + }
37 + leaf network-id {
38 + type string;
39 + description
40 + "Identifies a network.";
41 + }
42 + list supporting-network {
43 + key "network-ref";
44 + description
45 + "An underlay network, used to represent layered network
46 + topologies.";
47 + leaf network-ref {
48 + type leafref {
49 + path "/networks/network/network-id";
50 + require-instance false;
51 + }
52 + description
53 + "References the underlay network.";
54 + }
55 + }
56 + list node {
57 + key "node-id";
58 + description
59 + "The inventory of nodes of this network.";
60 + leaf node-id {
61 + type uint8;
62 + description
63 + "Identifies a node uniquely within the containing
64 + network.";
65 + }
66 + list supporting-node {
67 + key "network-ref node-ref";
68 + description
69 + "Represents another node, in an underlay network, that
70 + this node is supported by. Used to represent layering
71 + structure.";
72 + leaf network-ref {
73 + type leafref {
74 + path "../../../supporting-network/network-ref";
75 + require-instance false;
76 + }
77 + description
78 + "References the underlay network that the
79 + underlay node is part of.";
80 + }
81 + leaf node-ref {
82 + type leafref {
83 + path "/networks/network/node/node-id";
84 + require-instance false;
85 + }
86 + description
87 + "References the underlay node itself.";
88 + }
89 + }
90 + }
91 + }
92 + uses node-ref;
93 + }
94 +
95 +}
1 -module ietf-network { 1 +module SelfResolutionWhenLeafrefInModuleReferToLeafInInputOfRpc {
2 yang-version 1; 2 yang-version 1;
3 namespace "urn:ietf:params:xml:ns:yang:ietf-network"; 3 namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 prefix nd; 4 prefix nd;
...@@ -20,4 +20,4 @@ module ietf-network { ...@@ -20,4 +20,4 @@ module ietf-network {
20 path "/networks/input/network-id"; 20 path "/networks/input/network-id";
21 } 21 }
22 } 22 }
23 -}
...\ No newline at end of file ...\ No newline at end of file
23 +}
......
1 -module ietf-network { 1 +module SelfResolutionWhenLeafrefInModuleReferToGroupingWithInputInRpc {
2 yang-version 1; 2 yang-version 1;
3 namespace "urn:ietf:params:xml:ns:yang:ietf-network"; 3 namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 prefix nd; 4 prefix nd;
...@@ -25,4 +25,4 @@ module ietf-network { ...@@ -25,4 +25,4 @@ module ietf-network {
25 path "/networks/input/network-id"; 25 path "/networks/input/network-id";
26 } 26 }
27 } 27 }
28 -}
...\ No newline at end of file ...\ No newline at end of file
28 +}
......
1 -module ietf-network { 1 +module SelfResolutionWhenLeafrefReferToContainerLeaf {
2 yang-version 1; 2 yang-version 1;
3 namespace "urn:ietf:params:xml:ns:yang:ietf-network"; 3 namespace "urn:ietf:params:xml:ns:yang:ietf-network";
4 prefix nd; 4 prefix nd;
...@@ -16,4 +16,4 @@ module ietf-network { ...@@ -16,4 +16,4 @@ module ietf-network {
16 path "/networks/network-id"; 16 path "/networks/network-id";
17 } 17 }
18 } 18 }
19 -}
...\ No newline at end of file ...\ No newline at end of file
19 +}
......