From 98b55d6af5126de8b7f01ee1a60d08e6782e3808 Mon Sep 17 00:00:00 2001 From: Ming Lu Date: Tue, 27 Feb 2024 10:30:00 +0800 Subject: [PATCH] Revert "CP-45572: Print update guidance in xe host-apply-updates" This reverts commit 6668d5f5609eb75a50b7dd4138412e6bf9a732bd. Signed-off-by: Ming Lu --- ocaml/xapi-cli-protocol/cli_protocol.ml | 10 +------ ocaml/xapi-cli-server/cli_frontend.ml | 2 +- ocaml/xapi-cli-server/cli_operations.ml | 35 ++++++++----------------- ocaml/xe-cli/newcli.ml | 17 ------------ 4 files changed, 13 insertions(+), 51 deletions(-) diff --git a/ocaml/xapi-cli-protocol/cli_protocol.ml b/ocaml/xapi-cli-protocol/cli_protocol.ml index 261bc11b187..38d0f76871c 100644 --- a/ocaml/xapi-cli-protocol/cli_protocol.ml +++ b/ocaml/xapi-cli-protocol/cli_protocol.ml @@ -35,7 +35,6 @@ type command = | Load of string (* filename *) | HttpGet of string * string (* filename * path *) | PrintHttpGetJson of string (* path *) - | PrintUpdateGuidance of string (* path *) | HttpPut of string * string (* filename * path *) | HttpConnect of string (* path *) | Prompt (* request the user enter some text *) @@ -70,8 +69,6 @@ let string_of_command = function "HttpGet " ^ path ^ " -> " ^ filename | PrintHttpGetJson path -> "PrintHttpGetJson " ^ path ^ " -> stdout" - | PrintUpdateGuidance path -> - "PrintUpdateGuidance " ^ path ^ " -> stdout" | HttpPut (filename, path) -> "HttpPut " ^ path ^ " -> " ^ filename | HttpConnect path -> @@ -161,7 +158,7 @@ let unmarshal_list pos f = (*****************************************************************************) (* Marshal/Unmarshal higher-level messages *) -(* Highest command id: 19 *) +(* Highest command id: 18 *) let marshal_command = function | Print x -> @@ -174,8 +171,6 @@ let marshal_command = function marshal_int 12 ^ marshal_string a ^ marshal_string b | PrintHttpGetJson a -> marshal_int 18 ^ marshal_string a - | PrintUpdateGuidance a -> - marshal_int 19 ^ marshal_string a | HttpPut (a, b) -> marshal_int 13 ^ marshal_string a ^ marshal_string b | HttpConnect a -> @@ -229,9 +224,6 @@ let unmarshal_command pos = | 18 -> let a, pos = unmarshal_string pos in (PrintHttpGetJson a, pos) - | 19 -> - let a, pos = unmarshal_string pos in - (PrintUpdateGuidance a, pos) | n -> raise (Unknown_tag ("command", n)) diff --git a/ocaml/xapi-cli-server/cli_frontend.ml b/ocaml/xapi-cli-server/cli_frontend.ml index 55d884db9d8..09ce4f79dfb 100644 --- a/ocaml/xapi-cli-server/cli_frontend.ml +++ b/ocaml/xapi-cli-server/cli_frontend.ml @@ -1032,7 +1032,7 @@ let rec cmdtable_data : (string * cmd_spec) list = reqd= ["hash"] ; optn= [] ; help= "Apply updates from enabled repository on specified host." - ; implementation= With_fd Cli_operations.host_apply_updates + ; implementation= No_fd Cli_operations.host_apply_updates ; flags= [Host_selectors] } ) diff --git a/ocaml/xapi-cli-server/cli_operations.ml b/ocaml/xapi-cli-server/cli_operations.ml index 6766a5161f0..c3876aff009 100644 --- a/ocaml/xapi-cli-server/cli_operations.ml +++ b/ocaml/xapi-cli-server/cli_operations.ml @@ -7641,32 +7641,19 @@ let print_avail_updates ~rpc ~session_id ~fd ~host = PrintHttpGetJson (get_avail_updates_uri ~session_id ~task ~host) ) -let print_update_guidance ~rpc ~session_id ~fd ~host = - command_in_task ~rpc ~session_id ~fd ~obj:host - ~label:"Print update guidance for host" ~quiet_on_success:true - (fun session_id task host -> - PrintUpdateGuidance (get_avail_updates_uri ~session_id ~task ~host) - ) - -let host_apply_updates fd printer rpc session_id params = +let host_apply_updates _printer rpc session_id params = let hash = List.assoc "hash" params in - do_host_op rpc session_id ~multiple:false - (fun _ host -> - let host = host.getref () in - printer (Cli_printer.PMsg "Guidance of updates:") ; - print_update_guidance ~rpc ~session_id ~fd ~host ; - printer (Cli_printer.PMsg "Applying updates ...") ; - match Client.Host.apply_updates ~rpc ~session_id ~self:host ~hash with - | [] -> - printer (Cli_printer.PMsg "Updated.") - | warnings -> - printer (Cli_printer.PMsg "Updated with warnings:") ; - List.iter - (fun l -> printer (Cli_printer.PMsg (String.concat "; " l))) - warnings + ignore + (do_host_op rpc session_id ~multiple:false + (fun _ host -> + let host = host.getref () in + Client.Host.apply_updates ~rpc ~session_id ~self:host ~hash + |> List.iter (fun l -> + _printer (Cli_printer.PMsg (String.concat "; " l)) + ) + ) + params ["hash"] ) - params ["hash"] - |> ignore let host_updates_show_available fd _printer rpc session_id params = do_host_op rpc session_id ~multiple:false diff --git a/ocaml/xe-cli/newcli.ml b/ocaml/xe-cli/newcli.ml index 7c07c199512..7dddf2ee359 100644 --- a/ocaml/xe-cli/newcli.ml +++ b/ocaml/xe-cli/newcli.ml @@ -773,23 +773,6 @@ let main_loop ifd ofd permitted_filenames = |> print_endline ; flush stdout ) - | Command (PrintUpdateGuidance url) -> - do_http_get ofd url exit_code (fun ic -> - while input_line ic <> "\r" do - () - done ; - Yojson.Basic.from_channel ic |> Yojson.Basic.Util.member "hosts" - |> function - | `List [] -> - raise (ClientSideError "No host data returned") - | `List (host :: _) -> - Yojson.Basic.Util.member "guidance" host - |> Yojson.Basic.pretty_to_string - |> print_endline ; - flush stdout - | _ -> - raise (ClientSideError "Unknown data format") - ) | Command Prompt -> let data = input_line stdin in marshal ofd (Blob (Chunk (Int32.of_int (String.length data)))) ;