CP-308543 Use xenapi to manage timezone and NTP#82
Merged
changlei-li merged 3 commits intoxapi-project:release/xs8from Dec 18, 2025
Merged
Conversation
chunjiez
approved these changes
Dec 11, 2025
| elif inChoice == "NONE": | ||
| data.SetNTPMode("Disabled") | ||
| else: | ||
| raise ValueError("Unknown NTP choice: {}".format(inChoice)) |
Collaborator
There was a problem hiding this comment.
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")
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>
69471f9 to
50f3ca9
Compare
stephenchengCloud
approved these changes
Dec 17, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.