Skip to content

Commit 68ca423

Browse files
fastiuksonic-otn
authored andcommitted
[Clock] Add timezone config YANG model (sonic-net#14651)
* Add the ability to configure timezone Signed-off-by: Yevhen Fastiuk <[email protected]> * Add YANG model for timezone Signed-off-by: Yevhen Fastiuk <[email protected]> * Add timezone reference Signed-off-by: Yevhen Fastiuk <[email protected]> --------- Signed-off-by: Yevhen Fastiuk <[email protected]>
1 parent dece38c commit 68ca423

File tree

7 files changed

+53
-3
lines changed

7 files changed

+53
-3
lines changed

files/build_templates/init_cfg.json.j2

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"buffer_model": {% if default_buffer_model == "dynamic" %}"dynamic"{% else %}"traditional"{% endif %},
55
{%- if include_p4rt == "y" %}"synchronous_mode":"enable",{% endif %}
66
"default_bgp_status": {% if shutdown_bgp_on_start == "y" %}"down"{% else %}"up"{% endif %},
7-
"default_pfcwd_status": {% if enable_pfcwd_on_start == "y" %}"enable"{% else %}"disable"{% endif %}
7+
"default_pfcwd_status": {% if enable_pfcwd_on_start == "y" %}"enable"{% else %}"disable"{% endif %},
8+
"timezone": "UTC"
89
}
910
},
1011
"CRM": {

src/sonic-yang-models/doc/Configuration.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,8 @@ instance is supported in SONiC.
927927
"bgp_adv_lo_prefix_as_128" : "true",
928928
"buffer_model": "traditional",
929929
"yang_config_validation": "disable",
930-
"rack_mgmt_map": "dummy_value"
930+
"rack_mgmt_map": "dummy_value",
931+
"timezome": "Europe/Kiev"
931932
}
932933
}
933934
}

src/sonic-yang-models/tests/files/sample_config_db.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,8 @@
360360
"dhcp_server": "disabled",
361361
"bgp_adv_lo_prefix_as_128": "true",
362362
"yang_config_validation": "disable",
363-
"rack_mgmt_map": "dummy_value"
363+
"rack_mgmt_map": "dummy_value",
364+
"timezone": "Europe/Kiev"
364365
}
365366
},
366367
"VLAN": {

src/sonic-yang-models/tests/yang_model_tests/tests/device_metadata.json

+7
Original file line numberDiff line numberDiff line change
@@ -142,5 +142,12 @@
142142
"DEVICE_METADATA_INVALID_RACK_MGMT_MAP": {
143143
"desc": "Verifying invalid rack_mgmt_map configuration.",
144144
"eStr": "Invalid length for the rack mgmt map."
145+
},
146+
"DEVICE_METADATA_VALID_TIMEZONE": {
147+
"desc": "Verifying valid timezone value"
148+
},
149+
"DEVICE_METADATA_INVALID_TIMEZONE": {
150+
"desc": "Verifying invalid timezone value",
151+
"eStrKey": "Range"
145152
}
146153
}

src/sonic-yang-models/tests/yang_model_tests/tests_config/device_metadata.json

+18
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,15 @@
372372
}
373373
}
374374
},
375+
"DEVICE_METADATA_VALID_TIMEZONE": {
376+
"sonic-device_metadata:sonic-device_metadata": {
377+
"sonic-device_metadata:DEVICE_METADATA": {
378+
"sonic-device_metadata:localhost": {
379+
"timezone": "UTC"
380+
}
381+
}
382+
}
383+
},
375384
"DEVICE_METADATA_INVALID_RACK_MGMT_MAP": {
376385
"sonic-device_metadata:sonic-device_metadata": {
377386
"sonic-device_metadata:DEVICE_METADATA": {
@@ -380,5 +389,14 @@
380389
}
381390
}
382391
}
392+
},
393+
"DEVICE_METADATA_INVALID_TIMEZONE": {
394+
"sonic-device_metadata:sonic-device_metadata": {
395+
"sonic-device_metadata:DEVICE_METADATA": {
396+
"sonic-device_metadata:localhost": {
397+
"timezone": ""
398+
}
399+
}
400+
}
383401
}
384402
}

src/sonic-yang-models/yang-models/sonic-device_metadata.yang

+9
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,15 @@ module sonic-device_metadata {
225225
}
226226
description "Information of rack mgmt map.";
227227
}
228+
229+
leaf timezone {
230+
type stypes:timezone-name-type {
231+
length 1..255;
232+
}
233+
default "UTC";
234+
description "The TZ database name to use for the system, such as 'Europe/Stockholm'.";
235+
reference "IANA Time Zone Database http://www.iana.org/time-zones";
236+
}
228237
}
229238
/* end of container localhost */
230239
}

src/sonic-yang-models/yang-templates/sonic-types.yang.j2

+13
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,19 @@ module sonic-types {
334334
}
335335
}
336336

337+
typedef timezone-name-type {
338+
type string;
339+
description
340+
"A time zone name as used by the Time Zone Database,
341+
sometimes referred to as the 'Olson Database'.
342+
343+
The exact set of valid values is an implementation-specific
344+
matter. Client discovery of the exact set of time zone names
345+
for a particular server is out of scope.";
346+
reference
347+
"BCP 175: Procedures for Maintaining the Time Zone Database";
348+
}
349+
337350
{% if yang_model_type == "cvl" %}
338351
/* Required for CVL */
339352
container operation {

0 commit comments

Comments
 (0)