Skip to content

Commit 3d82e6c

Browse files
[DPB][YANG] Fix cases when boolean is used in different literal cases (#9654)
* Add boolean as typedef to sonic-types * Fix boolean in sonic-feature yang model * Fix boolean in sonic-flex_counter yang model #### Why I did it It was request to cherry-pick fix from master (#9418) to 202111 branch to fix issue when boolean is used in different literal cases. #### How I did it Added boolean to sonic-types as typedef with different literal cases. #### How to verify it Run the command config interface breakout <interface_name> <breakout_mode>
1 parent 3c8d0a6 commit 3d82e6c

File tree

6 files changed

+50
-15
lines changed

6 files changed

+50
-15
lines changed

src/sonic-yang-models/tests/files/sample_config_db.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,9 +1214,9 @@
12141214
"FEATURE": {
12151215
"bgp": {
12161216
"auto_restart": "enabled",
1217-
"has_global_scope": "false",
1218-
"has_per_asic_scope": "true",
1219-
"has_timer": "false",
1217+
"has_global_scope": "False",
1218+
"has_per_asic_scope": "True",
1219+
"has_timer": "False",
12201220
"high_mem_alert": "disabled",
12211221
"state": "enabled",
12221222
"set_owner": "local"
@@ -1329,7 +1329,7 @@
13291329
"scheduler": "TEST@1",
13301330
"wred_profile": "Wred1"
13311331
}
1332-
},
1332+
},
13331333

13341334
"DSCP_TO_TC_MAP": {
13351335
"Dscp_to_tc_map1": {

src/sonic-yang-models/tests/yang_model_tests/tests/feature.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
"eStrKey": "Pattern",
88
"eStr": ["enabled|disabled|always_enabled|always_disabled"]
99
},
10+
"FEATURE_WITH_INVALID_BOOLEAN_TYPE" : {
11+
"desc": "Referring invalid feature boolean types.",
12+
"eStrKey": "Pattern",
13+
"eStr": ["false|true|False|True"]
14+
},
1015
"FEATURE_WITH_INVALID_OWNER" : {
1116
"desc": "Referring invalid feature set_owner field.",
1217
"eStrKey": "Pattern",

src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"name": "database",
88
"state": "always_enabled",
99
"auto_restart": "always_enabled",
10-
"has_timer": "false",
11-
"has_global_scope": "true",
12-
"has_per_asic_scope": "true",
10+
"has_timer": "False",
11+
"has_global_scope": "True",
12+
"has_per_asic_scope": "True",
1313
"set_owner": "local"
1414
},
1515
{
@@ -101,5 +101,21 @@
101101
]
102102
}
103103
}
104+
},
105+
"FEATURE_WITH_INVALID_BOOLEAN_TYPE": {
106+
"sonic-feature:sonic-feature": {
107+
"sonic-feature:FEATURE": {
108+
"FEATURE_LIST": [
109+
{
110+
"name": "database",
111+
"state": "always_enabled",
112+
"auto_restart": "always_enabled",
113+
"has_timer": "FALSE",
114+
"has_global_scope": "TRUE",
115+
"has_per_asic_scope": "TRUE"
116+
}
117+
]
118+
}
119+
}
104120
}
105121
}

src/sonic-yang-models/yang-models/sonic-feature.yang

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ module sonic-feature{
55
namespace "http://github.com/Azure/sonic-feature";
66
prefix feature;
77

8+
import sonic-types {
9+
prefix stypes;
10+
}
11+
812
description "Feature Table yang Module for SONiC";
9-
13+
1014
typedef feature-state {
1115
description "configuration to set the feature running state";
1216
type string {
@@ -53,22 +57,22 @@ module sonic-feature{
5357
leaf has_timer {
5458
description "This configuration identicates if there is
5559
timer associated to this feature";
56-
type boolean;
57-
default false;
60+
type stypes:boolean_type;
61+
default "false";
5862
}
5963

6064
leaf has_global_scope {
6165
description "This configuration identicates there will only one service
6266
spawned for the device";
63-
type boolean;
64-
default false;
67+
type stypes:boolean_type;
68+
default "false";
6569
}
6670

6771
leaf has_per_asic_scope {
6872
description "This configuration identicates there will only one service
6973
spawned per asic";
70-
type boolean;
71-
default false;
74+
type stypes:boolean_type;
75+
default "false";
7276
}
7377

7478
leaf high_mem_alert {

src/sonic-yang-models/yang-models/sonic-flex_counter.yang

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ module sonic-flex_counter {
55
namespace "http://github.com/Azure/sonic-flex_counter";
66
prefix flex_counter;
77

8+
import sonic-types {
9+
prefix stypes;
10+
}
11+
812
description "FLEX COUNTER YANG Module for SONiC OS";
913

1014
revision 2020-04-10 {
@@ -24,7 +28,7 @@ module sonic-flex_counter {
2428
}
2529

2630
typedef flex_delay_status {
27-
type boolean;
31+
type stypes:boolean_type;
2832
}
2933

3034
typedef poll_interval {

src/sonic-yang-models/yang-templates/sonic-types.yang.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ module sonic-types {
217217
}
218218
}
219219

220+
typedef boolean_type {
221+
type string {
222+
pattern "false|true|False|True";
223+
}
224+
}
225+
220226
typedef mac-addr-and-mask {
221227
type string {
222228
pattern "[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}|[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}/[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}";

0 commit comments

Comments
 (0)