Skip to content

Commit

Permalink
Merge pull request xapi-project#5 from johnelse/ca-180015
Browse files Browse the repository at this point in the history
CA-180015: Log state of copying mirrors
  • Loading branch information
johnelse committed Sep 3, 2015
2 parents 4ef853c + 6d60f62 commit 88ce44c
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ module Opt = struct
let map f = function None -> None | Some x -> Some (f x)
end

let string_of_mirror id {Mirror.source_vdi; dest_vdi; state; failed} =
let open Storage_interface.Mirror in
Printf.sprintf
"id: %s\nsrc_vdi: %s\ndest_vdi: %s\nstatus: %s\nfailed: %b\n"
id source_vdi dest_vdi
(String.concat ","
(List.map
(function
| Receiving -> "Receiving"
| Sending -> "Sending"
| Copying -> "Copying")
state))
failed

let old_main () =
if Array.length Sys.argv < 2 then usage_and_exit ();
(* Look for url=foo *)
Expand Down Expand Up @@ -165,14 +179,9 @@ let old_main () =
Client.DATA.MIRROR.stop ~dbg ~id
| [ "mirror-list"; ] ->
let list = Client.DATA.MIRROR.list ~dbg in
let open Storage_interface.Mirror in
List.iter (fun (id,status) ->
Printf.printf "id: %s\nsrc_vdi: %s\ndest_vdi: %s\nstatus: %s\nfailed: %b\n"
id
status.source_vdi
status.dest_vdi
(String.concat "," (List.map (fun s -> match s with | Receiving -> "Receiving" | Sending -> "Sending") status.state))
status.failed) list
List.iter
(fun (id,status) -> Printf.printf "%s" (string_of_mirror id status))
list
| [ "task-list" ] ->
let tasks = Client.TASK.list ~dbg in
let open Storage_interface.Task in
Expand Down Expand Up @@ -288,14 +297,11 @@ let string_of_file filename =
Buffer.contents output

let mirror_list common_opts =
wrap common_opts (fun () ->
let list = Client.DATA.MIRROR.list ~dbg in
let open Storage_interface.Mirror in
List.iter (fun (id,status) ->
Printf.printf "id: %s\nsrc_vdi: %s\ndest_vdi: %s\nstatus: %s\nfailed: %b\n"
id status.source_vdi status.dest_vdi
(String.concat "," (List.map (fun s -> match s with | Receiving -> "Receiving" | Sending -> "Sending") status.state))
status.failed) list)
wrap common_opts (fun () ->
let list = Client.DATA.MIRROR.list ~dbg in
List.iter
(fun (id,status) -> Printf.printf "%s" (string_of_mirror id status))
list)

let sr_attach common_opts sr device_config = match sr with
| None -> `Error(true, "must supply SR")
Expand Down

0 comments on commit 88ce44c

Please sign in to comment.