From dab3a671220be6842a2f982a52d47d825f30d33d Mon Sep 17 00:00:00 2001 From: Arvindsrinivasan Lakshmi Narasimhan <55814491+arlakshm@users.noreply.github.com> Date: Sat, 13 Jul 2024 15:26:52 -0700 Subject: [PATCH] [Chassis][Voq][Yang] Make asic_name case sensitive in yang models (#19486) * make asic_name case sensitive * address comment --- .../tests_config/system_port.json | 76 +++++++++++++++++++ .../yang-models/sonic-buffer-queue.yang | 4 +- .../yang-models/sonic-queue.yang | 4 +- .../yang-models/sonic-system-port.yang | 4 +- .../yang-templates/sonic-types.yang.j2 | 6 ++ 5 files changed, 85 insertions(+), 9 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/system_port.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/system_port.json index 28edae5727a1..837d5a67797d 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/system_port.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/system_port.json @@ -86,6 +86,82 @@ ] } } + }, + "SYSTEM_ASIC_NAME_UPPERCASE": { + "sonic-system-port:sonic-system-port": { + "sonic-system-port:SYSTEM_PORT": { + "SYSTEM_PORT_LIST": [ + { + "hostname": "host456", + "asic_name": "ASIC0", + "ifname": "Ethernet0", + "core_index": "1", + "core_port_index": "20", + "num_voq": "8", + "speed": "900000", + "switch_id": "1", + "system_port_id": "200" + } + ] + } + } + }, + "SYSTEM_ASIC_NAME_INVALID": { + "sonic-system-port:sonic-system-port": { + "sonic-system-port:SYSTEM_PORT": { + "SYSTEM_PORT_LIST": [ + { + "hostname": "host456", + "asic_name": "INVALIDASIC0", + "ifname": "Ethernet0", + "core_index": "1", + "core_port_index": "20", + "num_voq": "8", + "speed": "900000", + "switch_id": "1", + "system_port_id": "200" + } + ] + } + } + }, + "SYSTEM_ASIC_NAME_SUP": { + "sonic-system-port:sonic-system-port": { + "sonic-system-port:SYSTEM_PORT": { + "SYSTEM_PORT_LIST": [ + { + "hostname": "host456", + "asic_name": "ASIC12", + "ifname": "Ethernet0", + "core_index": "1", + "core_port_index": "20", + "num_voq": "8", + "speed": "900000", + "switch_id": "1", + "system_port_id": "200" + } + ] + } + } + }, + "SYSTEM_ASIC_NAME_MIXED_CASE": { + "sonic-system-port:sonic-system-port": { + "sonic-system-port:SYSTEM_PORT": { + "SYSTEM_PORT_LIST": [ + { + "hostname": "host456", + "asic_name": "Asic2", + "ifname": "Ethernet0", + "core_index": "1", + "core_port_index": "20", + "num_voq": "8", + "speed": "900000", + "switch_id": "1", + "system_port_id": "200" + } + ] + } + } } } diff --git a/src/sonic-yang-models/yang-models/sonic-buffer-queue.yang b/src/sonic-yang-models/yang-models/sonic-buffer-queue.yang index 3e96db23c16c..685ed026dbfa 100644 --- a/src/sonic-yang-models/yang-models/sonic-buffer-queue.yang +++ b/src/sonic-yang-models/yang-models/sonic-buffer-queue.yang @@ -84,9 +84,7 @@ module sonic-buffer-queue { } leaf asic_name { - type string { - pattern "[Aa]sic[0-4]"; - } + type stypes:asic_name; } leaf port { diff --git a/src/sonic-yang-models/yang-models/sonic-queue.yang b/src/sonic-yang-models/yang-models/sonic-queue.yang index e491a50b01d2..453950f8b944 100644 --- a/src/sonic-yang-models/yang-models/sonic-queue.yang +++ b/src/sonic-yang-models/yang-models/sonic-queue.yang @@ -105,9 +105,7 @@ module sonic-queue { } leaf asic_name { - type string { - pattern "[Aa]sic[0-4]"; - } + type stypes:asic_name; } leaf ifname { diff --git a/src/sonic-yang-models/yang-models/sonic-system-port.yang b/src/sonic-yang-models/yang-models/sonic-system-port.yang index f95405ac662f..25d18e9a5515 100644 --- a/src/sonic-yang-models/yang-models/sonic-system-port.yang +++ b/src/sonic-yang-models/yang-models/sonic-system-port.yang @@ -34,9 +34,7 @@ module sonic-system-port { } leaf asic_name { - type string { - pattern "[Aa]sic[0-4]"; - } + type stypes:asic_name; } leaf ifname { diff --git a/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 b/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 index 6d3d3db00526..df9b3c91dd8f 100644 --- a/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 +++ b/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 @@ -386,6 +386,12 @@ module sonic-types { } } + typedef asic_name { + type string { + pattern '[Aa][Ss][Ii][Cc][0-9]{1,2}'; + } + } + {% if yang_model_type == "cvl" %} /* Required for CVL */ container operation {