-
- 1.1. Revision
- 1.2. Scope
- 1.3. Definitions/Abbreviations
- 1.4. Overview
- 1.5. Requirements
-
- 2.1. High-Level Design
-
- 3.1. ConfigDB Tables
- 3.2. CLI/YANG model
- 3.2.1. Yang model
- 3.2.2. CLI
-
- Test Plan
- 4.1. Unit Test cases
- Test Plan
Rev | Date | Author | Change Description |
---|---|---|---|
0.1 | 01/2023 | Meir Renford | Phase 1 Design |
This document will address the high level design for NVOS clock commands:
- Set/show date-time command
- Set/show timezone command
N/A
The clock commands allow to set and review the current time parameters of the system - including: time, date and timezone.
- Any time configuration that will change in the system will change the system time.
The requirements from the module are:
- Set and show the system time and date.
- Set and show the system timezone.
The design of this feature is based on Linux command of timedatectl.
(man page for timedatectl: https://man7.org/linux/man-pages/man1/timedatectl.1.html)
All set operations are based on this command, executing directly in linux upon user CLI execution. The time/date/timezone are configured directly to Linux, and is persistent upon any reboot.
System state of time/date/timezone will appear in 1 line as an output of existing "show clock" command.
Set operations will be divided into 2 different commands:
-
config clock set-timezone (to set timezone command)
- will get single input as a string, and validate it is valid as part of ("timedatectl list-timezones" command). Validation will be done either by YANG model, or (if not possible) by issueing relevant error to log.
- Value will be stored in db for future upgrade operations. Value is persistent upon reboot.
- Linux timedatectl with set-timezone flag will be called. e.g. timedatectl set-timezone "Asia/Kolkata"
- In case NTP is enabled -> timezone configuration is allowed and overrides the current time.
-
config clock set-date "" (to set time and date)
- Command will recieve single string with date-time format ""
- It will be possible to call command with the following options:
- Only with a date
- Only with time HH:MM:SS
- both date and time ""
- Command does not need to be stored in DB.
- Linux timedatectl with set-time flag will be called. e.g. timedatectl set-time "2012-10-30 18:17:16"
- In case NTP is enabled -> time/date set is NOT allowed and being blocked
Both set commands will be written directly to Linux (via imedatectl command), and will be activated immediately.
Only timezone configuration will be saved. Additional field will be added to DEVICE_METADATA table
DEVICE_METADATA :{
"timezone": {{string}}
}
default value: "Etc/UTC"
Adding to existing Yang model of device_metadata (https://github.com/sonic-net/sonic-buildimage/blob/master/src/sonic-yang-models/yang-models/sonic-device_metadata.yang)
container sonic-device_metadata {
container DEVICE_METADATA {
description "DEVICE_METADATA part of config_db.json";
container localhost{
...
leaf timezone {
type string;
}
root@host:~$ show clock
Sun 15 Jan 2023 06:12:08 PM IST
root@host:~$ config clock set-timezone "<timezone>"
root@host:~$ config clock set-date "<YYYY-MM-DD HH:MM:SS>"
-
Good flows:
a. set timezone
b. set date
c. set time
d. set date & time
e. check reboot / upgrade -
Bad flows:
a. set invalid timezone
b. set empty string
c. set invalid date format
d. set invalid time format
e. set invalide date/time format -
NTP interop
a. Change time/date, followed by changing NTP - and see time changed.
b. try to change time/date in case NTP is enabled -> and expect getting a failure.
c. Change timezone in case NTP is enabled, and expect to succeed and change relevant time.