Skip to content

Conversation

@changlei-li
Copy link
Contributor

xenapi host.set_timezone to config the timezone of the host.
host.set_ntp_mode to manage the NTP. The NTP mode mapping to xsconsole is:
DHCP - dhcp
Factory - default
Custom - manual
Disabled - none
host.set_ntp_custom_servers to configure the NTP servers that used in Custom mode.

elif inChoice == "NONE":
data.SetNTPMode("Disabled")
else:
raise ValueError("Unknown NTP choice: {}".format(inChoice))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Personally, I prefer to replace the if .. elif block with python dictionary, like following,

ntpmode_map = {
"DHCP": "DHCP",
"DEFAULT": "Factory",
}
return ntpmode_map.get(code, "Unknown")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

xenapi host.set_timezone to config the timezone of the host.
host.set_ntp_mode to manage the NTP. The NTP mode mapping
to xsconsole is:
DHCP - dhcp
Factory - default
Custom - manual
Disabled - none
host.set_ntp_custom_servers to configure the NTP servers
that used in Custom mode.

Signed-off-by: Changlei Li <changlei.li@cloud.com>
XAPI APIs can't set NTP Custom mode with empty custom NTP servers.
This is a meaningless selection that NTP is enabled but the time
sources are not configured. It is Disable NTP in fact.

Signed-off-by: Changlei Li <changlei.li@cloud.com>
The previous /etc/timezone is not on the system, but written by
xsconsole itself. It's more reasonable to read link from
/etc/localtime.
This is also consistent with XAPI's behavior.

Signed-off-by: Changlei Li <changlei.li@cloud.com>
@changlei-li changlei-li force-pushed the private/changleli/xapi-ntp-apis-xs8 branch from 69471f9 to 50f3ca9 Compare December 15, 2025 06:29
@changlei-li changlei-li merged commit e11ef4a into xapi-project:release/xs8 Dec 18, 2025
1 check passed
@changlei-li changlei-li deleted the private/changleli/xapi-ntp-apis-xs8 branch December 18, 2025 01:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants