diff --git a/src/sonic-yang-models/tests/files/sample_config_db.json b/src/sonic-yang-models/tests/files/sample_config_db.json index f04a051166..541cdb0f3c 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1220,9 +1220,9 @@ "FEATURE": { "bgp": { "auto_restart": "enabled", - "has_global_scope": "false", - "has_per_asic_scope": "true", - "has_timer": "false", + "has_global_scope": "False", + "has_per_asic_scope": "True", + "has_timer": "False", "high_mem_alert": "disabled", "state": "enabled", "set_owner": "local" diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/feature.json b/src/sonic-yang-models/tests/yang_model_tests/tests/feature.json index 811bf94c90..d18b693937 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/feature.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/feature.json @@ -7,6 +7,11 @@ "eStrKey": "Pattern", "eStr": ["enabled|disabled|always_enabled|always_disabled"] }, + "FEATURE_WITH_INVALID_BOOLEAN_TYPE" : { + "desc": "Referring invalid feature boolean types.", + "eStrKey": "Pattern", + "eStr": ["false|true|False|True"] + }, "FEATURE_WITH_INVALID_OWNER" : { "desc": "Referring invalid feature set_owner field.", "eStrKey": "Pattern", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json index 5578907cbd..5f43cfc3a6 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/feature.json @@ -7,9 +7,9 @@ "name": "database", "state": "always_enabled", "auto_restart": "always_enabled", - "has_timer": "false", - "has_global_scope": "true", - "has_per_asic_scope": "true", + "has_timer": "False", + "has_global_scope": "True", + "has_per_asic_scope": "True", "set_owner": "local" }, { @@ -101,5 +101,21 @@ ] } } + }, + "FEATURE_WITH_INVALID_BOOLEAN_TYPE": { + "sonic-feature:sonic-feature": { + "sonic-feature:FEATURE": { + "FEATURE_LIST": [ + { + "name": "database", + "state": "always_enabled", + "auto_restart": "always_enabled", + "has_timer": "FALSE", + "has_global_scope": "TRUE", + "has_per_asic_scope": "TRUE" + } + ] + } + } } } \ No newline at end of file diff --git a/src/sonic-yang-models/yang-models/sonic-feature.yang b/src/sonic-yang-models/yang-models/sonic-feature.yang index b89aea0084..6240836e74 100644 --- a/src/sonic-yang-models/yang-models/sonic-feature.yang +++ b/src/sonic-yang-models/yang-models/sonic-feature.yang @@ -5,8 +5,12 @@ module sonic-feature{ namespace "http://github.com/Azure/sonic-feature"; prefix feature; + import sonic-types { + prefix stypes; + } + description "Feature Table yang Module for SONiC"; - + typedef feature-state { description "configuration to set the feature running state"; type string { @@ -53,22 +57,22 @@ module sonic-feature{ leaf has_timer { description "This configuration identicates if there is timer associated to this feature"; - type boolean; - default false; + type stypes:boolean_type; + default "false"; } leaf has_global_scope { description "This configuration identicates there will only one service spawned for the device"; - type boolean; - default false; + type stypes:boolean_type; + default "false"; } leaf has_per_asic_scope { description "This configuration identicates there will only one service spawned per asic"; - type boolean; - default false; + type stypes:boolean_type; + default "false"; } leaf high_mem_alert { diff --git a/src/sonic-yang-models/yang-models/sonic-flex_counter.yang b/src/sonic-yang-models/yang-models/sonic-flex_counter.yang index 5f92d66331..8e958af2f4 100644 --- a/src/sonic-yang-models/yang-models/sonic-flex_counter.yang +++ b/src/sonic-yang-models/yang-models/sonic-flex_counter.yang @@ -5,6 +5,10 @@ module sonic-flex_counter { namespace "http://github.com/Azure/sonic-flex_counter"; prefix flex_counter; + import sonic-types { + prefix stypes; + } + description "FLEX COUNTER YANG Module for SONiC OS"; revision 2020-04-10 { @@ -24,7 +28,7 @@ module sonic-flex_counter { } typedef flex_delay_status { - type boolean; + type stypes:boolean_type; } typedef poll_interval { diff --git a/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 b/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 index 8896a2312e..04aff692d6 100644 --- a/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 +++ b/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 @@ -217,6 +217,12 @@ module sonic-types { } } + typedef boolean_type { + type string { + pattern "false|true|False|True"; + } + } + typedef mac-addr-and-mask { type string { 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}";