From 3d9a6e46bc6a5c2d44381d48fb07a96af15bff22 Mon Sep 17 00:00:00 2001 From: isabelmsft <67024108+isabelmsft@users.noreply.github.com> Date: Wed, 26 Oct 2022 13:11:42 -0700 Subject: [PATCH] Add yang_config_validation to DEVICE_METADATA yang model (#12497) * Add yang_config_validation to DEVICE_METADATA yang model --- src/sonic-yang-models/doc/Configuration.md | 3 ++- .../tests/files/sample_config_db.json | 3 ++- .../tests/yang_model_tests/tests/device_metadata.json | 9 +++++++++ .../tests_config/device_metadata.json | 11 +++++++++++ .../yang-models/sonic-device_metadata.yang | 5 +++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index f30a2c8c5f..d09e2c8bac 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -831,7 +831,8 @@ instance is supported in SONiC. "deployment_id": "1", "type": "ToRRouter", "bgp_adv_lo_prefix_as_128" : "true", - "buffer_model": "traditional" + "buffer_model": "traditional", + "yang_config_validation": "disable" } } } 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 9dec93b520..ecb0be1c4c 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -332,7 +332,8 @@ "max_cores": "8", "sub_role": "FrontEnd", "dhcp_server": "disabled", - "bgp_adv_lo_prefix_as_128": "true" + "bgp_adv_lo_prefix_as_128": "true", + "yang_config_validation": "disable" } }, "VLAN": { diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json index 8a562ef536..e55ba4c825 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json @@ -51,6 +51,15 @@ "value": "enable" } }, + "DEVICE_METADATA_DEFAULT_YANG_CONFIG_VALIDATION": { + "desc": "DEVICE_METADATA DEFAULT VALUE FOR YANG CONFIG VALIDATION.", + "eStrKey" : "Verify", + "verify": { + "xpath": "/sonic-device_metadata:sonic-device_metadata/DEVICE_METADATA/localhost/hostname", + "key": "sonic-device_metadata:yang_config_validation", + "value": "disable" + } + }, "DEVICE_METADATA_CORRECT_BUFFER_MODEL_PATTERN": { "desc": "DEVICE_METADATA correct value for BUFFER_MODEL field" }, diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json index ece046f2af..638f83d562 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json @@ -85,6 +85,17 @@ } } }, + "DEVICE_METADATA_DEFAULT_YANG_CONFIG_VALIDATION": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "bgp_asn": "65001", + "hostname": "DUT-CSW", + "platform": "Stone-DX010" + } + } + } + }, "DEV_META_DEV_NEIGH_VERSION_TABLE": { "sonic-device_metadata:sonic-device_metadata": { "sonic-device_metadata:DEVICE_METADATA": { diff --git a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang index b04f929cdd..1d40dc31b7 100644 --- a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang +++ b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang @@ -119,6 +119,11 @@ module sonic-device_metadata { default enable; } + leaf yang_config_validation { + type stypes:mode-status; + default disable; + } + leaf cloudtype { type string; }