Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions doc/content/design/host-ntp-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ cache for the getter APIs.

New fields:
`host.ntp_mode`, enum host_ntp_mode(DHCP, Custom, Factory, Disabled)
`host.ntp_custom_servers`, string set
`host.ntp_enabled`, bool
`host.ntp_custom_servers`, string set

New APIs: `host.set_ntp_mode`, `host.set_ntp_custom_servers`, `host.get_ntp_mode`,
`host.get_ntp_custom_servers`, `host.get_ntp_servers_status`
Expand Down Expand Up @@ -201,7 +200,6 @@ host.timezone
host.set_timezone
host.list_timezones
host.get_timezone
host.get_ntp_enabled
host.get_ntp_synchronized
host.set_ntp_mode
host.get_ntp_mode
Expand Down
2 changes: 1 addition & 1 deletion ocaml/idl/datamodel_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ open Datamodel_roles
to leave a gap for potential hotfixes needing to increment the schema version.*)
let schema_major_vsn = 5

let schema_minor_vsn = 791
let schema_minor_vsn = 792

(* Historical schema versions just in case this is useful later *)
let rio_schema_major_vsn = 5
Expand Down
30 changes: 7 additions & 23 deletions ocaml/idl/datamodel_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2579,11 +2579,10 @@ let host_ntp_mode =
Enum
( "host_ntp_mode"
, [
("ntp_mode_dhcp", "Using NTP servers assigned by DHCP to sync time")
; ( "ntp_mode_custom"
, "Using custom NTP servers configured by user to sync time"
)
; ("ntp_mode_default", "Using default NTP servers to sync time")
("DHCP", "Using NTP servers assigned by DHCP to sync time")
; ("Custom", "Using custom NTP servers configured by user to sync time")
; ("Factory", "Using built-in NTP servers to sync time")
; ("Disabled", "NTP is disabled on the host")
]
)

Expand All @@ -2606,16 +2605,6 @@ let set_ntp_custom_servers =
]
~allowed_roles:_R_POOL_OP ()

let disable_ntp =
call ~name:"disable_ntp" ~lifecycle:[] ~doc:"Disable NTP on the host"
~params:[(Ref _host, "self", "The host")]
~allowed_roles:_R_POOL_OP ()

let enable_ntp =
call ~name:"enable_ntp" ~lifecycle:[] ~doc:"Enable NTP on the host"
~params:[(Ref _host, "self", "The host")]
~allowed_roles:_R_POOL_OP ()

let get_ntp_servers_status =
call ~name:"get_ntp_servers_status" ~lifecycle:[]
~doc:"Get the NTP servers status on the host"
Expand Down Expand Up @@ -2822,8 +2811,6 @@ let t =
; set_max_cstate
; set_ntp_mode
; set_ntp_custom_servers
; disable_ntp
; enable_ntp
; get_ntp_servers_status
; set_timezone
; list_timezones
Expand Down Expand Up @@ -3297,15 +3284,12 @@ let t =
~default_value:(Some (VBool false)) "secure_boot"
"Whether the host has booted in secure boot mode"
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:host_ntp_mode
~default_value:(Some (VEnum "ntp_mode_dhcp")) "ntp_mode"
~default_value:(Some (VEnum "Factory")) "ntp_mode"
"Indicates NTP servers are assigned by DHCP, or configured by \
user, or the default servers"
user, or the factory servers, or NTP is disabled"
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:(Set String)
~default_value:(Some (VSet [])) "ntp_custom_servers"
"The set of NTP servers configured for the host"
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:Bool
~default_value:(Some (VBool false)) "ntp_enabled"
"Reflects whether NTP is enabled on the host"
"Custom NTP servers configured by users, used in Custom NTP mode"
; field ~qualifier:DynamicRO ~lifecycle:[] ~ty:String
~default_value:(Some (VString "UTC")) "timezone"
"The time zone identifier as defined in the IANA Time Zone Database"
Expand Down
24 changes: 24 additions & 0 deletions ocaml/idl/datamodel_lifecycle.ml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,16 @@ let prototyped_of_field = function
Some "22.26.0"
| "SM", "host_pending_features" ->
Some "24.37.0"
| "host", "timezone" ->
Some "25.37.0-next"
| "host", "ntp_custom_servers" ->
Some "25.37.0-next"
| "host", "ntp_mode" ->
Some "25.37.0-next"
| "host", "secure_boot" ->
Some "25.31.0"
| "host", "max_cstate" ->
Some "25.37.0-next"
| "host", "ssh_auto_mode" ->
Some "25.27.0"
| "host", "console_idle_timeout" ->
Expand Down Expand Up @@ -225,6 +233,22 @@ let prototyped_of_message = function
Some "22.26.0"
| "VTPM", "create" ->
Some "22.26.0"
| "host", "set_servertime" ->
Some "25.37.0-next"
| "host", "get_ntp_synchronized" ->
Some "25.37.0-next"
| "host", "list_timezones" ->
Some "25.37.0-next"
| "host", "set_timezone" ->
Some "25.37.0-next"
| "host", "get_ntp_servers_status" ->
Some "25.37.0-next"
| "host", "set_ntp_custom_servers" ->
Some "25.37.0-next"
| "host", "set_ntp_mode" ->
Some "25.37.0-next"
| "host", "set_max_cstate" ->
Some "25.37.0-next"
| "host", "update_firewalld_service_status" ->
Some "25.34.0"
| "host", "get_tracked_user_agents" ->
Expand Down
2 changes: 1 addition & 1 deletion ocaml/idl/schematest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let hash x = Digest.string x |> Digest.to_hex
(* BEWARE: if this changes, check that schema has been bumped accordingly in
ocaml/idl/datamodel_common.ml, usually schema_minor_vsn *)

let last_known_schema_hash = "c72edb27945bceb074de3fa54381ddd4"
let last_known_schema_hash = "d8cb04ccddfd91ca3f0f9074dcf7c219"

let current_schema_hash : string =
let open Datamodel_types in
Expand Down
4 changes: 2 additions & 2 deletions ocaml/tests/common/test_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ let make_host2 ~__context ?(ref = Ref.make ()) ?(uuid = make_uuid ())
~pending_guidances_recommended:[] ~pending_guidances_full:[]
~last_update_hash:"" ~ssh_enabled:true ~ssh_enabled_timeout:0L
~ssh_expiry:Date.epoch ~console_idle_timeout:0L ~ssh_auto_mode:false
~max_cstate:"" ~secure_boot:false ~ntp_mode:`ntp_mode_dhcp
~ntp_custom_servers:[] ~ntp_enabled:false ~timezone:"UTC" ;
~max_cstate:"" ~secure_boot:false ~ntp_mode:`Factory ~ntp_custom_servers:[]
~timezone:"UTC" ;
ref

let make_pif ~__context ~network ~host ?(device = "eth0")
Expand Down
18 changes: 0 additions & 18 deletions ocaml/xapi-cli-server/cli_frontend.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1098,24 +1098,6 @@ let rec cmdtable_data : (string * cmd_spec) list =
; flags= [Neverforward]
}
)
; ( "host-enable-ntp"
, {
reqd= []
; optn= []
; help= "Enable ntp service on the host."
; implementation= No_fd Cli_operations.host_enable_ntp
; flags= [Host_selectors]
}
)
; ( "host-disable-ntp"
, {
reqd= []
; optn= []
; help= "Disable ntp service on the host."
; implementation= No_fd Cli_operations.host_disable_ntp
; flags= [Host_selectors]
}
)
; ( "patch-upload"
, {
reqd= ["file-name"]
Expand Down
20 changes: 0 additions & 20 deletions ocaml/xapi-cli-server/cli_operations.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7820,26 +7820,6 @@ let host_disable_ssh _printer rpc session_id params =
params []
)

let host_enable_ntp _printer rpc session_id params =
ignore
(do_host_op rpc session_id
(fun _ host ->
let host = host.getref () in
Client.Host.enable_ntp ~rpc ~session_id ~self:host
)
params []
)

let host_disable_ntp _printer rpc session_id params =
ignore
(do_host_op rpc session_id
(fun _ host ->
let host = host.getref () in
Client.Host.disable_ntp ~rpc ~session_id ~self:host
)
params []
)

module SDN_controller = struct
let introduce printer rpc session_id params =
let port =
Expand Down
3 changes: 0 additions & 3 deletions ocaml/xapi-cli-server/records.ml
Original file line number Diff line number Diff line change
Expand Up @@ -3423,9 +3423,6 @@ let host_record rpc session_id host =
)
)
()
; make_field ~name:"ntp_enabled"
~get:(fun () -> string_of_bool (x ()).API.host_ntp_enabled)
()
; make_field ~name:"timezone"
~get:(fun () -> (x ()).API.host_timezone)
~set:(fun value ->
Expand Down
14 changes: 1 addition & 13 deletions ocaml/xapi/message_forwarding.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4152,18 +4152,6 @@ functor
let remote_fn = Client.Host.set_ntp_custom_servers ~self ~value in
do_op_on ~local_fn ~__context ~host:self ~remote_fn

let enable_ntp ~__context ~self =
info "Host.enable_ntp: host='%s'" (host_uuid ~__context self) ;
let local_fn = Local.Host.enable_ntp ~self in
let remote_fn = Client.Host.enable_ntp ~self in
do_op_on ~local_fn ~__context ~host:self ~remote_fn

let disable_ntp ~__context ~self =
info "Host.disable_ntp: host='%s'" (host_uuid ~__context self) ;
let local_fn = Local.Host.disable_ntp ~self in
let remote_fn = Client.Host.disable_ntp ~self in
do_op_on ~local_fn ~__context ~host:self ~remote_fn

let get_ntp_servers_status ~__context ~self =
info "Host.get_ntp_servers_status: host = '%s'"
(host_uuid ~__context self) ;
Expand Down Expand Up @@ -4195,7 +4183,7 @@ functor
info "Host.set_servertime : host = '%s'; value = '%s'"
(host_uuid ~__context self)
(Clock.Date.to_rfc3339 value) ;
if Db.Host.get_ntp_enabled ~__context ~self then
if Db.Host.get_ntp_mode ~__context ~self <> `Disabled then
raise
(Api_errors.Server_error
(Api_errors.not_allowed_when_ntp_is_enabled, [Ref.string_of self])
Expand Down
12 changes: 6 additions & 6 deletions ocaml/xapi/xapi_globs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1425,9 +1425,9 @@ let nvidia_gpumon_detach = ref false

let failed_login_alert_freq = ref 3600

let default_ntp_servers = ref []
let factory_ntp_servers = ref []

let legacy_default_ntp_servers = ref []
let legacy_factory_ntp_servers = ref []

let other_options =
[
Expand Down Expand Up @@ -1916,16 +1916,16 @@ let other_options =
, (fun () -> !timedatectl)
, "Path to the timedatectl executable"
)
; gen_list_option "legacy-default-ntp-servers"
; gen_list_option "legacy-factory-ntp-servers"
"space-separated list of legacy default NTP servers"
(fun s -> s)
(fun s -> s)
legacy_default_ntp_servers
; gen_list_option "default-ntp-servers"
legacy_factory_ntp_servers
; gen_list_option "factory-ntp-servers"
"space-separated list of default NTP servers"
(fun s -> s)
(fun s -> s)
default_ntp_servers
factory_ntp_servers
]

(* The options can be set with the variable xapiflags in /etc/sysconfig/xapi.
Expand Down
Loading
Loading