WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-api

[Xen-API] [PATCH 16 of 17] Do not hardcode the edition names in the bash

To: xen-api@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-API] [PATCH 16 of 17] Do not hardcode the edition names in the bash completion file, but ask v6d
From: Rob Hoes <rob.hoes@xxxxxxxxxx>
Date: Fri, 7 Jan 2011 16:57:59 +0000
Delivery-date: Fri, 07 Jan 2011 09:29:39 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1294419463@xxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-api-request@lists.xensource.com?subject=help>
List-id: Discussion of API issues surrounding Xen <xen-api.lists.xensource.com>
List-post: <mailto:xen-api@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-api>, <mailto:xen-api-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1294419463@xxxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.3
Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>


# HG changeset patch
# User Rob Hoes <rob.hoes@xxxxxxxxxx>
# Date 1294419412 0
# Node ID 9e99160603a3f19a762cc5c4e46b6f2ca2b092b3
# Parent  ede19e107342daa6cef1ae67ece70a73eacc5c8c
Do not hardcode the edition names in the bash completion file, but ask v6d

Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx>

diff -r ede19e107342 -r 9e99160603a3 ocaml/xapi/cli_frontend.ml
--- a/ocaml/xapi/cli_frontend.ml
+++ b/ocaml/xapi/cli_frontend.ml
@@ -1911,10 +1911,18 @@
     {
       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 -r ede19e107342 -r 9e99160603a3 ocaml/xapi/cli_operations.ml
--- a/ocaml/xapi/cli_operations.ml
+++ b/ocaml/xapi/cli_operations.ml
@@ -2629,6 +2629,10 @@
                        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 -r ede19e107342 -r 9e99160603a3 ocaml/xe-cli/bash-completion
--- a/ocaml/xe-cli/bash-completion
+++ b/ocaml/xe-cli/bash-completion
@@ -52,7 +52,8 @@
                                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 @@
                                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`

Attachment: xen-api.hg-16.patch
Description: Text Data

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api