Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Clock] Add timezone config YANG model #14651

Merged
merged 3 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"buffer_model": {% if default_buffer_model == "dynamic" %}"dynamic"{% else %}"traditional"{% endif %},
{%- if include_p4rt == "y" %}"synchronous_mode":"enable",{% endif %}
"default_bgp_status": {% if shutdown_bgp_on_start == "y" %}"down"{% else %}"up"{% endif %},
"default_pfcwd_status": {% if enable_pfcwd_on_start == "y" %}"enable"{% else %}"disable"{% endif %}
"default_pfcwd_status": {% if enable_pfcwd_on_start == "y" %}"enable"{% else %}"disable"{% endif %},
"timezone": "UTC"
}
},
"CRM": {
Expand Down
3 changes: 2 additions & 1 deletion src/sonic-yang-models/doc/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,8 @@ instance is supported in SONiC.
"bgp_adv_lo_prefix_as_128" : "true",
"buffer_model": "traditional",
"yang_config_validation": "disable",
"rack_mgmt_map": "dummy_value"
"rack_mgmt_map": "dummy_value",
"timezome": "Europe/Kiev"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/sonic-yang-models/tests/files/sample_config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,8 @@
"dhcp_server": "disabled",
"bgp_adv_lo_prefix_as_128": "true",
"yang_config_validation": "disable",
"rack_mgmt_map": "dummy_value"
"rack_mgmt_map": "dummy_value",
"timezone": "Europe/Kiev"
}
},
"VLAN": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,5 +142,12 @@
"DEVICE_METADATA_INVALID_RACK_MGMT_MAP": {
"desc": "Verifying invalid rack_mgmt_map configuration.",
"eStr": "Invalid length for the rack mgmt map."
},
"DEVICE_METADATA_VALID_TIMEZONE": {
"desc": "Verifying valid timezone value"
},
"DEVICE_METADATA_INVALID_TIMEZONE": {
"desc": "Verifying invalid timezone value",
"eStrKey": "Range"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,15 @@
}
}
},
"DEVICE_METADATA_VALID_TIMEZONE": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"sonic-device_metadata:localhost": {
"timezone": "UTC"
}
}
}
},
"DEVICE_METADATA_INVALID_RACK_MGMT_MAP": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
Expand All @@ -380,5 +389,14 @@
}
}
}
},
"DEVICE_METADATA_INVALID_TIMEZONE": {
"sonic-device_metadata:sonic-device_metadata": {
"sonic-device_metadata:DEVICE_METADATA": {
"sonic-device_metadata:localhost": {
"timezone": ""
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ module sonic-device_metadata {
}
description "Information of rack mgmt map.";
}

leaf timezone {
type stypes:timezone-name-type {
length 1..255;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not move length to sonic-types.yang?

Copy link
Contributor

@wen587 wen587 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. Others look good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timezone-name-type was copied from the Openconfig. I prefer to leave it unchanged there. So that is why I add the length definition here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need length?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we shouldn't allow empty timezones, as well as enormous long strings, like more than 255 characters long.

default "UTC";
description "The TZ database name to use for the system, such as 'Europe/Stockholm'.";
reference "IANA Time Zone Database http://www.iana.org/time-zones";
}
}
/* end of container localhost */
}
Expand Down
13 changes: 13 additions & 0 deletions src/sonic-yang-models/yang-templates/sonic-types.yang.j2
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,19 @@ module sonic-types {
}
}

typedef timezone-name-type {
type string;
description
"A time zone name as used by the Time Zone Database,
sometimes referred to as the 'Olson Database'.

The exact set of valid values is an implementation-specific
matter. Client discovery of the exact set of time zone names
for a particular server is out of scope.";
reference
"BCP 175: Procedures for Maintaining the Time Zone Database";
}

{% if yang_model_type == "cvl" %}
/* Required for CVL */
container operation {
Expand Down