Skip to content

Commit 327ad41

Browse files
authored
[yang] add set_owner to feature yang (#9075)
#### Why I did it Add the configuration for the set_owner in the `feature` yang model #### How I did it Add new leaf `set_pwner` to the `feature` yang model #### How to verify it compile `sonic_yang_mgmt-1.0-py3-none-any.whl`
1 parent 325276a commit 327ad41

File tree

5 files changed

+89
-23
lines changed

5 files changed

+89
-23
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,47 +1224,53 @@
12241224
"has_per_asic_scope": "true",
12251225
"has_timer": "false",
12261226
"high_mem_alert": "disabled",
1227-
"state": "enabled"
1227+
"state": "enabled",
1228+
"set_owner": "local"
12281229
},
12291230
"database": {
12301231
"auto_restart": "always_enabled",
12311232
"has_global_scope": "true",
12321233
"has_per_asic_scope": "true",
12331234
"has_timer": "false",
12341235
"high_mem_alert": "disabled",
1235-
"state": "always_enabled"
1236+
"state": "always_enabled",
1237+
"set_owner": "local"
12361238
},
12371239
"snmp": {
12381240
"auto_restart": "enabled",
12391241
"has_global_scope": "true",
12401242
"has_per_asic_scope": "false",
12411243
"has_timer": "true",
12421244
"high_mem_alert": "disabled",
1243-
"state": "enabled"
1245+
"state": "enabled",
1246+
"set_owner": "kube"
12441247
},
12451248
"swss": {
12461249
"auto_restart": "enabled",
12471250
"has_global_scope": "false",
12481251
"has_per_asic_scope": "true",
12491252
"has_timer": "false",
12501253
"high_mem_alert": "disabled",
1251-
"state": "enabled"
1254+
"state": "enabled",
1255+
"set_owner": "local"
12521256
},
12531257
"syncd": {
12541258
"auto_restart": "enabled",
12551259
"has_global_scope": "false",
12561260
"has_per_asic_scope": "true",
12571261
"has_timer": "false",
12581262
"high_mem_alert": "disabled",
1259-
"state": "enabled"
1263+
"state": "enabled",
1264+
"set_owner": "local"
12601265
},
12611266
"lldp": {
12621267
"auto_restart": "enabled",
12631268
"has_global_scope": "false",
12641269
"has_per_asic_scope": "true",
12651270
"has_timer": "false",
12661271
"high_mem_alert": "disabled",
1267-
"state": "enabled"
1272+
"state": "enabled",
1273+
"set_owner": "kube"
12681274
}
12691275
},
12701276
"DHCP_RELAY": {

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
"FEATURE_WITH_INVALID_STATE" : {
66
"desc": "Referring invalid feature state.",
77
"eStrKey": "Pattern",
8-
"eStr": ["enabled|disabled|always_enabled"]
8+
"eStr": ["enabled|disabled|always_enabled|always_disabled"]
9+
},
10+
"FEATURE_WITH_INVALID_OWNER" : {
11+
"desc": "Referring invalid feature set_owner field.",
12+
"eStrKey": "Pattern",
13+
"eStr": ["kube|local"]
14+
},
15+
"FEATURE_WITH_NO_OWNER" : {
16+
"desc": "Config feature table without set_owner"
917
}
1018
}

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

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,44 @@
99
"auto_restart": "always_enabled",
1010
"has_timer": "false",
1111
"has_global_scope": "true",
12-
"has_per_asic_scope": "true"
12+
"has_per_asic_scope": "true",
13+
"set_owner": "local"
1314
},
1415
{
1516
"name": "swss",
1617
"state": "always_enabled",
1718
"auto_restart": "always_enabled",
1819
"has_timer": "false",
1920
"has_global_scope": "false",
20-
"has_per_asic_scope": "true"
21+
"has_per_asic_scope": "true",
22+
"set_owner": "local"
2123
},
2224
{
2325
"name": "syncd",
2426
"state": "always_enabled",
2527
"auto_restart": "always_enabled",
2628
"has_timer": "false",
2729
"has_global_scope": "false",
28-
"has_per_asic_scope": "true"
30+
"has_per_asic_scope": "true",
31+
"set_owner": "local"
2932
},
3033
{
3134
"name": "snmp",
3235
"state": "enabled",
3336
"auto_restart": "enabled",
3437
"has_timer": "false",
3538
"has_global_scope": "true",
36-
"has_per_asic_scope": "false"
39+
"has_per_asic_scope": "false",
40+
"set_owner": "kube"
3741
},
3842
{
3943
"name": "lldp",
4044
"state": "disabled",
4145
"auto_restart": "disabled",
4246
"has_timer": "false",
4347
"has_global_scope": "false",
44-
"has_per_asic_scope": "true"
48+
"has_per_asic_scope": "true",
49+
"set_owner": "kube"
4550
}
4651
]
4752
}
@@ -57,6 +62,40 @@
5762
"auto_restart": "always_enabled",
5863
"has_timer": "false",
5964
"has_global_scope": "true",
65+
"has_per_asic_scope": "true",
66+
"set_owner": "local"
67+
}
68+
]
69+
}
70+
}
71+
},
72+
"FEATURE_WITH_INVALID_OWNER": {
73+
"sonic-feature:sonic-feature": {
74+
"sonic-feature:FEATURE": {
75+
"FEATURE_LIST": [
76+
{
77+
"name": "lldp",
78+
"state": "disabled",
79+
"auto_restart": "disabled",
80+
"has_timer": "false",
81+
"has_global_scope": "false",
82+
"has_per_asic_scope": "true",
83+
"set_owner": "invalid"
84+
}
85+
]
86+
}
87+
}
88+
},
89+
"FEATURE_WITH_NO_OWNER": {
90+
"sonic-feature:sonic-feature": {
91+
"sonic-feature:FEATURE": {
92+
"FEATURE_LIST": [
93+
{
94+
"name": "lldp",
95+
"state": "disabled",
96+
"auto_restart": "disabled",
97+
"has_timer": "false",
98+
"has_global_scope": "false",
6099
"has_per_asic_scope": "true"
61100
}
62101
]

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

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

8-
import sonic-types {
9-
prefix stypes;
8+
description "Feature Table yang Module for SONiC";
9+
10+
typedef feature-state {
11+
description "configuration to set the feature running state";
12+
type string {
13+
pattern "enabled|disabled|always_enabled|always_disabled";
14+
}
1015
}
1116

12-
description "Feature Table yang Module for SONiC OS";
17+
typedef feature-owner {
18+
description "configuration to set if the container is controlled
19+
by kubernetes or locally";
20+
type string {
21+
pattern "kube|local";
22+
}
23+
}
1324

1425
container sonic-feature {
1526

@@ -30,12 +41,12 @@ module sonic-feature{
3041

3142
leaf state {
3243
description "state of the feature";
33-
type stypes:feature_state;
44+
type feature-state;
3445
default "enabled";
3546
}
3647

3748
leaf auto_restart {
38-
type stypes:feature_state;
49+
type feature-state;
3950
default "enabled";
4051
}
4152

@@ -63,9 +74,16 @@ module sonic-feature{
6374
leaf high_mem_alert {
6475
description "This configuration controls the trigger to generate
6576
alert on high memory utilization";
66-
type stypes:feature_state;
77+
type feature-state;
6778
default "disabled";
6879
}
80+
81+
leaf set_owner {
82+
description " This configuration set the feature owner is
83+
kubernetes or local";
84+
type feature-owner;
85+
default "local";
86+
}
6987
}
7088
}
7189
}

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,6 @@ module sonic-types {
197197
}
198198
}
199199

200-
typedef feature_state {
201-
type string {
202-
pattern "enabled|disabled|always_enabled";
203-
}
204-
}
205200
typedef meter_type {
206201
type enumeration {
207202
enum packets;

0 commit comments

Comments
 (0)