Skip to content

Commit

Permalink
MVD CP-52334 multi-version driver API/CLI - improve records
Browse files Browse the repository at this point in the history
Use more existing functions to format records.

Signed-off-by: Christian Lindig <[email protected]>
  • Loading branch information
Christian Lindig committed Jan 16, 2025
1 parent c9d69bc commit 21dd993
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions ocaml/xapi-cli-server/records.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5449,9 +5449,12 @@ let host_driver_record rpc session_id host_driver =
()
; make_field ~name:"variants"
~get:(fun () ->
map_and_concat
(fun _, v -> Printf.sprintf "%s/%s" v.API.driver_variant_name v.API.driver_variant_version)
(xv ())
map_and_concat
(fun (_, v) ->
Printf.sprintf "%s/%s" v.API.driver_variant_name
v.API.driver_variant_version
)
(xv ())
)
()
; make_field ~name:"variants-dev-status"
Expand All @@ -5471,19 +5474,25 @@ let host_driver_record rpc session_id host_driver =
()
; make_field ~name:"variants-uuid"
~get:(fun () ->
map_and_concat
(fun _, v -> Printf.sprintf "%s/%s" v.API.driver_variant_name v.API.driver_variant_uuid)
(xv ())
map_and_concat
(fun (_, v) ->
Printf.sprintf "%s/%s" v.API.driver_variant_name
v.API.driver_variant_uuid
)
(xv ())
)
()
; make_field ~name:"variants-hw-present"
~get:(fun () ->
map_filter_and_concat (fun _, v ->
if v.API.driver_variant_hardware_present then
Some v.API.driver_variant_name
else
None
)
(xv ())
xv ()
|> List.map (fun (_, v) ->
( v.API.driver_variant_name
, v.API.driver_variant_version
, v.API.driver_variant_hardware_present
)
)
|> List.filter (fun (_, _, status) -> status = true)
|> map_and_concat (fun (name, _, _) -> name)
)
()
]
Expand Down

0 comments on commit 21dd993

Please sign in to comment.