From a8f72e5d452edc85c441ef5e19125d4373de1664 Mon Sep 17 00:00:00 2001 From: ganglv <88995770+ganglyu@users.noreply.github.com> Date: Sat, 2 Apr 2022 07:32:01 +0800 Subject: [PATCH] [yang] Update device_metadata to add dhcp_server (#10382) 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 | 7 +++++++ .../tests_config/device_metadata.json | 18 ++++++++++++++++++ .../yang-models/sonic-device_metadata.yang | 5 +++++ 4 files changed, 32 insertions(+), 1 deletion(-) 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 d33cf20e20..e40d75e8f2 100644 --- a/src/sonic-yang-models/tests/files/sample_config_db.json +++ b/src/sonic-yang-models/tests/files/sample_config_db.json @@ -304,7 +304,8 @@ "switch_id": "2", "switch_type": "voq", "max_cores": "8", - "sub_role": "FrondEnd" + "sub_role": "FrondEnd", + "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 ecfff6f69a..7f0ddd3849 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 @@ -103,6 +103,13 @@ }, "DEVICE_METADATA_VALID_SUB_ROLE_CONFIG": { "desc": "Verifying valid sub_role configuration." + }, + "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 de0d4e15dc..a921e9ef41 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 @@ -283,5 +283,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 87170850d8..618ed19cd8 100644 --- a/src/sonic-yang-models/yang-models/sonic-device_metadata.yang +++ b/src/sonic-yang-models/yang-models/sonic-device_metadata.yang @@ -183,6 +183,11 @@ module sonic-device_metadata { type uint8; description "Maximum number of cores in a VoQ Switch (chassis)."; } + + leaf dhcp_server { + type stypes:admin_mode; + description "Indicate whether enable the embedded DHCP server."; + } } /* end of container localhost */ }