-
Notifications
You must be signed in to change notification settings - Fork 292
CP-54471 Configure Dom0 NTP via XAPI #6689
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
base: feature/config-ntp-timezone-maxcstate
Are you sure you want to change the base?
CP-54471 Configure Dom0 NTP via XAPI #6689
Conversation
Examles: def set_mode(mode):
session.xenapi.host.set_ntp_mode(host_ref, mode)
def set_custom_servers(servers):
session.xenapi.host.set_ntp_custom_servers(host_ref, servers)
def enable_ntp():
session.xenapi.host.enable_ntp(host_ref)
def disable_ntp():
session.xenapi.host.disable_ntp(host_ref)
def show():
enabled = session.xenapi.host.get_ntp_enabled(host_ref)
mode = session.xenapi.host.get_ntp_mode(host_ref)
custom_servers = session.xenapi.host.get_ntp_custom_servers(host_ref)
status = session.xenapi.host.get_ntp_servers_status(host_ref)
print(f'enabled {enabled}; mode {mode}; custom_servers {custom_servers}; status {status}')
def init():
set_mode('ntp_mode_default')
set_custom_servers([])
disable_ntp()
init()
show()
set_mode('ntp_mode_dhcp')
show()
enable_ntp()
time.sleep(5)
show()
set_mode('ntp_mode_default')
time.sleep(5)
show()
set_custom_servers(['time.google.com', 'time.windows.com', 'time.apple.com'])
set_mode('ntp_mode_custom')
time.sleep(5)
show() output:
xe
|
Did you mean |
ocaml/xapi/xapi_host_ntp.ml
Outdated
|
||
let chrony_conf = "/etc/chrony.conf" | ||
|
||
let chrony_script = "/etc/dhcp/dhclient.d/chrony.sh" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually scripts are added to the list of requited commands in ocaml/idl
so xapi will refuse to run if any of them are missing. Is there any reason this shouldn't be the case here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I am not aware of this. Let me check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean xapi_globs.ml
right?
How about Active Directory? IIUC that relies on a working clock synchronization with the AD servers (which may be out of sync with NTP, e.g. we've had situations where they were 30m off). |
- write ntp servers to chrony.conf - interaction with dhclient - handle /run/chrony-dhcp/$interface.sources - handle chrony.sh - restart/enable/disable chronyd Signed-off-by: Changlei Li <[email protected]>
2d3bf3b
to
d52e6d9
Compare
d52e6d9
to
f2c3a5c
Compare
Signed-off-by: Changlei Li <[email protected]>
Signed-off-by: Changlei Li <[email protected]>
Signed-off-by: Changlei Li <[email protected]>
Signed-off-by: Changlei Li <[email protected]>
f2c3a5c
to
97d6734
Compare
It's a good point. But it is beyond the feature scope. Maybe worth exploring in future discussions or tickets |
New filed:
host.ntp_mode
,host.ntp_custom_servers
New API:
host.set_ntp_mode
,host.set_ntp_custom_servers
,host.get_ntp_mode
,host.get_ntp_custom_servers
,host.get_ntp_servers_status
.ntp_mode_dhcp: In this mode, ntp uses the dhcp assigned ntp servers as sources. In Dom0, dhclient triggers
chrony.sh
to update the ntp servers when network event happens. It writes ntp servers to/run/chrony-dhcp/$interface.sources
and the dir/run/chrony-dhcp
is included inchrony.conf
. The dhclient also stores dhcp lease in/var/lib/xcp/dhclient-$interface.leases
, see https://github.com/xapi-project/xen-api/blob/v25.31.0/ocaml/networkd/lib/network_utils.ml#L925. When switch ntp mode to dhcp, XAPI checks the lease file and finds ntp server then fills chrony-dhcp file. The exec permission ofchrony.sh
is added. When swith ntp mode from dhcp to others, XAPI removes the chrony-dhcp files and the exec permission ofchrony.sh
. The operation is same with xsconsole https://github.com/xapi-project/xsconsole/blob/v11.1.1/XSConsoleData.py#L593. In this feature, xsconsole will change to use XenAPI to manage ntp later to avoid conflict.ntp_mode_custom: In this mode, ntp uses
host.ntp_custom_servers
as sources. This is implemented by changingchrony.conf
and restart chronyd.host.ntp_custom_servers
is set by the user.ntp_mode_default: In this mode, ntp uses default-ntp-servers in XAPI config file.
The dbsync, more APIs about NTP will be in following PRs.