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 11 of 21] CP-1835: add optional task-uuid parameter to

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH 11 of 21] CP-1835: add optional task-uuid parameter to cli vm-export
From: Marcus Granado <marcus.granado@xxxxxxxxxx>
Date: Fri, 20 Aug 2010 17:52:30 +0100
Delivery-date: Fri, 20 Aug 2010 10:40:14 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1282323139@localhost>
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.1282323139@localhost>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
 ocaml/xapi/cli_operations.ml |  16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)


# HG changeset patch
# User Marcus Granado <marcus.granado@xxxxxxxxxx>
# Date 1282322886 -3600
# Node ID 5ed6061cd4377edb0e9d46a31a69fd9a1dabbf7a
# Parent  cf4fa3283659fb55b279c563e3a818ad8ddf7181
CP-1835: add optional task-uuid parameter to cli vm-export

Signed-off-by: Marcus Granado <marcus.granado@xxxxxxxxxxxxx>

diff -r cf4fa3283659 -r 5ed6061cd437 ocaml/xapi/cli_operations.ml
--- a/ocaml/xapi/cli_operations.ml
+++ b/ocaml/xapi/cli_operations.ml
@@ -3075,9 +3075,16 @@
     raise (Cli_util.Cli_failure "Need one of: vm-uuid, host-uuid, 
network-uuid, sr-uuid or pool-uuid")
 
     
-let export_common fd printer rpc session_id params filename num 
use_compression preserve_power_state vm =
+let export_common fd printer rpc session_id params filename num ?task_uuid 
use_compression preserve_power_state vm =
   let vm_record = vm.record () in
-  let exporttask = Client.Task.create rpc session_id (Printf.sprintf "Export 
of VM: %s" (vm_record.API.vM_uuid)) "" in
+  let exporttask, task_destroy_fn = 
+    match task_uuid with
+               | None -> (* manage task internally *)
+      let exporttask = Client.Task.create rpc session_id (Printf.sprintf 
"Export of VM: %s" (vm_record.API.vM_uuid)) "" in
+      (exporttask,(fun ()->Client.Task.destroy rpc session_id exporttask))
+               | Some task_uuid -> (* do not destroy the task that has been 
received *)
+                       ((Client.Task.get_by_uuid rpc session_id 
task_uuid),(fun ()->()))
+  in
   
   (* Initially mark the task progress as -1.0. The first thing the export 
handler does it to mark it as zero *)
   (* This is used as a flag to show that the 'ownership' of the task has been 
passed to the handler, and it's *)
@@ -3102,15 +3109,16 @@
                preserve_power_state)
         "Export";
         num := !num + 1)
-    (fun () -> Client.Task.destroy rpc session_id exporttask)
+    (fun () -> task_destroy_fn ())
     
 let vm_export fd printer rpc session_id params =
   let filename = List.assoc "filename" params in
   let use_compression = List.mem_assoc "compress" params && (List.assoc 
"compress" params = "true") in
   let preserve_power_state = List.mem_assoc "preserve-power-state" params && 
bool_of_string "preserve-power-state" (List.assoc "preserve-power-state" 
params) in
+  let task_uuid = if (List.mem_assoc "task-uuid" params) then Some (List.assoc 
"task-uuid" params) else None in
   let num = ref 1 in
   let op vm = 
-    export_common fd printer rpc session_id params filename num 
use_compression preserve_power_state vm
+    export_common fd printer rpc session_id params filename num ?task_uuid 
use_compression preserve_power_state vm
   in
   ignore(do_vm_op printer rpc session_id op params ["filename"; "metadata"; 
"compress"; "preserve-power-state"])
 

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

_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
<Prev in Thread] Current Thread [Next in Thread>