Skip to content

Commit 04bc425

Browse files
committed
Raise the logging of destructive xe cli to info level
... usually such commands are leads of series of actions. Signed-off-by: Zheng Li <[email protected]>
1 parent c58598d commit 04bc425

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

ocaml/xapi/xapi_cli.ml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ let do_help cmd minimal s =
134134
flush ();
135135
marshal s (Command (Exit 0))
136136

137+
let uninteresting_cmd_postfixes = [ "help"; "-get"; "-list" ]
138+
137139
let exec_command req cmd s session args =
138140
let params = get_params cmd in
139141
let minimal =
@@ -147,15 +149,18 @@ let exec_command req cmd s session args =
147149
Cli_frontend.populate_cmdtable rpc Ref.null;
148150
(* Log the actual CLI command to help diagnose failures like CA-25516 *)
149151
let cmd_name = get_cmdname cmd in
150-
if String.startswith "secret-" cmd_name
151-
then
152-
debug "xe %s %s" cmd_name (String.concat " " (List.map (fun (k, v) -> let v' = if k = "value" then "(omitted)" else v in k ^ "=" ^ v') params))
152+
if cmd_name = "help" then do_help cmd minimal s
153153
else
154-
debug "xe %s %s" cmd_name (String.concat " " (List.map (fun (k, v) -> k ^ "=" ^ v) params));
155-
if cmd_name = "help"
156-
then do_help cmd minimal s
157-
else do_rpcs req s u p minimal cmd session args
158-
154+
let uninteresting =
155+
List.exists
156+
(fun k -> String.endswith k cmd_name) uninteresting_cmd_postfixes in
157+
let do_log = if uninteresting then debug else info in
158+
if String.startswith "secret-" cmd_name
159+
then
160+
do_log "xe %s %s" cmd_name (String.concat " " (List.map (fun (k, v) -> let v' = if k = "value" then "(omitted)" else v in k ^ "=" ^ v') params))
161+
else
162+
do_log "xe %s %s" cmd_name (String.concat " " (List.map (fun (k, v) -> k ^ "=" ^ v) params));
163+
do_rpcs req s u p minimal cmd session args
159164

160165
let get_line str i =
161166
try

0 commit comments

Comments
 (0)