From 0526ff98f27512080be7a9a558ce67c975eb7b7a Mon Sep 17 00:00:00 2001 From: ganglv <88995770+ganglyu@users.noreply.github.com> Date: Thu, 21 Apr 2022 08:39:35 +0800 Subject: [PATCH] [yang] Update device_metadata to add dhcp_server (#10598) Why I did it dhcp_server is introduced, and need to update yang model. How I did it Update yang models and add unit test. How to verify it Run unit test for sonic-yang-models. Signed-off-by: Gang Lv ganglv@microsoft.com --- .../tests/files/sample_config_db.json | 3 ++- .../tests/device_metadata.json | 9 ++++++++- .../tests_config/device_metadata.json | 18 ++++++++++++++++++ .../yang-models/sonic-device_metadata.yang | 5 +++++ 4 files changed, 33 insertions(+), 2 deletions(-) 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 28124b7d82..4b477abec0 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -283,7 +283,8 @@ "hwsku": "Stone", "buffer_model": "dynamic", "cloudtype": "Public", - "region": "usfoo" + "region": "usfoo", + "dhcp_server": "disabled" } }, "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 dd35f6cf94..1035d527fb 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 @@ -93,6 +93,13 @@ "DEVICE_METADATA_INVALID_STORAGE_DEVICE": { "desc": "Verifying invalid storage device value", "eStrKey": "InvalidValue" - } + }, + "DEVICE_METADATA_VALID_DHCP_SERVER": { + "desc": "Verifying dhcp_server configuration." + }, + "DEVICE_METADATA_INVALID_DHCP_SERVER": { + "desc": "Verifying invalid dhcp_server configuration.", + "eStrKey": "InvalidValue" + } } 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 34dcf4e5a2..9792409cc4 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 @@ -251,5 +251,23 @@ } } } + }, + "DEVICE_METADATA_VALID_DHCP_SERVER": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "dhcp_server": "enabled" + } + } + } + }, + "DEVICE_METADATA_INVALID_DHCP_SERVER": { + "sonic-device_metadata:sonic-device_metadata": { + "sonic-device_metadata:DEVICE_METADATA": { + "sonic-device_metadata:localhost": { + "dhcp_server": "invalid" + } + } + } } } 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 5501f7ecca..08e7014ce6 100644 --- a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang +++ b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang @@ -148,6 +148,11 @@ module sonic-device_metadata { leaf storage_device { type boolean; } + + leaf dhcp_server { + type stypes:admin_mode; + description "Indicate whether enable the embedded DHCP server."; + } } /* end of container localhost */ }