From: Rob Hoes Date: Wed, 26 Jan 2011 17:39:05 +0000 (+0000) Subject: Do not hardcode the edition names in the bash completion file, but ask v6d X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=1b40b3b3d2d3a8f835025abf54ca8a3174674967;p=xcp%2Fxen-api.git Do not hardcode the edition names in the bash completion file, but ask v6d Signed-off-by: Rob Hoes --- diff --git a/ocaml/xapi/cli_frontend.ml b/ocaml/xapi/cli_frontend.ml index 2bf44024..5686ebed 100644 --- a/ocaml/xapi/cli_frontend.ml +++ b/ocaml/xapi/cli_frontend.ml @@ -1911,10 +1911,18 @@ add a mapping of 'path' -> '/tmp', the command line should contain the argument { reqd=["edition"]; optn=["host-uuid"; "license-server-address"; "license-server-port"]; - help="Change to another edition, or reactivate the current edition after a license has expired. This may be subject to the successful checkout of an appropriate license"; + help="Change to another edition, or reactivate the current edition after a license has expired. This may be subject to the successful checkout of an appropriate license."; implementation=No_fd Cli_operations.host_apply_edition; flags=[]; }; + "host-all-editions", + { + reqd=[]; + optn=[]; + help="Get a list of all available editions."; + implementation=No_fd Cli_operations.host_all_editions; + flags=[]; + }; "host-evacuate", { reqd=["uuid"]; diff --git a/ocaml/xapi/cli_operations.ml b/ocaml/xapi/cli_operations.ml index cd159eef..25c9ef87 100644 --- a/ocaml/xapi/cli_operations.ml +++ b/ocaml/xapi/cli_operations.ml @@ -2629,6 +2629,10 @@ let host_apply_edition printer rpc session_id params = raise e | e -> raise e +let host_all_editions printer rpc session_id params = + let editions = List.map (fun (e, _, _, _) -> e) (V6client.get_editions ()) in + printer (Cli_printer.PList editions) + let host_evacuate printer rpc session_id params = let uuid = List.assoc "uuid" params in let host = Client.Host.get_by_uuid rpc session_id uuid in diff --git a/ocaml/xe-cli/bash-completion b/ocaml/xe-cli/bash-completion index 5cb09c61..a4039fad 100755 --- a/ocaml/xe-cli/bash-completion +++ b/ocaml/xe-cli/bash-completion @@ -52,7 +52,8 @@ _xe() case "${COMP_WORDS[1]}" in diagnostic-vm-status) cmd=vm-list;; diagnostic-vdi-status) cmd=vdi-list;; - *) cmd=`echo ${COMP_WORDS[1]} | awk -F- '/^host-cpu-/ || /^host-crashdump-/ { print $1 "-" $2 } $0 !~ /^host-cpu-/ && $0 !~ /^host-crashdump-/ { print $1 }'`-list;; + *) cmd=`echo ${COMP_WORDS[1]} | awk -F- '/^host-cpu-/ || /^host-crashdump-/ { print $1 "-" $2 } +$0 !~ /^host-cpu-/ && $0 !~ /^host-crashdump-/ { print $1 }'`-list;; esac IFS=$'\n,' COMPREPLY=( $(compgen_names "$cmd" uuid "$value") ) @@ -220,11 +221,13 @@ _xe() COMPREPLY=( $(compgen -W "vm-power-admin,vm-admin,vm-operator,read-only,pool-operator,pool-admin" -- ${LAST_VALUE}) ) return 0 ;; - edition) # for host-apply-edition (licensing) - IFS=$'\n,' - COMPREPLY=( $(compgen -W "free ,enterprise ,platinum ,enterprise-xd " -- ${value}) ) - return 0 - ;; + edition) # for host-apply-edition (licensing) + IFS=$'\n,' + LAST_VALUE=`echo ${value}|gawk 'BEGIN{FS=" "}{print $NF}'` + EDITIONS=`${xe} host-all-editions --minimal 2>/dev/null` + COMPREPLY=( $(compgen -W "${EDITIONS}" -- ${LAST_VALUE}) ) + return 0 + ;; *) snd=`echo ${param} | cut -d- -f2` fst=`echo ${param} | cut -d- -f1`