Skip to content

Commit 6eb5daa

Browse files
committed
add deref to schema
1 parent d87202b commit 6eb5daa

9 files changed

+181
-153
lines changed

tests/schema/sdcio_model.yang

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,27 @@ module sdcio_model {
33
namespace "urn:sdcio/model";
44
prefix sdcio_model;
55

6-
import sdcio_model_ni {
7-
prefix sdcio_model_ni;
8-
}
9-
import sdcio_model_if {
10-
prefix sdcio_model_if;
11-
}
12-
import sdcio_model_choice {
13-
prefix sdcio_model_choice;
14-
}
15-
import sdcio_model_doublekey {
16-
prefix sdcio_model_doublekey;
17-
}
18-
import sdcio_model_leaflist {
19-
prefix sdcio_model_leaflist;
20-
}
21-
import sdcio_model_list_unique {
22-
prefix sdcio_model_list_unique;
23-
}
6+
import sdcio_model_ni {
7+
prefix sdcio_model_ni;
8+
}
9+
import sdcio_model_if {
10+
prefix sdcio_model_if;
11+
}
12+
import sdcio_model_choice {
13+
prefix sdcio_model_choice;
14+
}
15+
import sdcio_model_doublekey {
16+
prefix sdcio_model_doublekey;
17+
}
18+
import sdcio_model_leaflist {
19+
prefix sdcio_model_leaflist;
20+
}
21+
import sdcio_model_list_unique {
22+
prefix sdcio_model_list_unique;
23+
}
24+
import sdcio_model_deref {
25+
prefix sdcio_model_deref;
26+
}
2427

2528
description
2629
"This is the test schema for sdcio";
@@ -30,22 +33,20 @@ import sdcio_model_list_unique {
3033
"Test schema first attempt";
3134
}
3235

33-
3436
uses sdcio_model_if:interface-top;
3537
uses sdcio_model_ni:network-instance-top;
3638
uses sdcio_model_choice:choicecase-top;
3739
uses sdcio_model_doublekey:doublekey-top;
3840
uses sdcio_model_leaflist:leaflist-top;
3941
uses sdcio_model_list_unique:list-unique-top;
40-
41-
leaf patterntest {
42-
type string {
43-
length "7..10";
44-
pattern "hallo [0-9a-fA-F]*";
45-
// pattern 'hallo DU' {
46-
// // modifier invert-match;
47-
// }
48-
}
49-
}
50-
51-
}
42+
uses sdcio_model_deref:deref-top;
43+
leaf patterntest {
44+
type string {
45+
length "7..10";
46+
pattern 'hallo [0-9a-fA-F]*';
47+
// pattern 'hallo DU' {
48+
// // modifier invert-match;
49+
// }
50+
}
51+
}
52+
}

tests/schema/sdcio_model_choice.yang

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ module sdcio_model_choice {
77
// prefix sdcio_model_common;
88
// }
99

10-
1110
description
1211
"This is part of the test schema for sdcio";
1312

@@ -16,39 +15,41 @@ module sdcio_model_choice {
1615
"Test schema first attempt";
1716
}
1817

19-
20-
grouping choicecase-top {
21-
container choices {
22-
description
23-
"here we have a choice with two cases";
24-
choice choicecase {
25-
container case1 {
26-
presence "case1 is active";
18+
grouping choicecase-top {
19+
container choices {
20+
description
21+
"here we have a choice with two cases";
22+
choice choicecase {
23+
container case1 {
24+
presence "case1 is active";
25+
description
26+
"case 1 of the choicecase";
27+
leaf log {
28+
type boolean;
29+
default "false";
2730
description
28-
"case 1 of the choicecase";
29-
leaf log {
30-
type boolean;
31-
default "false";
32-
description "When this is true, a log is created for each packet matching the entry";
33-
}
34-
container case-elem {
35-
leaf elem {
36-
type string;
37-
description "some element under the case";
38-
}
31+
"When this is true, a log is created for each packet matching the entry";
32+
}
33+
container case-elem {
34+
leaf elem {
35+
type string;
36+
description
37+
"some element under the case";
3938
}
4039
}
41-
container case2 {
42-
presence "case1 is active";
40+
}
41+
container case2 {
42+
presence "case1 is active";
43+
description
44+
"case 1 of the choicecase";
45+
leaf log {
46+
type boolean;
47+
default "false";
4348
description
44-
"case 1 of the choicecase";
45-
leaf log {
46-
type boolean;
47-
default "false";
48-
description "When this is true, a log is created for each packet matching the entry";
49-
}
49+
"When this is true, a log is created for each packet matching the entry";
5050
}
5151
}
5252
}
5353
}
54-
}
54+
}
55+
}

tests/schema/sdcio_model_common.yang

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ module sdcio_model_common {
1111
"Test schema first attempt";
1212
}
1313

14-
typedef admin-state {
14+
typedef admin-state {
1515
type enumeration {
1616
enum enable {
1717
value 1;
18-
description "admin-state enable";
18+
description
19+
"admin-state enable";
1920
}
2021
enum disable {
2122
value 2;
22-
description "admin-state disable";
23+
description
24+
"admin-state disable";
2325
}
2426
}
2527
description
@@ -60,12 +62,13 @@ module sdcio_model_common {
6062
"A user provided description string";
6163
}
6264

63-
typedef as-number {
65+
typedef as-number {
6466
type uint32 {
6567
range "1..4294967295";
6668
}
67-
description "AS Number";
68-
}
69+
description
70+
"AS Number";
71+
}
6972

7073
typedef ip-address {
7174
type union {
@@ -76,10 +79,7 @@ module sdcio_model_common {
7679
"An IPv4 or IPv6 address with no prefix specified.";
7780
}
7881

79-
80-
8182
typedef ipv4-address {
82-
8383
type string {
8484
pattern '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|'
8585
+ '25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4]'
@@ -179,7 +179,7 @@ module sdcio_model_common {
179179
"User defined name or reference type to a specific subinterface of the form <interface-name>.<subinterface-index>";
180180
}
181181

182-
identity bgp-address-family {
182+
identity bgp-address-family {
183183
description
184184
"Base type for BGP address families.";
185185
}
@@ -232,7 +232,7 @@ module sdcio_model_common {
232232
"Route target constraint routes (AFI 1, SAFI 132)";
233233
}
234234

235-
typedef interface-name {
235+
typedef interface-name {
236236
type string {
237237
length "3..20";
238238
pattern '(mgmt0|'
@@ -243,6 +243,4 @@ module sdcio_model_common {
243243
+ 'lag(([1-9](\d){0,2})|(1000)))';
244244
}
245245
}
246-
247-
248-
}
246+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
module sdcio_model_deref {
2+
yang-version 1.1;
3+
namespace "urn:sdcio/model_deref";
4+
prefix sdcio_model_deref;
5+
6+
description
7+
"This is part of the test schema for sdcio";
8+
9+
revision 2024-09-09 {
10+
description
11+
"Test schema first attempt";
12+
}
13+
14+
grouping deref-top {
15+
container mgmt-interface {
16+
leaf name {
17+
type leafref {
18+
path "/interface/name";
19+
}
20+
}
21+
leaf typer {
22+
type leafref {
23+
path "interface[name=current()/../name]/interface-type";
24+
}
25+
must 'deref(.)/../admin-state = "enable"' {
26+
error-message "The management interface cannot be disabled.";
27+
}
28+
}
29+
}
30+
}
31+
}

tests/schema/sdcio_model_doublekey.yang

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,31 @@ module sdcio_model_doublekey {
1111
"Test schema first attempt";
1212
}
1313

14-
grouping doublekey-top {
15-
list doublekey {
14+
grouping doublekey-top {
15+
list doublekey {
16+
description
17+
"here we have a container with two keys";
18+
key "key1 key2";
19+
leaf key1 {
20+
type string;
21+
}
22+
leaf key2 {
23+
type string;
24+
}
25+
leaf mandato {
26+
type string;
27+
mandatory true;
28+
}
29+
container cont {
1630
description
17-
"here we have a container with two keys";
18-
key "key1 key2";
19-
20-
leaf key1 {
21-
type string;
22-
}
23-
leaf key2 {
31+
"just a simple container under a double keyed item";
32+
leaf value1 {
2433
type string;
2534
}
26-
leaf mandato {
35+
leaf value2 {
2736
type string;
28-
mandatory true;
29-
}
30-
container cont {
31-
description "just a simple container under a double keyed item";
32-
leaf value1 {
33-
type string;
34-
}
35-
leaf value2 {
36-
type string;
37-
}
3837
}
39-
4038
}
4139
}
42-
}
40+
}
41+
}

tests/schema/sdcio_model_if.yang

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
21
module sdcio_model_if {
32
yang-version 1.1;
43
namespace "urn:sdcio/model_if";
54
prefix sdcio_model_if;
65

7-
import sdcio_model_common {
6+
import sdcio_model_common {
87
prefix sdcio_model_common;
98
}
109

11-
grouping interface-top {
10+
grouping interface-top {
1211
description
1312
"Top-level grouping for interface configuration and operational state data";
1413
list interface {
@@ -20,18 +19,21 @@ module sdcio_model_if {
2019
description
2120
"The name of the interface";
2221
}
23-
leaf admin-state {
24-
type sdcio_model_common:admin-state;
25-
default "enable";
26-
description
27-
"The configured, desired state of the interface";
28-
reference
29-
"RFC 2863: The Interfaces Group MIB - ifAdminStatus";
30-
must "((. = 'enable') and starts-with(../name, 'system0')) or not(starts-with(../name, 'system0'))" {
31-
error-message "admin-state must be enable";
22+
leaf admin-state {
23+
type sdcio_model_common:admin-state;
24+
default "enable";
25+
description
26+
"The configured, desired state of the interface";
27+
reference
28+
"RFC 2863: The Interfaces Group MIB - ifAdminStatus";
29+
must "((. = 'enable') and starts-with(../name, 'system0')) or not(starts-with(../name, 'system0'))" {
30+
error-message "admin-state must be enable";
31+
}
3232
}
33-
}
34-
leaf description {
33+
leaf interface-type {
34+
type string;
35+
}
36+
leaf description {
3537
type sdcio_model_common:description;
3638
description
3739
"A user-entered description of this network instance.";
@@ -40,7 +42,7 @@ module sdcio_model_if {
4042
}
4143
}
4244

43-
grouping subinterface-top {
45+
grouping subinterface-top {
4446
description
4547
"Subinterface data for logical interfaces associated with a given interface";
4648
list subinterface {
@@ -71,12 +73,11 @@ module sdcio_model_if {
7173
error-message "local-mirror-dest is not supported on this interface";
7274
}
7375
}
74-
leaf description {
76+
leaf description {
7577
type sdcio_model_common:description;
7678
description
7779
"A user-entered description of this network instance.";
7880
}
7981
}
80-
}
81-
82-
}
82+
}
83+
}

0 commit comments

Comments
 (0)