From 73238a439bb637e2cdaf5fd41fcbb88872e70a1e Mon Sep 17 00:00:00 2001 From: yaqiangz Date: Thu, 17 Aug 2023 02:59:46 +0000 Subject: [PATCH] Fix comment --- src/sonic-yang-models/doc/Configuration.md | 4 +- .../tests/dhcp_server_ipv4.json | 17 ++++- .../tests_config/dhcp_server_ipv4.json | 70 +++++++++++++++++++ .../yang-models/sonic-dhcp-server-ipv4.yang | 37 +++++----- 4 files changed, 108 insertions(+), 20 deletions(-) diff --git a/src/sonic-yang-models/doc/Configuration.md b/src/sonic-yang-models/doc/Configuration.md index 3d4497bb5299..277684a83927 100644 --- a/src/sonic-yang-models/doc/Configuration.md +++ b/src/sonic-yang-models/doc/Configuration.md @@ -1018,7 +1018,9 @@ IPV4 DHPC Server related configuration are defined in **DHCP_SERVER_IPV4**, **DH }, "DHCP_SERVER_IPV4_PORT": { "Vlan100|PortChannel0003": { - "ip": "100.1.1.10" + "ips": [ + "100.1.1.10" + ] }, "Vlan100|PortChannel2": { "ranges": [ diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcp_server_ipv4.json b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcp_server_ipv4.json index 2b355a78c340..a4e688a8e055 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/dhcp_server_ipv4.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/dhcp_server_ipv4.json @@ -27,13 +27,28 @@ "eStrKey": "InvalidValue", "eStr": ["type"] }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_TEXT": { + "desc": "Add text type of DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS." + }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_IPV4_ADDRESS": { + "desc": "Add ipv4-address type of DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS." + }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_UINT8": { + "desc": "Add uint8 type of DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS." + }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_UINT16": { + "desc": "Add uint16 type of DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS." + }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_UINT32": { + "desc": "Add uint32 type of DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS." + }, "DHCP_SERVER_IPV4_RANGE_INVALID_END": { "desc": "Configure wrong end ip of range.", "eStrKey": "Pattern" }, "DHCP_SERVER_IPV4_RANGE_RANGES_WITH_IP": { "desc": "Configure both ip and ranges in DHCP_SERVER_IPV4_RANGE_RANGES", - "eStr": ["Statement of 'ip' and 'ranges' cannot both exist"] + "eStr": ["Statement of 'ips' and 'ranges' cannot both exist"] }, "DHCP_SERVER_IPV4_GATEWAY_ABSENT": { "desc": "Missing gateway in DHCP_SERVER_IPV4", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4.json index 031a22ca0811..97519f490e67 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/dhcp_server_ipv4.json @@ -237,6 +237,76 @@ } } }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_TEXT": { + "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { + "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": { + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_LIST": [ + { + "name": "option60", + "id": 60, + "type": "text", + "value": "dummy_value" + } + ] + } + } + }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_IPV4_ADDRESS": { + "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { + "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": { + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_LIST": [ + { + "name": "option60", + "id": 60, + "type": "ipv4-address", + "value": "dummy_value" + } + ] + } + } + }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_UINT8": { + "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { + "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": { + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_LIST": [ + { + "name": "option60", + "id": 60, + "type": "uint8", + "value": "dummy_value" + } + ] + } + } + }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_UINT16": { + "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { + "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": { + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_LIST": [ + { + "name": "option60", + "id": 60, + "type": "uint16", + "value": "dummy_value" + } + ] + } + } + }, + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_VALID_VALUE_UINT32": { + "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { + "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": { + "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_LIST": [ + { + "name": "option60", + "id": 60, + "type": "uint32", + "value": "dummy_value" + } + ] + } + } + }, "DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS_TYPE_WRONG_VALUE": { "sonic-dhcp-server-ipv4:sonic-dhcp-server-ipv4": { "sonic-dhcp-server-ipv4:DHCP_SERVER_IPV4_CUSTOMIZED_OPTIONS": { diff --git a/src/sonic-yang-models/yang-models/sonic-dhcp-server-ipv4.yang b/src/sonic-yang-models/yang-models/sonic-dhcp-server-ipv4.yang index 0d332e1d556c..d837da468a8c 100644 --- a/src/sonic-yang-models/yang-models/sonic-dhcp-server-ipv4.yang +++ b/src/sonic-yang-models/yang-models/sonic-dhcp-server-ipv4.yang @@ -10,6 +10,10 @@ module sonic-dhcp-server-ipv4 { prefix inet; } + import sonic-types { + prefix stypes; + } + import sonic-vlan { prefix vlan; } @@ -87,10 +91,7 @@ module sonic-dhcp-server-ipv4 { leaf state { description "State of DHCP server"; mandatory true; - type enumeration { - enum enabled; - enum disabled; - } + type stypes:admin_mode; } } /* end of DHCP_SERVER_IPV4_LIST */ @@ -196,34 +197,34 @@ module sonic-dhcp-server-ipv4 { leaf vlan { description "Name of vlan"; type leafref { - path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; - } + path "/vlan:sonic-vlan/vlan:VLAN/vlan:VLAN_LIST/vlan:name"; + } } leaf port { description "Interface under vlan"; - type union { - type leafref { - path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; - } - type leafref { - path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; - } - } - } + type union { + type leafref { + path "/port:sonic-port/port:PORT/port:PORT_LIST/port:name"; + } + type leafref { + path "/lag:sonic-portchannel/lag:PORTCHANNEL/lag:PORTCHANNEL_LIST/lag:name"; + } + } + } leaf-list ips { description "Assigned IPs"; must "(not(boolean(../ranges)))"{ - error-message "Statement of 'ip' and 'ranges' cannot both exist"; + error-message "Statement of 'ips' and 'ranges' cannot both exist"; } type inet:ipv4-address; } leaf-list ranges { description "IP ranges"; - must "(not(boolean(../ip)))"{ - error-message "Statement of 'ip' and 'ranges' cannot both exist"; + must "(not(boolean(../ips)))"{ + error-message "Statement of 'ips' and 'ranges' cannot both exist"; } type leafref { path "/dhcp-server-ipv4:sonic-dhcp-server-ipv4/dhcp-server-ipv4:DHCP_SERVER_IPV4_RANGE/dhcp-server-ipv4:DHCP_SERVER_IPV4_RANGE_LIST/dhcp-server-ipv4:name";