From 771a0d0fbc36131f2ad099976363d2a96366f58c Mon Sep 17 00:00:00 2001 From: jfeng-arista <98421150+jfeng-arista@users.noreply.github.com> Date: Mon, 15 May 2023 13:20:23 -0700 Subject: [PATCH] YANG model for FABRIC_MONITOR|FABRIC_MONITOR_DATA (#14390) #### Why I did it Table FABRIC_MONITOR|FABRIC_MONITOR_DATA in CONFIG_DB was added in https://github.com/sonic-net/sonic-buildimage/pull/14170 The YANG model for that table is still missing. Need to wait https://github.com/sonic-net/sonic-buildimage/pull/14170 get merged first. #### How I did it Added new YANG model FABRIC_MONITOR and associated unit tests. #### How to verify it Passing unit tests --- .../tests/test_cfggen_from_yang.py | 12 +++++ .../tests/test_yang_data.json | 10 ++++ src/sonic-yang-models/doc/Configuration.md | 16 ++++++ src/sonic-yang-models/setup.py | 2 + .../tests/files/sample_config_db.json | 8 +++ .../tests/fabric_monitor_data.json | 5 ++ .../tests_config/fabric_monitor_data.json | 14 +++++ .../yang-models/sonic-fabric-monitor.yang | 53 +++++++++++++++++++ 8 files changed, 120 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/fabric_monitor_data.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/fabric_monitor_data.json create mode 100644 src/sonic-yang-models/yang-models/sonic-fabric-monitor.yang diff --git a/src/sonic-config-engine/tests/test_cfggen_from_yang.py b/src/sonic-config-engine/tests/test_cfggen_from_yang.py index ddc77c8b0311..4f4cdb841465 100644 --- a/src/sonic-config-engine/tests/test_cfggen_from_yang.py +++ b/src/sonic-config-engine/tests/test_cfggen_from_yang.py @@ -264,3 +264,15 @@ def test_vlan_crm(self): "ipv6_neighbor_threshold_type": "used" } }) + + def test_fabric_monitor_data_table(self): + arg = ["--var-json", "FABRIC_MONITOR"] + output = json.loads(self.run_script_with_yang_arg(arg)) + assert(output == {\ + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": "1", + "monErrThreshRxCells": "61035156", + "monPollThreshIsolation": "1", + "monPollThreshRecovery": "8" + } + }) diff --git a/src/sonic-config-engine/tests/test_yang_data.json b/src/sonic-config-engine/tests/test_yang_data.json index 69c8125f7837..51a1c6a94590 100644 --- a/src/sonic-config-engine/tests/test_yang_data.json +++ b/src/sonic-config-engine/tests/test_yang_data.json @@ -378,5 +378,15 @@ "ipv6_neighbor_threshold_type": "used" } } + }, + "sonic-fabric-monitor:sonic-fabric-monitor": { + "sonic-fabric-monitor:FABRIC_MONITOR": { + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": "1", + "monErrThreshRxCells": "61035156", + "monPollThreshIsolation": "1", + "monPollThreshRecovery": "8" + } + } } } diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index c5d74a1d3d2c..eccf550ecef9 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -33,6 +33,7 @@ Table of Contents * [FG_NHG](#fg_nhg) * [FG_NHG_MEMBER](#fg_nhg_member) * [FG_NHG_PREFIX](#fg_nhg_prefix) + * [FABRIC_MONITOR](#fabric-monitor) * [FLEX_COUNTER_TABLE](#flex_counter_table) * [Hash](#hash) * [IPv6 Link-local] (#ipv6-link-local) @@ -1043,6 +1044,21 @@ The FG_NHG_PREFIX table provides the FG_NHG_PREFIX for which FG behavior is desi } ``` +### FABRIC_MONITOR +``` +{ +"FABRIC_MONITOR": { + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": "1", + "monErrThreshRxCells": "61035156", + "monPollThreshIsolation": "1", + "monPollThreshRecovery": "8" + } + } +} + +``` + ### MPLS_TC_TO_TC_MAP ``` diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index e4e4fe0ac17b..4369b5b1d335 100644 --- a/src/sonic-yang-models/setup.py +++ b/src/sonic-yang-models/setup.py @@ -116,6 +116,7 @@ def run(self): './yang-models/sonic-events-swss.yang', './yang-models/sonic-events-syncd.yang', './yang-models/sonic-extension.yang', + './yang-models/sonic-fabric-monitor.yang', './yang-models/sonic-flex_counter.yang', './yang-models/sonic-fine-grained-ecmp.yang', './yang-models/sonic-feature.yang', @@ -205,6 +206,7 @@ def run(self): './cvlyang-models/sonic-events-syncd.yang', './cvlyang-models/sonic-device_neighbor_metadata.yang', './cvlyang-models/sonic-extension.yang', + './cvlyang-models/sonic-fabric-monitor.yang', './cvlyang-models/sonic-flex_counter.yang', './cvlyang-models/sonic-feature.yang', './cvlyang-models/sonic-fine-grained-ecmp.yang', 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 b7696bf68a85..c9d3cfec61b8 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1263,6 +1263,14 @@ "allow_insecure": "false" } }, + "FABRIC_MONITOR": { + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": "1", + "monErrThreshRxCells": "61035156", + "monPollThreshIsolation": "1", + "monPollThreshRecovery": "8" + } + }, "FLEX_COUNTER_TABLE": { "PFCWD": { "FLEX_COUNTER_STATUS": "enable" diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/fabric_monitor_data.json b/src/sonic-yang-models/tests/yang_model_tests/tests/fabric_monitor_data.json new file mode 100644 index 000000000000..0bff2427c971 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/fabric_monitor_data.json @@ -0,0 +1,5 @@ +{ + "FABRIC_MONITOR_POSITIVE_CONFIG": { + "desc": "Configure FABRIC_MONITOR_DATA no failure." + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fabric_monitor_data.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fabric_monitor_data.json new file mode 100644 index 000000000000..ad71aabd9c4c --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fabric_monitor_data.json @@ -0,0 +1,14 @@ +{ + "FABRIC_MONITOR_POSITIVE_CONFIG": { + "sonic-fabric-monitor:sonic-fabric-monitor": { + "sonic-fabric-monitor:FABRIC_MONITOR": { + "FABRIC_MONITOR_DATA": { + "monErrThreshCrcCells": "1", + "monErrThreshRxCells": "61035156", + "monPollThreshIsolation": "1", + "monPollThreshRecovery": "8" + } + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-fabric-monitor.yang b/src/sonic-yang-models/yang-models/sonic-fabric-monitor.yang new file mode 100644 index 000000000000..0c0464ab965d --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-fabric-monitor.yang @@ -0,0 +1,53 @@ +module sonic-fabric-monitor{ + + yang-version 1.1; + + namespace "http://github.com/sonic-net/sonic-fabric-monitor"; + prefix fabric-monitor; + + description "FABRIC_MONITOR yang Module for SONiC OS"; + + revision 2023-03-14 { + description "First Revision"; + } + + container sonic-fabric-monitor { + + container FABRIC_MONITOR { + + description "FABRIC_MONITOR part of config_db.json"; + + container FABRIC_MONITOR_DATA { + + leaf monErrThreshCrcCells { + type uint32; + default 1; + description "The number of cells with errors."; + } + + leaf monErrThreshRxCells { + type uint32; + default 61035156; + description "The number of cells received. If more than monErrThreshCrcCells out of monErrThreshRxCells seen with errors, the fabric port needs to be isolated"; + } + + leaf monPollThreshIsolation { + type uint32; + default 1; + description "Consecutive polls with higher error rate for isolation."; + } + + leaf monPollThreshRecovery { + type uint32; + default 8; + description "Consecutive polls with lesser error rate for inclusion."; + } + + } /* end of container FABRIC_MONITOR_DATA */ + + } /* end of container FABRIC_MONITOR */ + + } /* end of container sonic-fabric-monitor */ + +} /* end of module sonic-fabric-monitor */ +