Skip to content

Commit 014f214

Browse files
committed
Add v6 interface
Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
1 parent 8ef6624 commit 014f214

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

v6/v6_client.ml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
(*
2+
* Copyright (C) Citrix Systems Inc.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
open V6_interface
16+
open Xcp_client
17+
18+
let retry_econnrefused f =
19+
let rec loop retry =
20+
let result =
21+
try
22+
Some (f ())
23+
with Unix.Unix_error((Unix.ECONNREFUSED | Unix.ENOENT), _, _) ->
24+
Thread.delay 1.;
25+
None in
26+
match result with
27+
| Some x -> x
28+
| None -> if retry then loop false else raise V6d_failure
29+
in
30+
loop true
31+
32+
module Client = V6_interface.Client(struct
33+
let rpc call =
34+
retry_econnrefused (fun () ->
35+
if !use_switch
36+
then json_switch_rpc !queue_name call
37+
else xml_http_rpc
38+
~srcstr:(Xcp_client.get_user_agent ())
39+
~dststr:"v6"
40+
V6_interface.uri
41+
call
42+
)
43+
end)
44+
45+
include Client

v6/v6_interface.ml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
(*
2+
* Copyright (C) Citrix Systems Inc.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published
6+
* by the Free Software Foundation; version 2.1 only. with the special
7+
* exception on linking described in file LICENSE.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*)
14+
15+
let service_name = "v6d"
16+
let queue_name = ref (Xcp_service.common_prefix ^ service_name)
17+
let default_sockets_dir = "/var/lib/xcp"
18+
let default_path = ref (Filename.concat default_sockets_dir service_name)
19+
let uri () = "file:" ^ !default_path
20+
21+
type debug_info = string
22+
23+
exception Invalid_edition of string
24+
exception V6d_failure
25+
exception License_expired
26+
exception License_processing_error
27+
exception Missing_connection_details
28+
exception License_checkout_error of string
29+
30+
(* dbg_str -> requested edition -> current params ->
31+
new edition * new xapi params * new additional params *)
32+
external apply_edition : debug_info -> string -> (string * string) list ->
33+
string * (string * string) list * (string * string) list = ""
34+
35+
(* dbg_str -> list of editions *)
36+
external get_editions : debug_info -> (string * (string * string * int)) list = ""
37+
38+
(* dbg_str -> result *)
39+
external get_version : debug_info -> string = ""

0 commit comments

Comments
 (0)