From edd094593cfc07db6710176b63195d887a1f0ad8 Mon Sep 17 00:00:00 2001 From: zitingguo-ms Date: Tue, 28 Nov 2023 10:06:37 +0800 Subject: [PATCH] Fix device type and add cluster in DEVICE_NEIGHBOR_METADATA yang model (#17049) (#17251) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Why I did it The current DEVICE_NEIGHBOR_METADATA yang model has two issues that would block GCU operation when it checks if the current config aligns with the YANG model: Missing cluster field in YANG Incomplete set of device type. The device type in YANG model doesn't include all the device type. Work item tracking Microsoft ADO (number only): 25577813 How I did it Add cluster field in DEVICE_NEIGHBOR_METADATA YANG model. Change device type to string. Fix the UT test accordingly. How to verify it Build the image and verify the unit tests passed. Signed-off-by: zitingguo-ms --- .../tests/simple-sample-graph-case.xml | 4 +- .../tests/test_minigraph_case.py | 4 +- src/sonic-yang-models/doc/Configuration.md | 2 + .../tests/device_neighbor_metadata.json | 11 ----- .../device_neighbor_metadata.json | 47 ++++--------------- .../sonic-device_neighbor_metadata.yang | 9 ++-- 6 files changed, 22 insertions(+), 55 deletions(-) diff --git a/src/sonic-config-engine/tests/simple-sample-graph-case.xml b/src/sonic-config-engine/tests/simple-sample-graph-case.xml index aaade89d5d49..cfcb8559ef2f 100644 --- a/src/sonic-config-engine/tests/simple-sample-graph-case.xml +++ b/src/sonic-config-engine/tests/simple-sample-graph-case.xml @@ -348,6 +348,7 @@ 10.7.0.196/26 switch2-t0 + DB5PrdApp11 Force10-S6000 @@ -359,7 +360,8 @@ 10.7.0.196/26 - + + DB5PrdApp11 Force10-S6000 diff --git a/src/sonic-config-engine/tests/test_minigraph_case.py b/src/sonic-config-engine/tests/test_minigraph_case.py index 92834ee36f99..6fb4d5f89ac8 100644 --- a/src/sonic-config-engine/tests/test_minigraph_case.py +++ b/src/sonic-config-engine/tests/test_minigraph_case.py @@ -209,6 +209,7 @@ def test_minigraph_neighbor_metadata(self): expected_table = { 'switch2-t0': { + 'cluster': 'DB5PrdApp11', 'lo_addr': '25.1.1.10/32', 'mgmt_addr': '10.7.0.196/26', 'hwsku': 'Force10-S6000', @@ -228,7 +229,8 @@ def test_minigraph_neighbor_metadata(self): 'hwsku': 'server-sku', 'type': 'Server' }, - 'switch-01t1': { + 'switch-01t1': { + 'cluster': 'DB5PrdApp11', 'lo_addr': '10.1.0.186/32', 'deployment_id': '2', 'hwsku': 'Force10-S6000', diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index bd29c94fc5e2..a5db1b0b1929 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -842,12 +842,14 @@ instance is supported in SONiC. { "DEVICE_NEIGHBOR_METADATA": { "ARISTA01T1": { + "cluster": "AAA00PrdStr00", "lo_addr": "None", "mgmt_addr": "10.11.150.45", "hwsku": "Arista-VM", "type": "LeafRouter" }, "ARISTA02T1": { + "cluster": "AAA00PrdStr00", "lo_addr": "None", "mgmt_addr": "10.11.150.46", "hwsku": "Arista-VM", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/device_neighbor_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests/device_neighbor_metadata.json index 404856159a44..b8e62bff7fd3 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/device_neighbor_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/device_neighbor_metadata.json @@ -2,17 +2,6 @@ "DEVICE_NEIGHBOR_METADATA_TABLE": { "desc": "DEVICE_NEIGHBOR_METADATA_TABLE config pattern." }, - "DEVICE_NEIGHBOR_METADATA_TYPE_INCORRECT_PATTERN": { - "desc": "DEVICE_NEIGHBOR_METADATA_TYPE_INCORRECT_PATTERN pattern failure.", - "eStrKey" : "Pattern" - }, - "DEVICE_NEIGHBOR_METADATA_TYPE_CORRECT_PATTERN": { - "desc": "DEVICE_NEIGHBOR_METADATA correct value for Type field" - }, - "DEVICE_NEIGHBOR_METADATA_TYPE_INCORRECT_PATTERN_BMC": { - "desc": "DEVICE_NEIGHBOR_METADATA_TYPE_INCORRECT_PATTERN pattern failure with IncorrectTypeBmc.", - "eStrKey" : "Pattern" - }, "DEVICE_NEIGHBOR_METADATA_TYPE_CORRECT_PATTERN_BMC": { "desc": "DEVICE_NEIGHBOR_METADATA correct value for type field for Bmc" }, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_neighbor_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_neighbor_metadata.json index 82faf0815f56..8c5388d2043c 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_neighbor_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_neighbor_metadata.json @@ -1,43 +1,4 @@ { - "DEVICE_NEIGHBOR_METADATA_TYPE_INCORRECT_PATTERN": { - "sonic-device_neighbor_metadata:sonic-device_neighbor_metadata": { - "sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": { - "DEVICE_NEIGHBOR_METADATA_LIST": [ - { - "name": "Ethernet116", - "hwsku": "Arista", - "type": "ToRrouter" - } - ] - } - } - }, - "DEVICE_NEIGHBOR_METADATA_TYPE_CORRECT_PATTERN": { - "sonic-device_neighbor_metadata:sonic-device_neighbor_metadata": { - "sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": { - "DEVICE_NEIGHBOR_METADATA_LIST": [ - { - "name": "Ethernet116", - "hwsku": "Arista", - "type": "BackEndToRRouter" - } - ] - } - } - }, - "DEVICE_NEIGHBOR_METADATA_TYPE_INCORRECT_PATTERN_BMC": { - "sonic-device_neighbor_metadata:sonic-device_neighbor_metadata": { - "sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": { - "DEVICE_NEIGHBOR_METADATA_LIST": [ - { - "name": "Ethernet116", - "hwsku": "DUMMY_BMC_SKU", - "type": "IncorrectTypeBmc" - } - ] - } - } - }, "DEVICE_NEIGHBOR_METADATA_TYPE_CORRECT_PATTERN_BMC": { "sonic-device_neighbor_metadata:sonic-device_neighbor_metadata": { "sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": { @@ -69,6 +30,7 @@ "sonic-device_neighbor_metadata:DEVICE_NEIGHBOR_METADATA": { "DEVICE_NEIGHBOR_METADATA_LIST": [ { + "cluster": "AAA00PrdStr00", "lo_addr": "25.77.193.11/32", "mgmt_addr": "0.0.0.0/0", "name": "dccsw01.nw", @@ -77,6 +39,7 @@ "deployment_id": "1" }, { + "cluster": "AAA00PrdStr00", "lo_addr": "0.0.0.0/0", "mgmt_addr": "10.11.150.46/26", "name": "dccsw02.nw", @@ -85,6 +48,7 @@ "deployment_id": "1" }, { + "cluster": "AAA00PrdStr00", "lo_addr_v6": "2a04:5555:40:a709::2/126", "mgmt_addr": "10.11.150.47/26", "name": "dccsw03.nw", @@ -93,6 +57,7 @@ "deployment_id": "1" }, { + "cluster": "AAA00PrdStr00", "name": "dccsw04.nw", "mgmt_addr_v6": "2a04:5555:40:a708::2/126", "hwsku": "Arista", @@ -100,12 +65,14 @@ "deployment_id": "1" }, { + "cluster": "AAA00PrdStr00", "name": "dccsw05.nw", "hwsku": "Arista", "type": "LeafRouter", "deployment_id": "1" }, { + "cluster": "AAA00PrdStr00", "lo_addr_v6": "2a04:5555:40:a710::2/126", "name": "dccsw06.nw", "hwsku": "Arista", @@ -113,6 +80,7 @@ "deployment_id": "1" }, { + "cluster": "AAA00PrdStr00", "lo_addr": "25.77.193.11/32", "name": "dccsw07.nw", "hwsku": "Arista", @@ -120,6 +88,7 @@ "deployment_id": "1" }, { + "cluster": "AAA00PrdStr00", "mgmt_addr": "10.11.150.48/26", "name": "dccsw08.nw", "hwsku": "Arista", diff --git a/src/sonic-yang-models/yang-models/sonic-device_neighbor_metadata.yang b/src/sonic-yang-models/yang-models/sonic-device_neighbor_metadata.yang index 594c4a8c2c2c..cf3cbde89be3 100644 --- a/src/sonic-yang-models/yang-models/sonic-device_neighbor_metadata.yang +++ b/src/sonic-yang-models/yang-models/sonic-device_neighbor_metadata.yang @@ -40,6 +40,11 @@ module sonic-device_neighbor_metadata { } } + leaf cluster { + description "The switch is a member of this cluster"; + type string; + } + leaf hwsku { type stypes:hwsku; } @@ -82,9 +87,7 @@ module sonic-device_neighbor_metadata { leaf type { description "Network element type"; - type string { - pattern "ToRRouter|LeafRouter|SpineChassisFrontendRouter|ChassisBackendRouter|ASIC|Asic|Supervior|MgmtToRRouter|MgmtLeafRouter|SpineRouter|BackEndToRRouter|BackEndLeafRouter|EPMS|MgmtTsToR|BmcMgmtToRRouter|Server|Bmc|MiniPower|SmartCable|Ixia|not-provisioned"; - } + type string; } leaf deployment_id {