]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
Do not hardcode the edition names in the bash completion file, but ask v6d
authorRob Hoes <rob.hoes@citrix.com>
Wed, 26 Jan 2011 17:39:05 +0000 (17:39 +0000)
committerRob Hoes <rob.hoes@citrix.com>
Wed, 26 Jan 2011 17:39:05 +0000 (17:39 +0000)
Signed-off-by: Rob Hoes <rob.hoes@citrix.com>
ocaml/xapi/cli_frontend.ml
ocaml/xapi/cli_operations.ml
ocaml/xe-cli/bash-completion

index 2bf44024a194abe70483e3856a601b22df54a4e9..5686ebede72b643f12530ee6984e172667039496 100644 (file)
@@ -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"];
index cd159eef96a08be33a3ecec86d45b5e361e87823..25c9ef87e022f59c634e072b2f8789a3febd643e 100644 (file)
@@ -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
index 5cb09c614d071c808dac55ce7d11e5cc59b1f666..a4039fad9cde6a127fa6e33f82437dfe7c2b2f25 100755 (executable)
@@ -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 }\r$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`