From 64c0fdb6fb7807a98480e31ae8b7d93c9ad7957f Mon Sep 17 00:00:00 2001 From: Jie Feng Date: Thu, 16 Mar 2023 15:54:01 -0700 Subject: [PATCH 1/3] Add YANG model for FABRIC_PORT --- .../tests/test_cfggen_from_yang.py | 11 ++++ .../tests/test_yang_data.json | 12 +++++ src/sonic-yang-models/doc/Configuration.md | 21 ++++++++ src/sonic-yang-models/setup.py | 2 + .../tests/files/sample_config_db.json | 12 +++++ .../yang_model_tests/tests/fabric_port.json | 5 ++ .../tests_config/fabric_port.json | 16 ++++++ .../yang-models/sonic-fabric-port.yang | 54 +++++++++++++++++++ 8 files changed, 133 insertions(+) create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests/fabric_port.json create mode 100644 src/sonic-yang-models/tests/yang_model_tests/tests_config/fabric_port.json create mode 100644 src/sonic-yang-models/yang-models/sonic-fabric-port.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 ddc77c8b031..0d4336439b2 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,14 @@ def test_vlan_crm(self): "ipv6_neighbor_threshold_type": "used" } }) + + def test_fabric_port_table(self): + arg = ["--var-json", "FABRIC_PORT"] + output = json.loads(self.run_script_with_yang_arg(arg)) + assert(output == {\ + "Fabric0": { + "alias": "Fabric0", + "isolateStatus": "False", + "lanes": "0" + } + }) diff --git a/src/sonic-config-engine/tests/test_yang_data.json b/src/sonic-config-engine/tests/test_yang_data.json index 69c8125f783..345762e40ed 100644 --- a/src/sonic-config-engine/tests/test_yang_data.json +++ b/src/sonic-config-engine/tests/test_yang_data.json @@ -378,5 +378,17 @@ "ipv6_neighbor_threshold_type": "used" } } + }, + "sonic-fabric-port:sonic-fabric-port": { + "sonic-fabric-port:FABRIC_PORT": { + "FABRIC_PORT_LIST": [ + { + "name": "Fabric0", + "alias": "Fabric0", + "isolateStatus": "False", + "lanes": "0" + } + ] + } } } diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 3b8def2fdbc..63fda57a9c9 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -29,6 +29,7 @@ Table of Contents * [Device neighbor metada](#device-neighbor-metada) * [DHCP_RELAY](#dhcp_relay) * [DSCP_TO_TC_MAP](#dscp_to_tc_map) + * [FABRIC_PORT](#fabric-port) * [FG_NHG](#fg_nhg) * [FG_NHG_MEMBER](#fg_nhg_member) * [FG_NHG_PREFIX](#fg_nhg_prefix) @@ -985,6 +986,26 @@ The FG_NHG_PREFIX table provides the FG_NHG_PREFIX for which FG behavior is desi ``` +### FABRIC_PORT +``` +{ +"FABRIC_PORT": { + "Fabric0": { + "alias": "Fabric0", + "isolateStatus": "False", + "lanes": "0" + }, + "Fabric1": { + "alias": "Fabric1", + "isolateStatus": "False", + "lanes": "1" + } + } +} + +``` + + ### MPLS_TC_TO_TC_MAP ``` { diff --git a/src/sonic-yang-models/setup.py b/src/sonic-yang-models/setup.py index 0416794925b..44dc06790b1 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-port.yang', './yang-models/sonic-flex_counter.yang', './yang-models/sonic-fine-grained-ecmp.yang', './yang-models/sonic-feature.yang', @@ -204,6 +205,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-port.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 977be6ded22..818eadb52b5 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -1260,6 +1260,18 @@ "allow_insecure": "false" } }, + "FABRIC_PORT": { + "Fabric0": { + "alias": "Fabric0", + "isolateStatus": "False", + "lanes": "0" + }, + "Fabric1": { + "alias": "Fabric1", + "isolateStatus": "False", + "lanes": "1" + } + }, "FLEX_COUNTER_TABLE": { "PFCWD": { "FLEX_COUNTER_STATUS": "enable" diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/fabric_port.json b/src/sonic-yang-models/tests/yang_model_tests/tests/fabric_port.json new file mode 100644 index 00000000000..8c8db3ca165 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/fabric_port.json @@ -0,0 +1,5 @@ +{ + "FABRIC_PORT_POSITIVE_CONFIG": { + "desc": "Configure FABRIC_PORT no failure." + } +} diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/fabric_port.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fabric_port.json new file mode 100644 index 00000000000..27883482612 --- /dev/null +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/fabric_port.json @@ -0,0 +1,16 @@ +{ + "FABRIC_PORT_POSITIVE_CONFIG": { + "sonic-fabric-port:sonic-fabric-port": { + "sonic-fabric-port:FABRIC_PORT": { + "FABRIC_PORT_LIST": [ + { + "name": "Fabric0", + "alias": "Fabric0", + "isolateStatus": "False", + "lanes": "0" + } + ] + } + } + } +} diff --git a/src/sonic-yang-models/yang-models/sonic-fabric-port.yang b/src/sonic-yang-models/yang-models/sonic-fabric-port.yang new file mode 100644 index 00000000000..edf16b5d658 --- /dev/null +++ b/src/sonic-yang-models/yang-models/sonic-fabric-port.yang @@ -0,0 +1,54 @@ +module sonic-fabric-port{ + + yang-version 1.1; + + namespace "http://github.com/sonic-net/sonic-fabric-port"; + prefix fabric-port; + + description "FABRIC_PORT yang Module for SONiC OS"; + + revision 2023-03-14 { + description "First Revision"; + } + + container sonic-fabric-port { + + container FABRIC_PORT { + + description "FABRIC_PORT part of config_db.json"; + + list FABRIC_PORT_LIST { + + key "name"; + + leaf name { + type string { + length 1..128; + } + } + + leaf isolateStatus { + type string { + pattern "False|True"; + } + } + + leaf alias { + type string { + length 1..128; + } + } + + leaf lanes { + type string { + length 1..128; + } + } + + } /* end of list FABRIC_PORT_LIST */ + + } /* end of container FABRIC_PORT */ + + } /* end of container sonic-fabric-port */ + +} /* end of module sonic-fabric-port */ From 33067255fe0f5ff690e5cc66e1ac950e31409813 Mon Sep 17 00:00:00 2001 From: Jie Feng Date: Wed, 19 Apr 2023 09:32:23 -0700 Subject: [PATCH 2/3] Added default value for isolateStatus, add mandatory for lanes field. --- src/sonic-yang-models/yang-models/sonic-fabric-port.yang | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/sonic-yang-models/yang-models/sonic-fabric-port.yang b/src/sonic-yang-models/yang-models/sonic-fabric-port.yang index edf16b5d658..2c69a357889 100644 --- a/src/sonic-yang-models/yang-models/sonic-fabric-port.yang +++ b/src/sonic-yang-models/yang-models/sonic-fabric-port.yang @@ -31,6 +31,7 @@ module sonic-fabric-port{ type string { pattern "False|True"; } + default "False"; } leaf alias { @@ -40,6 +41,7 @@ module sonic-fabric-port{ } leaf lanes { + mandatory true; type string { length 1..128; } From a392aa155d83e17810f67c9334e53a2002b203ff Mon Sep 17 00:00:00 2001 From: Jie Feng Date: Fri, 21 Apr 2023 20:50:39 -0700 Subject: [PATCH 3/3] Add description to the leaf nodes. --- src/sonic-yang-models/yang-models/sonic-fabric-port.yang | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sonic-yang-models/yang-models/sonic-fabric-port.yang b/src/sonic-yang-models/yang-models/sonic-fabric-port.yang index 2c69a357889..d9a00ca335d 100644 --- a/src/sonic-yang-models/yang-models/sonic-fabric-port.yang +++ b/src/sonic-yang-models/yang-models/sonic-fabric-port.yang @@ -28,6 +28,7 @@ module sonic-fabric-port{ } leaf isolateStatus { + description "Isolation status of a fabric port"; type string { pattern "False|True"; } @@ -35,12 +36,14 @@ module sonic-fabric-port{ } leaf alias { + description "Alias of a fabric port"; type string { length 1..128; } } leaf lanes { + description "Lanes of a fabric port"; mandatory true; type string { length 1..128;