Skip to content

Commit

Permalink
fixup! MVD CP-52334 multi-version driver API/CLI
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Lindig <[email protected]>
  • Loading branch information
Christian Lindig committed Dec 6, 2024
1 parent 293874b commit 36118b3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 25 deletions.
8 changes: 1 addition & 7 deletions ocaml/xapi/xapi_host_driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ module DriverSet = Set.Make (String)
*)
module T = Xapi_host_driver_tool

let with_lock = Xapi_stdext_threads.Threadext.Mutex.execute

let selection_mutex = Mutex.create ()

let ( // ) = Filename.concat

let invalid_value field value =
raise Api_errors.(Server_error (invalid_value, [field; value]))

Expand All @@ -43,7 +37,7 @@ let internal_error fmt =
let drivertool args =
let path = !Xapi_globs.driver_tool in
try
let stdout, stderr = Forkhelpers.execute_command_get_output path args in
let stdout, _stderr = Forkhelpers.execute_command_get_output path args in
debug "%s: executed %s %s" __FUNCTION__ path (String.concat " " args) ;
stdout
with e ->
Expand Down
36 changes: 18 additions & 18 deletions ocaml/xapi/xapi_host_driver_tool.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ module J = struct
| e ->
R.error (Printexc.to_string e)

let keys = wrap U.keys
let _keys = wrap U.keys

let values = wrap U.values
let _values = wrap U.values

let combine = wrap2 U.combine
let _combine = wrap2 U.combine

let member key json =
match U.member key json with
Expand All @@ -115,39 +115,39 @@ module J = struct
| exception e ->
R.error (Printexc.to_string e)

let path = wrap2 U.path
let _path = wrap2 U.path

let index = wrap2 U.index
let _index = wrap2 U.index

let map = wrap2 U.map
let _map = wrap2 U.map

let to_assoc = wrap U.to_assoc

let to_option f = wrap (U.to_option f)
let _to_option f = wrap (U.to_option f)

let to_bool = wrap U.to_bool

let to_bool_option = wrap U.to_bool_option
let _to_bool_option = wrap U.to_bool_option

let to_number = wrap U.to_number

let to_number_option = wrap U.to_number_option
let _to_number_option = wrap U.to_number_option

let to_float = wrap U.to_float
let _to_float = wrap U.to_float

let to_float_option = wrap U.to_float_option
let _to_float_option = wrap U.to_float_option

let to_int = wrap U.to_int
let _to_int = wrap U.to_int

let to_int_option = wrap U.to_int_option
let _to_int_option = wrap U.to_int_option

let to_list = wrap U.to_list
let _to_list = wrap U.to_list

let to_string = wrap U.to_string

let to_string_option = wrap U.to_string_option

let convert_each f = wrap (U.convert_each f)
let _convert_each f = wrap (U.convert_each f)
end

(** combinators for results and accessing members in JSON objects *)
Expand All @@ -161,7 +161,7 @@ let ( |. ) json key = json |> J.member key

(** combine a list of ok list of oks into an ok list:
('a, 'b) result list -> ('a list, 'b) result. *)
let combine results =
let _combine results =
let rec loop acc = function
| [] ->
R.Ok (List.rev acc)
Expand All @@ -185,9 +185,9 @@ let combine_assoc results =
in
loop [] results

let protocol json = json |. "protocol" ||. "version" ||> J.to_string
let _protocol json = json |. "protocol" ||. "version" ||> J.to_string

let operation json = json |. "operation" ||. "reboot" ||> J.to_bool
let _operation json = json |. "operation" ||. "reboot" ||> J.to_bool

let variant json =
let* version = json |. "version" ||> J.to_string in
Expand Down

0 comments on commit 36118b3

Please sign in to comment.