Skip to content

Commit

Permalink
Raise the logging of destructive xe cli to info level
Browse files Browse the repository at this point in the history
... usually such commands are leads of series of actions.

Signed-off-by: Zheng Li <zheng.li@eu.citrix.com>
  • Loading branch information
zli committed Jan 5, 2012
1 parent 9300a8a commit 2ebd09b
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions ocaml/xapi/xapi_cli.ml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ let do_help cmd minimal s =
flush ();
marshal s (Command (Exit 0))

let uninteresting_cmd_postfixes = [ "help"; "-get"; "-list" ]

let exec_command req cmd s session args =
let params = get_params cmd in
let minimal =
Expand All @@ -147,15 +149,18 @@ let exec_command req cmd s session args =
Cli_frontend.populate_cmdtable rpc Ref.null;
(* Log the actual CLI command to help diagnose failures like CA-25516 *)
let cmd_name = get_cmdname cmd in
if String.startswith "secret-" cmd_name
then
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))
if cmd_name = "help" then do_help cmd minimal s
else
debug "xe %s %s" cmd_name (String.concat " " (List.map (fun (k, v) -> k ^ "=" ^ v) params));
if cmd_name = "help"
then do_help cmd minimal s
else do_rpcs req s u p minimal cmd session args

let uninteresting =
List.exists
(fun k -> String.endswith k cmd_name) uninteresting_cmd_postfixes in
let do_log = if uninteresting then debug else info in
if String.startswith "secret-" cmd_name
then
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))
else
do_log "xe %s %s" cmd_name (String.concat " " (List.map (fun (k, v) -> k ^ "=" ^ v) params));
do_rpcs req s u p minimal cmd session args

let get_line str i =
try
Expand Down

0 comments on commit 2ebd09b

Please sign in to comment.