diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 8c19b719e34d..6a84d105dad2 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -73,6 +73,7 @@ './yang-models/sonic-versions.yang', './yang-models/sonic-vlan.yang', './yang-models/sonic-vrf.yang', + './yang-models/sonic-warm-restart.yang', './yang-models/sonic-lldp.yang', './yang-models/sonic_yang_tree']), ], 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 0778a7a87ad6..18ead92d29de 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -879,6 +879,13 @@ "polling_interval": "0" } }, + + "WARM_RESTART": { + "bgp": { + "bgp_timer": "500" + } + }, + "PFC_WD": { "Ethernet9": { "action": "drop", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/warm_restart.json b/src/sonic-yang-models/tests/yang_model_tests/tests/warm_restart.json new file mode 100644 index 000000000000..2abc88944e47 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/warm_restart.json @@ -0,0 +1,33 @@ +{ + "WARM_RESTART_TEST": { + "desc": "Configure an entry in WARM_RESTART table." + }, + "WARM_RESTART_WITH_MUST_CONDITION_FAILURE_TEST_FOR_BGP_EOIU": { + "desc": "Configuration of bgp eoiu with incorrect module name.", + "eStr" : ["bgp_eoiu is only supported for module bgp"] + }, + "WARM_RESTART_WITH_MUST_CONDITION_FAILURE_TEST_FOR_BGP_TIMER": { + "desc": "Configuration of bgp timer with incorrect module name.", + "eStr" : ["bgp_timer is only supported for module bgp"] + }, + "WARM_RESTART_WITH_MUST_CONDITION_FAILURE_TEST_FOR_TEAMSYNCD_TIMER": { + "desc": "Configuration of teamsyncd timer with incorrect module name.", + "eStr" : ["teamsyncd_timer is only supported for module teamd"] + }, + "WARM_RESTART_WITH_MUST_CONDITION_FAILURE_TEST_FOR_NEIGHSYNCD_TIMER": { + "desc": "Configuration of neighsyncd timer with incorrect module name.", + "eStr" : ["neighsyncd_timer is only supported for module swss"] + }, + "WARM_RESTART_TEST_WITH_INCORRECT_BGP_TIMER": { + "desc": "Configure Warm restart for bgp module with an out of range bgp timer.", + "eStr": ["Timer must be 1..3600"] + }, + "WARM_RESTART_TEST_WITH_INCORRECT_TEAMSYNCD_TIMER": { + "desc": "Configure Warm restart for teamsyncd module with an out of range teamsyncd timer.", + "eStr": ["Timer must be 1..3600"] + }, + "WARM_RESTART_TEST_WITH_INCORRECT_NEIGHSYNCD_TIMER": { + "desc": "Configure Warm restart for neighsyncd module with an out of range neighsyncd timer.", + "eStr": ["Timer must be 1..9999"] + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/warm_restart.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/warm_restart.json new file mode 100644 index 000000000000..970767e00feb --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/warm_restart.json @@ -0,0 +1,92 @@ +{ + "WARM_RESTART_TEST": { + "sonic-warm-restart:sonic-warm-restart": { + "sonic-warm-restart:WARM_RESTART": { + "WARM_RESTART_LIST": [{ + "module": "bgp", + "bgp_eoiu": true, + "bgp_timer": 500 + }] + } + } + }, + + "WARM_RESTART_WITH_MUST_CONDITION_FAILURE_TEST_FOR_BGP_EOIU": { + "sonic-warm-restart:sonic-warm-restart": { + "sonic-warm-restart:WARM_RESTART": { + "WARM_RESTART_LIST": [{ + "module": "teamd", + "bgp_eoiu": true + }] + } + } + }, + + "WARM_RESTART_WITH_MUST_CONDITION_FAILURE_TEST_FOR_BGP_TIMER": { + "sonic-warm-restart:sonic-warm-restart": { + "sonic-warm-restart:WARM_RESTART": { + "WARM_RESTART_LIST": [{ + "module": "teamd", + "bgp_timer": 500 + }] + } + } + }, + + "WARM_RESTART_WITH_MUST_CONDITION_FAILURE_TEST_FOR_TEAMSYNCD_TIMER": { + "sonic-warm-restart:sonic-warm-restart": { + "sonic-warm-restart:WARM_RESTART": { + "WARM_RESTART_LIST": [{ + "module": "bgp", + "teamsyncd_timer": 500 + }] + } + } + }, + + "WARM_RESTART_WITH_MUST_CONDITION_FAILURE_TEST_FOR_NEIGHSYNCD_TIMER": { + "sonic-warm-restart:sonic-warm-restart": { + "sonic-warm-restart:WARM_RESTART": { + "WARM_RESTART_LIST": [{ + "module": "bgp", + "neighsyncd_timer": 500 + }] + } + } + }, + + "WARM_RESTART_TEST_WITH_INCORRECT_BGP_TIMER": { + "sonic-warm-restart:sonic-warm-restart": { + "sonic-warm-restart:WARM_RESTART": { + "WARM_RESTART_LIST": [{ + "module": "bgp", + "bgp_timer": 3601 + }] + } + } + }, + + "WARM_RESTART_TEST_WITH_INCORRECT_TEAMSYNCD_TIMER": { + "sonic-warm-restart:sonic-warm-restart": { + "sonic-warm-restart:WARM_RESTART": { + "WARM_RESTART_LIST": [{ + "module": "teamd", + "teamsyncd_timer": 3601 + }] + } + } + }, + + "WARM_RESTART_TEST_WITH_INCORRECT_NEIGHSYNCD_TIMER": { + "sonic-warm-restart:sonic-warm-restart": { + "sonic-warm-restart:WARM_RESTART": { + "WARM_RESTART_LIST": [{ + "module": "swss", + "neighsyncd_timer": 0 + }] + } + } + } + +} + diff --git a/src/sonic-yang-models/yang-models/sonic-warm-restart.yang b/src/sonic-yang-models/yang-models/sonic-warm-restart.yang new file mode 100644 index 000000000000..8366016746ad --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-warm-restart.yang @@ -0,0 +1,105 @@ +module sonic-warm-restart { + + yang-version 1.1; + + namespace "http://github.com/Azure/sonic-warm-restart"; + prefix wrm; + + description "SONIC WARMRESTART"; + + revision 2021-05-24 { + description "First Revision"; + } + + typedef module-name { + + type enumeration { + + enum bgp { + description + "BGP module"; + } + + enum teamd { + description + "Teamd module"; + } + + enum swss { + description + "Switch State Services module"; + } + + enum system { + description + "Warm Restart on a System level."; + } + + } + + description + "The modules supported in warm-restart"; + } + + + container sonic-warm-restart { + container WARM_RESTART { + + list WARM_RESTART_LIST { + key "module"; + + leaf module { + type module-name; + description + "Name of the module"; + } + + leaf bgp_eoiu { + type boolean; + must "current()/../module = 'bgp'" { error-message "bgp_eoiu is only supported for module bgp."; } + description + "BGP End-of-Initial Update (EOIU) signal enable/disable"; + } + + leaf bgp_timer { + type uint16 { + range "1..3600" { + error-message "Timer must be 1..3600"; + error-app-tag timer-invalid; + } + } + must "current()/../module = 'bgp'" { error-message "bgp_timer is only supported for module bgp."; } + description + "Timer value for BGP module"; + } + + leaf teamsyncd_timer { + type uint16 { + range "1..3600" { + error-message "Timer must be 1..3600"; + error-app-tag timer-invalid; + } + } + must "current()/../module = 'teamd'" { error-message "teamsyncd_timer is only supported for module teamd."; } + description + "Timer value for teamd module"; + } + + leaf neighsyncd_timer { + type uint16 { + range "1..9999" { + error-message "Timer must be 1..9999"; + error-app-tag timer-invalid; + } + } + must "current()/../module = 'swss'" { error-message "neighsyncd_timer is only supported for module swss."; } + description + "Timer value for swss module"; + } + + } /* end of list WARM_RESTART_LIST */ + } /* end of container WARM_RESTART */ + } /* end of container sonic-warm-restart */ + + +} /* end of module sonic-warm-restart */