From 3abd2167bca612422dba43fafadd590bbe6d434b Mon Sep 17 00:00:00 2001 From: Dmytro Shevchuk <68949102+dmytroxshevchuk@users.noreply.github.com> Date: Wed, 24 Feb 2021 20:48:43 +0200 Subject: [PATCH] [yang] update crm yang model for dynamic port breakout (#6395) - Why I did it Fix DPB crash caused of new entries in config db. Details: #6331 - How I did it Updated crm yang model --- .../tests/yang_model_tests/test_yang_model.py | 71 ++++++ .../tests/yang_model_tests/yangTest.json | 216 +++++++++++++++++- .../yang-models/sonic-crm.yang | 84 ++++++- 3 files changed, 356 insertions(+), 15 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py b/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py index adf643ad79..f492dbd286 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py +++ b/src/sonic-yang-models/tests/yang_model_tests/test_yang_model.py @@ -190,10 +190,18 @@ class Test_yang_models: about high threshold being lower than low threshold.', 'eStr': ['high_threshold should be more than low_threshold'] }, + 'CRM_WITH_CORRECT_FREE_VALUE': { + 'desc': 'CRM_WITH_CORRECT_FREE_VALUE no failure.', + 'eStr': self.defaultYANGFailure['None'] + }, 'CRM_WITH_CORRECT_USED_VALUE': { 'desc': 'CRM_WITH_CORRECT_USED_VALUE no failure.', 'eStr': self.defaultYANGFailure['None'] }, + 'CRM_WITH_WRONG_THRESHOLD_TYPE': { + 'desc': 'CRM_WITH_WRONG_THRESHOLD_TYPE pattern failure.', + 'eStr': self.defaultYANGFailure['Pattern'] + ['wrong'] + }, 'FLEX_COUNTER_TABLE_WITH_CORRECT_USED_VALUE': { 'desc': 'FLEX_COUNTER_TABLE_WITH_CORRECT_USED_VALUE no failure.', 'eStr': self.defaultYANGFailure['None'] @@ -241,6 +249,69 @@ class Test_yang_models: 'BREAKOUT_CFG_INCORRECT_MODES': { 'desc': 'BREAKOUT_CFG wrong breakout modes', 'eStr': self.defaultYANGFailure['Pattern'] + }, + 'SNAT_WITH_WRONG_PERCENTAGE': { + 'desc': 'SNAT_WITH_WRONG_PERCENTAGE must condition failure.', + 'eStr': self.defaultYANGFailure['Must'] + }, + 'SNAT_WITH_HIGH_THRESHOLD_ERR': { + 'desc': 'SNAT_WITH_HIGH_THRESHOLD_ERR must condition failure \ + about high threshold being lower than low threshold.', + 'eStr': ['high_threshold should be more than low_threshold'] + }, + 'SNAT_WITH_CORRECT_FREE_VALUE': { + 'desc': 'SNAT_WITH_CORRECT_FREE_VALUE no failure.', + 'eStr': self.defaultYANGFailure['None'] + }, + 'SNAT_WITH_CORRECT_USED_VALUE': { + 'desc': 'SNAT_WITH_CORRECT_USED_VALUE no failure.', + 'eStr': self.defaultYANGFailure['None'] + }, + 'SNAT_WITH_WRONG_THRESHOLD_TYPE': { + 'desc': 'SNAT_WITH_WRONG_THRESHOLD_TYPE pattern failure.', + 'eStr': self.defaultYANGFailure['Pattern'] + ['wrong'] + }, + 'DNAT_WITH_WRONG_PERCENTAGE': { + 'desc': 'DNAT_WITH_WRONG_PERCENTAGE must condition failure.', + 'eStr': self.defaultYANGFailure['Must'] + }, + 'DNAT_WITH_HIGH_THRESHOLD_ERR': { + 'desc': 'DNAT_WITH_HIGH_THRESHOLD_ERR must condition failure \ + about high threshold being lower than low threshold.', + 'eStr': ['high_threshold should be more than low_threshold'] + }, + 'DNAT_WITH_CORRECT_FREE_VALUE': { + 'desc': 'DNAT_WITH_CORRECT_FREE_VALUE no failure.', + 'eStr': self.defaultYANGFailure['None'] + }, + 'DNAT_WITH_CORRECT_USED_VALUE': { + 'desc': 'DNAT_WITH_CORRECT_USED_VALUE no failure.', + 'eStr': self.defaultYANGFailure['None'] + }, + 'DNAT_WITH_WRONG_THRESHOLD_TYPE': { + 'desc': 'DNAT_WITH_WRONG_THRESHOLD_TYPE pattern failure.', + 'eStr': self.defaultYANGFailure['Pattern'] + ['wrong'] + }, + 'IPMC_WITH_WRONG_PERCENTAGE': { + 'desc': 'IPMC_WITH_WRONG_PERCENTAGE must condition failure.', + 'eStr': self.defaultYANGFailure['Must'] + }, + 'IPMC_WITH_HIGH_THRESHOLD_ERR': { + 'desc': 'IPMC_WITH_HIGH_THRESHOLD_ERR must condition failure \ + about high threshold being lower than low threshold.', + 'eStr': ['high_threshold should be more than low_threshold'] + }, + 'IPMC_WITH_CORRECT_FREE_VALUE': { + 'desc': 'IPMC_WITH_CORRECT_FREE_VALUE no failure.', + 'eStr': self.defaultYANGFailure['None'] + }, + 'IPMC_WITH_CORRECT_USED_VALUE': { + 'desc': 'IPMC_WITH_CORRECT_USED_VALUE no failure.', + 'eStr': self.defaultYANGFailure['None'] + }, + 'IPMC_WITH_WRONG_THRESHOLD_TYPE': { + 'desc': 'IPMC_WITH_WRONG_THRESHOLD_TYPE pattern failure.', + 'eStr': self.defaultYANGFailure['Pattern'] + ['wrong'] } } diff --git a/src/sonic-yang-models/tests/yang_model_tests/yangTest.json b/src/sonic-yang-models/tests/yang_model_tests/yangTest.json index 92c841830d..44e74c1f2c 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/yangTest.json +++ b/src/sonic-yang-models/tests/yang_model_tests/yangTest.json @@ -814,12 +814,12 @@ } }, - "CRM_WITH_WRONG_THRESHOLD": { + "CRM_WITH_CORRECT_FREE_VALUE": { "sonic-crm:sonic-crm": { "sonic-crm:CRM": { "Config": { - "acl_counter_high_threshold": 85, - "acl_counter_low_threshold": 90, + "acl_counter_high_threshold": 90, + "acl_counter_low_threshold": 70, "acl_counter_threshold_type": "free" } } @@ -838,6 +838,198 @@ } }, + "CRM_WITH_WRONG_THRESHOLD_TYPE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "acl_counter_high_threshold": 90, + "acl_counter_low_threshold": 70, + "acl_counter_threshold_type": "wrong" + } + } + } + }, + + "SNAT_WITH_WRONG_PERCENTAGE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "snat_entry_high_threshold": 110, + "snat_entry_low_threshold": 85, + "snat_entry_threshold_type": "PERCENTAGE" + } + } + } + }, + + "SNAT_WITH_HIGH_THRESHOLD_ERR": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "snat_entry_high_threshold": 80, + "snat_entry_low_threshold": 81, + "snat_entry_threshold_type": "PERCENTAGE" + } + } + } + }, + + "SNAT_WITH_CORRECT_FREE_VALUE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "snat_entry_high_threshold": 90, + "snat_entry_low_threshold": 70, + "snat_entry_threshold_type": "free" + } + } + } + }, + + "SNAT_WITH_CORRECT_USED_VALUE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "snat_entry_high_threshold": 85, + "snat_entry_low_threshold": 25, + "snat_entry_threshold_type": "used" + } + } + } + }, + + "SNAT_WITH_WRONG_THRESHOLD_TYPE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "snat_entry_high_threshold": 90, + "snat_entry_low_threshold": 70, + "snat_entry_threshold_type": "wrong" + } + } + } + }, + + "DNAT_WITH_WRONG_PERCENTAGE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "dnat_entry_high_threshold": 110, + "dnat_entry_low_threshold": 85, + "dnat_entry_threshold_type": "PERCENTAGE" + } + } + } + }, + + "DNAT_WITH_HIGH_THRESHOLD_ERR": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "dnat_entry_high_threshold": 80, + "dnat_entry_low_threshold": 81, + "dnat_entry_threshold_type": "PERCENTAGE" + } + } + } + }, + + "DNAT_WITH_CORRECT_FREE_VALUE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "dnat_entry_high_threshold": 90, + "dnat_entry_low_threshold": 70, + "dnat_entry_threshold_type": "free" + } + } + } + }, + + "DNAT_WITH_CORRECT_USED_VALUE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "dnat_entry_high_threshold": 85, + "dnat_entry_low_threshold": 25, + "dnat_entry_threshold_type": "used" + } + } + } + }, + + "DNAT_WITH_WRONG_THRESHOLD_TYPE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "dnat_entry_high_threshold": 90, + "dnat_entry_low_threshold": 70, + "dnat_entry_threshold_type": "wrong" + } + } + } + }, + + "IPMC_WITH_WRONG_PERCENTAGE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "ipmc_entry_high_threshold": 110, + "ipmc_entry_low_threshold": 85, + "ipmc_entry_threshold_type": "PERCENTAGE" + } + } + } + }, + + "IPMC_WITH_HIGH_THRESHOLD_ERR": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "ipmc_entry_high_threshold": 80, + "ipmc_entry_low_threshold": 81, + "ipmc_entry_threshold_type": "PERCENTAGE" + } + } + } + }, + + "IPMC_WITH_CORRECT_FREE_VALUE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "ipmc_entry_high_threshold": 90, + "ipmc_entry_low_threshold": 70, + "ipmc_entry_threshold_type": "free" + } + } + } + }, + + "IPMC_WITH_CORRECT_USED_VALUE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "ipmc_entry_high_threshold": 85, + "ipmc_entry_low_threshold": 25, + "ipmc_entry_threshold_type": "used" + } + } + } + }, + + "IPMC_WITH_WRONG_THRESHOLD_TYPE": { + "sonic-crm:sonic-crm": { + "sonic-crm:CRM": { + "Config": { + "ipmc_entry_high_threshold": 90, + "ipmc_entry_low_threshold": 70, + "ipmc_entry_threshold_type": "wrong" + } + } + } + }, + "DEVICE_METADATA_DEFAULT_BGP_STATUS": { "sonic-device_metadata:sonic-device_metadata": { "sonic-device_metadata:DEVICE_METADATA": { @@ -953,6 +1145,15 @@ "nexthop_group_high_threshold": "67", "nexthop_group_low_threshold": "56", "nexthop_group_threshold_type": "percentage", + "snat_entry_threshold_type": "percentage", + "snat_entry_low_threshold": "70", + "snat_entry_high_threshold": "85", + "dnat_entry_threshold_type": "percentage", + "dnat_entry_low_threshold": "70", + "dnat_entry_high_threshold": "85", + "ipmc_entry_threshold_type": "percentage", + "ipmc_entry_low_threshold": "70", + "ipmc_entry_high_threshold": "85", "polling_interval": "0" } } @@ -1743,6 +1944,15 @@ "nexthop_group_high_threshold": "67", "nexthop_group_low_threshold": "56", "nexthop_group_threshold_type": "percentage", + "snat_entry_threshold_type": "percentage", + "snat_entry_low_threshold": "70", + "snat_entry_high_threshold": "85", + "dnat_entry_threshold_type": "percentage", + "dnat_entry_low_threshold": "70", + "dnat_entry_high_threshold": "85", + "ipmc_entry_threshold_type": "percentage", + "ipmc_entry_low_threshold": "70", + "ipmc_entry_high_threshold": "85", "polling_interval": "0" } } diff --git a/src/sonic-yang-models/yang-models/sonic-crm.yang b/src/sonic-yang-models/yang-models/sonic-crm.yang index cc53aa7f0d..29161958e4 100644 --- a/src/sonic-yang-models/yang-models/sonic-crm.yang +++ b/src/sonic-yang-models/yang-models/sonic-crm.yang @@ -60,7 +60,7 @@ module sonic-crm { leaf acl_group_high_threshold { must "(current() > ../acl_group_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -80,7 +80,7 @@ module sonic-crm { leaf acl_entry_high_threshold { must "(current() > ../acl_entry_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -100,7 +100,7 @@ module sonic-crm { leaf acl_table_high_threshold { must "(current() > ../acl_table_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -120,7 +120,7 @@ module sonic-crm { leaf fdb_entry_high_threshold { must "(current() > ../fdb_entry_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -140,7 +140,7 @@ module sonic-crm { leaf ipv4_neighbor_high_threshold { must "(current() > ../ipv4_neighbor_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -160,7 +160,7 @@ module sonic-crm { leaf ipv4_nexthop_high_threshold { must "(current() > ../ipv4_nexthop_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -180,7 +180,7 @@ module sonic-crm { leaf ipv4_route_high_threshold { must "(current() > ../ipv4_route_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -200,7 +200,7 @@ module sonic-crm { leaf ipv6_neighbor_high_threshold { must "(current() > ../ipv6_neighbor_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -220,7 +220,7 @@ module sonic-crm { leaf ipv6_nexthop_high_threshold { must "(current() > ../ipv6_nexthop_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -240,7 +240,7 @@ module sonic-crm { leaf ipv6_route_high_threshold { must "(current() > ../ipv6_route_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -260,7 +260,7 @@ module sonic-crm { leaf nexthop_group_high_threshold { must "(current() > ../nexthop_group_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -280,7 +280,7 @@ module sonic-crm { leaf nexthop_group_member_high_threshold { must "(current() > ../nexthop_group_member_low_threshold)" { - error-message "high_threshold should be more that low_threshold"; + error-message "high_threshold should be more than low_threshold"; } type threshold; } @@ -293,6 +293,66 @@ module sonic-crm { type threshold; } + leaf dnat_entry_threshold_type { + must "(((current()='PERCENTAGE' or current()='percentage') and + ../dnat_entry_high_threshold<100 and + ../dnat_entry_low_threshold<100) or + (current()!='PERCENTAGE' and current()!='percentage'))"; + type stypes:crm_threshold_type; + } + + leaf dnat_entry_high_threshold { + must "(current() > ../dnat_entry_low_threshold)" + { + error-message "high_threshold should be more than low_threshold"; + } + type threshold; + } + + leaf dnat_entry_low_threshold { + type threshold; + } + + leaf snat_entry_threshold_type { + must "(((current()='PERCENTAGE' or current()='percentage') and + ../snat_entry_high_threshold<100 and + ../snat_entry_low_threshold<100) or + (current()!='PERCENTAGE' and current()!='percentage'))"; + type stypes:crm_threshold_type; + } + + leaf snat_entry_high_threshold { + must "(current() > ../snat_entry_low_threshold)" + { + error-message "high_threshold should be more than low_threshold"; + } + type threshold; + } + + leaf snat_entry_low_threshold { + type threshold; + } + + leaf ipmc_entry_threshold_type { + must "(((current()='PERCENTAGE' or current()='percentage') and + ../ipmc_entry_high_threshold<100 and + ../ipmc_entry_low_threshold<100) or + (current()!='PERCENTAGE' and current()!='percentage'))"; + type stypes:crm_threshold_type; + } + + leaf ipmc_entry_high_threshold { + must "(current() > ../ipmc_entry_low_threshold)" + { + error-message "high_threshold should be more than low_threshold"; + } + type threshold; + } + + leaf ipmc_entry_low_threshold { + type threshold; + } + } /* end of Config */ }