@@ -1095,7 +1095,7 @@ let create ~__context ~uuid ~name_label ~name_description:_ ~hostname ~address
10951095 ~pending_guidances_recommended: [] ~pending_guidances_full: [] ~ssh_enabled
10961096 ~ssh_enabled_timeout ~ssh_expiry ~console_idle_timeout ~ssh_auto_mode
10971097 ~max_cstate: " " ~secure_boot ~ntp_mode: `ntp_mode_dhcp ~ntp_custom_servers: []
1098- ~ntp_enabled: false ;
1098+ ~ntp_enabled: false ~timezone: " UTC " ;
10991099 (* If the host we're creating is us, make sure its set to live *)
11001100 Db.Host_metrics. set_last_updated ~__context ~self: metrics ~value: (Date. now () ) ;
11011101 Db.Host_metrics. set_live ~__context ~self: metrics ~value: host_is_us ;
@@ -3561,3 +3561,23 @@ let get_ntp_servers_status ~__context ~self:_ =
35613561 Xapi_host_ntp. get_servers_status ()
35623562 else
35633563 []
3564+
3565+ let set_timezone ~__context ~self ~value =
3566+ try
3567+ let _ =
3568+ Helpers. call_script ! Xapi_globs. timedatectl [" set-timezone" ; value]
3569+ in
3570+ Db.Host. set_timezone ~__context ~self ~value
3571+ with
3572+ | Forkhelpers. Spawn_internal_error (stderr, _, _)
3573+ when String. starts_with ~prefix: " Failed to set time zone: Invalid" stderr ->
3574+ raise
3575+ (Api_errors. Server_error (Api_errors. invalid_value, [" timezone" ; value]))
3576+ | e ->
3577+ Helpers. internal_error " %s" (ExnHelper. string_of_exn e)
3578+
3579+ let list_timezones ~__context ~self :_ =
3580+ try
3581+ Helpers. call_script ! Xapi_globs. timedatectl [" list-timezones" ]
3582+ |> Astring.String. cuts ~empty: false ~sep: " \n "
3583+ with e -> Helpers. internal_error " %s" (ExnHelper. string_of_exn e)
0 commit comments