Skip to content

Commit 94d24a9

Browse files
authored
xapi-stdext-date: replace all usages to use clock instead (xapi-project#6358)
Not deleting the package and aliasing its main type to Clock.Date.t allows for a smooth transition. In particular xenserver's license and clustering daemons can build without any source changes. Once this has been merge I'll open respective PRs to use Clock.Date.t, and another one to update xs-opam metadata, after which Xapi_stdext_date can be dropped completely.
2 parents 5ec5732 + 37b5f70 commit 94d24a9

File tree

115 files changed

+219
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+219
-242
lines changed

dune-project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@
338338
base64
339339
(bos :with-test)
340340
cdrom
341+
(clock (= :version))
341342
cmdliner
342343
cohttp
343344
conf-pam
@@ -398,7 +399,6 @@
398399
(xapi-idl (= :version))
399400
(xapi-inventory (= :version))
400401
(xapi-log (= :version))
401-
(xapi-stdext-date (= :version))
402402
(xapi-stdext-pervasives (= :version))
403403
(xapi-stdext-std (= :version))
404404
(xapi-stdext-threads (= :version))
@@ -604,6 +604,7 @@ This package provides an Lwt compatible interface to the library.")
604604
(alcotest :with-test)
605605
astring
606606
(base64 (>= "3.1.0"))
607+
(clock (= :version))
607608
fmt
608609
ipaddr
609610
mtime
@@ -619,7 +620,6 @@ This package provides an Lwt compatible interface to the library.")
619620
xapi-backtrace
620621
(xapi-idl (= :version))
621622
(xapi-log (= :version))
622-
(xapi-stdext-date (= :version))
623623
(xapi-stdext-pervasives (= :version))
624624
(xapi-stdext-threads (= :version))
625625
(xapi-tracing (= :version))

http-lib.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ depends: [
1313
"alcotest" {with-test}
1414
"astring"
1515
"base64" {>= "3.1.0"}
16+
"clock" {= version}
1617
"fmt"
1718
"ipaddr"
1819
"mtime"
@@ -28,7 +29,6 @@ depends: [
2829
"xapi-backtrace"
2930
"xapi-idl" {= version}
3031
"xapi-log" {= version}
31-
"xapi-stdext-date" {= version}
3232
"xapi-stdext-pervasives" {= version}
3333
"xapi-stdext-threads" {= version}
3434
"xapi-tracing" {= version}

ocaml/alerts/certificate/certificate_check.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module XenAPI = Client.Client
2-
module Date = Xapi_stdext_date.Date
2+
module Date = Clock.Date
33

44
type cert =
55
| CA of API.ref_Certificate * API.datetime

ocaml/alerts/certificate/certificate_check.mli

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
val alert : (Rpc.call -> Rpc.response) -> [< `session] Ref.t -> unit
1616

17-
(* Below exposed only for ease of testing *)
17+
(* Below exposed only for ease of testing, drop any documentation *)
18+
(**/**)
1819

1920
type cert =
2021
| CA of API.ref_Certificate * API.datetime
@@ -25,11 +26,11 @@ val certificate_description : cert -> string
2526

2627
val alert_conditions : cert -> (int * (string * int64)) list
2728

28-
val get_expiry : cert -> Xapi_stdext_date.Date.t
29+
val get_expiry : cert -> Clock.Date.t
2930

3031
val maybe_generate_alert :
31-
Xapi_stdext_date.Date.t
32+
Clock.Date.t
3233
-> string
3334
-> (int * (string * int64)) list
34-
-> Xapi_stdext_date.Date.t
35+
-> Clock.Date.t
3536
-> (string * (string * int64)) option

ocaml/alerts/certificate/dune

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
(modes best)
55
(libraries
66
astring
7+
ptime
78
xapi-expiry-alerts
89
xapi-client
910
xapi-consts
1011
xapi-types
11-
xapi-stdext-date
12+
clock
1213
)
1314
)
1415

@@ -18,7 +19,7 @@
1819
(modules certificate_check_main)
1920
(libraries
2021
certificate_check
21-
22+
2223
http_lib
2324
xapi-client
2425
xapi-types

ocaml/alerts/dune

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
(name expiry_alert)
33
(public_name xapi-expiry-alerts)
44
(libraries
5+
clock
56
xapi-client
67
xapi-types
7-
xapi-stdext-date
88
)
99
)

ocaml/alerts/expiry_alert.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*)
1414

1515
module XenAPI = Client.Client
16-
module Date = Xapi_stdext_date.Date
16+
module Date = Clock.Date
1717

1818
type message_name = string
1919

@@ -37,7 +37,7 @@ type raw_alert = {
3737
; obj_uuid: string
3838
; obj_description: string
3939
; alert_conditions: (remaining_days * message_id) list
40-
; expiry: Xapi_stdext_date.Date.t (* when the obj will expire *)
40+
; expiry: Date.t (* when the obj will expire *)
4141
}
4242

4343
let seconds_per_day = 3600. *. 24.
@@ -87,7 +87,7 @@ let filter_messages msg_name_list msg_obj_uuid alert all_msgs =
8787
)
8888

8989
let alert ~rpc ~session_id raw_alerts =
90-
let now = Date.now () in
90+
let now = Clock.Date.now () in
9191
let all_msgs = all_messages rpc session_id in
9292
List.iter
9393
(fun {cls; obj_uuid; obj_description; alert_conditions; expiry} ->

ocaml/alerts/expiry_alert.mli

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ type raw_alert = {
5555
* sent, and when it has expired, message "host_server_certificate_expired"
5656
* should be sent.
5757
*)
58-
; expiry: Xapi_stdext_date.Date.t
58+
; expiry: Clock.Date.t
5959
(* the last second when the obj is valid, it will expire in the next second *)
6060
}
6161

@@ -69,17 +69,17 @@ val alert :
6969

7070
(* Below exposed only for ease of testing *)
7171

72-
val message_body : string -> Xapi_stdext_date.Date.t -> string
72+
val message_body : string -> Clock.Date.t -> string
7373

7474
val expired_message : string -> string
7575

7676
val expiring_message : string -> string
7777

7878
val maybe_generate_alert :
79-
Xapi_stdext_date.Date.t
79+
Clock.Date.t
8080
-> string
8181
-> (remaining_days * message_id) list
82-
-> Xapi_stdext_date.Date.t
82+
-> Clock.Date.t
8383
-> (string * message_id) option
8484
(** An inner function exposed only for ease of testing, it returns None if there is no
8585
need for an expiry alert as it is not expiring or expired yet, otherwise an "alert"

ocaml/forkexecd/lib/dune

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
xapi-log
1616
xapi-stdext-pervasives
1717
xapi-stdext-unix
18-
xapi-stdext-date
1918
xapi-tracing
2019
)
2120
(preprocess (per_module ((pps ppx_deriving_rpc) Fe))))

ocaml/forkexecd/lib/fe_systemctl.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ let exists ~service = Sys.file_exists (path service)
139139
(** creation time of [path] as a string *)
140140
let ctime path =
141141
let ctime = Unix.((stat path).st_ctime) in
142-
Xapi_stdext_date.Date.(of_unix_time ctime |> to_rfc3339)
142+
Clock.Date.(of_unix_time ctime |> to_rfc3339)
143143

144144
let start_transient ?env ?properties ?(exec_ty = Type.Simple) ~service cmd args
145145
=

0 commit comments

Comments
 (0)