From 28a272b09c6ddb333a77e32ebca417ba3a45b324 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 28edae572..837d5a677 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 c36eb5415..1b4ce3362 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 e249b78f3..d5e4eda43 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 f95405ac6..25d18e9a5 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 5f24b45df..b4dce02c4 100644 --- a/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 +++ b/src/sonic-yang-models/yang-templates/sonic-types.yang.j2 @@ -271,6 +271,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 {