-
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?
Changes from all commits
11d1fbb
83b65ac
4e7c00a
d25491e
97d6734
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1094,7 +1094,8 @@ let create ~__context ~uuid ~name_label ~name_description:_ ~hostname ~address | |
~recommended_guidances:[] ~latest_synced_updates_applied:`unknown | ||
~pending_guidances_recommended:[] ~pending_guidances_full:[] ~ssh_enabled | ||
~ssh_enabled_timeout ~ssh_expiry ~console_idle_timeout ~ssh_auto_mode | ||
~max_cstate:"" ~secure_boot ; | ||
~max_cstate:"" ~secure_boot ~ntp_mode:`ntp_mode_dhcp ~ntp_custom_servers:[] | ||
~ntp_enabled:false ; | ||
(* If the host we're creating is us, make sure its set to live *) | ||
Db.Host_metrics.set_last_updated ~__context ~self:metrics ~value:(Date.now ()) ; | ||
Db.Host_metrics.set_live ~__context ~self:metrics ~value:host_is_us ; | ||
|
@@ -3374,3 +3375,64 @@ let sync_max_cstate ~__context ~host = | |
let value = Xapi_host_max_cstate.to_string (max_cstate, max_sub_cstate) in | ||
Db.Host.set_max_cstate ~__context ~self:host ~value | ||
with e -> error "Failed to sync max_cstate: %s" (Printexc.to_string e) | ||
|
||
let set_ntp_mode ~__context ~self ~value = | ||
let current_mode = Db.Host.get_ntp_mode ~__context ~self in | ||
let ntp_enabled = Db.Host.get_ntp_enabled ~__context ~self in | ||
if current_mode <> value then ( | ||
let open Xapi_host_ntp in | ||
let ensure_custom_servers_exist servers = | ||
if servers = [] then | ||
Helpers.internal_error "ntp_custom_servers is empty, please set first" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about raise an |
||
in | ||
let default_servers = !Xapi_globs.default_ntp_servers in | ||
( match (current_mode, value) with | ||
| `ntp_mode_dhcp, `ntp_mode_custom -> | ||
let custom_servers = Db.Host.get_ntp_custom_servers ~__context ~self in | ||
ensure_custom_servers_exist custom_servers ; | ||
remove_dhcp_ntp_servers () ; | ||
set_servers_in_conf custom_servers | ||
| `ntp_mode_default, `ntp_mode_custom -> | ||
let custom_servers = Db.Host.get_ntp_custom_servers ~__context ~self in | ||
ensure_custom_servers_exist custom_servers ; | ||
set_servers_in_conf custom_servers | ||
| _, `ntp_mode_dhcp -> | ||
clear_servers_in_conf () ; add_dhcp_ntp_servers () | ||
| `ntp_mode_dhcp, `ntp_mode_default -> | ||
remove_dhcp_ntp_servers () ; | ||
set_servers_in_conf default_servers | ||
| `ntp_mode_custom, `ntp_mode_default -> | ||
set_servers_in_conf default_servers | ||
| _, _ -> | ||
() | ||
) ; | ||
if ntp_enabled then Xapi_host_ntp.restart_ntp_service () ; | ||
Db.Host.set_ntp_mode ~__context ~self ~value | ||
) | ||
|
||
let set_ntp_custom_servers ~__context ~self ~value = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we check the IP/domain format here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me consider it. But it seems hard to construct a valid domain format rule to check. |
||
let current_mode = Db.Host.get_ntp_mode ~__context ~self in | ||
match (current_mode, value) with | ||
| `ntp_mode_custom, [] -> | ||
Helpers.internal_error | ||
"ntp_mode is custom, can't clear ntp_custom_servers" | ||
| `ntp_mode_custom, servers -> | ||
Xapi_host_ntp.set_servers_in_conf servers ; | ||
Xapi_host_ntp.restart_ntp_service () ; | ||
Db.Host.set_ntp_custom_servers ~__context ~self ~value | ||
| _ -> | ||
Db.Host.set_ntp_custom_servers ~__context ~self ~value | ||
|
||
let enable_ntp ~__context ~self = | ||
Xapi_host_ntp.enable_ntp_service () ; | ||
Db.Host.set_ntp_enabled ~__context ~self ~value:true | ||
|
||
let disable_ntp ~__context ~self = | ||
Xapi_host_ntp.disable_ntp_service () ; | ||
Db.Host.set_ntp_enabled ~__context ~self ~value:false | ||
|
||
let get_ntp_servers_status ~__context ~self:_ = | ||
if Xapi_host_ntp.is_ntp_service_active () then | ||
Xapi_host_ntp.get_servers_status () | ||
else | ||
[] |
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.
Is it possible the default ntp service status is enabled after XS installation? If so, I would suggest add synchronization for the ntp service status when xapi starts.
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes. I need consider more for the dbsync (like ntp_mode, compatibility for old default ntp servers etc.). So, I plan to handle it in a new PR and ticket.