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] CA-43645: show VMPR snapshots in task list in xencente

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] CA-43645: show VMPR snapshots in task list in xencenter
From: Marcus Granado <marcus.granado@xxxxxxxxxx>
Date: Tue, 7 Sep 2010 14:42:00 +0100
Delivery-date: Tue, 07 Sep 2010 07:03:39 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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>
Sender: xen-api-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.4.3
 ocaml/xapi/xapi_vm_clone.ml    |  12 +-----------
 ocaml/xapi/xapi_vm_snapshot.ml |   3 +++
 ocaml/xapi/xapi_vmpp.ml        |  28 ++++++++++++++++++++++++++++
 3 files changed, 32 insertions(+), 11 deletions(-)


# HG changeset patch
# User Marcus Granado <marcus.granado@xxxxxxxxxx>
# Date 1283866374 -3600
# Node ID f9273c413c8ecdd2a8cb0104a8d8307b357deb6f
# Parent  75d9c25311cf1638ed2cb58a58f41138b706dcf0
CA-43645: show VMPR snapshots in task list in xencenter

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

diff -r 75d9c25311cf -r f9273c413c8e ocaml/xapi/xapi_vm_clone.ml
--- a/ocaml/xapi/xapi_vm_clone.ml
+++ b/ocaml/xapi/xapi_vm_clone.ml
@@ -249,17 +249,7 @@
 
   (* verify if this action is happening due to a VM protection policy *)
   let is_snapshot_from_vmpp =
-    (try
-      is_a_snapshot &&
-      (let session = Xapi_session.get_top ~__context 
~self:(Context.get_session_id __context) in
-       let uname = Db.Session.get_auth_user_name ~__context ~self:session in
-       let is_lsu = Db.Session.get_is_local_superuser ~__context ~self:session 
in
-       is_lsu && (uname = Xapi_vmpp.vmpr_username)
-      )
-               with e ->
-      debug "Error obtaining is_snapshot_from_vmpp: %s" (Printexc.to_string e);
-      false
-    )
+      is_a_snapshot && (Xapi_vmpp.is_snapshot_from_vmpp ~__context)
        in
 
        (* create a new VM *)
diff -r 75d9c25311cf -r f9273c413c8e ocaml/xapi/xapi_vm_snapshot.ml
--- a/ocaml/xapi/xapi_vm_snapshot.ml
+++ b/ocaml/xapi/xapi_vm_snapshot.ml
@@ -28,6 +28,7 @@
 let snapshot ~__context ~vm ~new_name =
        debug "Snapshot: begin";
        TaskHelper.set_cancellable ~__context;
+       Xapi_vmpp.show_task_in_xencenter ~__context;
        let res = Xapi_vm_clone.clone Xapi_vm_clone.Disk_op_snapshot ~__context 
~vm ~new_name in
        debug "Snapshot: end"; 
        res
@@ -128,6 +129,7 @@
 (* dynamically by the xapi_vm_lifecycle.update_allowed_operations call.        
          *)
 let snapshot_with_quiesce ~__context ~vm ~new_name =
        debug "snapshot_with_quiesce: begin";
+       Xapi_vmpp.show_task_in_xencenter ~__context;
        let domid = Int64.to_int (Db.VM.get_domid ~__context ~self:vm) in
        let result = Vmopshelpers.with_xs (fun xs ->
                (* 1. We first check if the VM supports quiesce-mode *)
@@ -173,6 +175,7 @@
        List.filter aux (Db.VM.get_VBDs ~__context ~self:vm)
 
 let checkpoint ~__context ~vm ~new_name =
+       Xapi_vmpp.show_task_in_xencenter ~__context;
        let power_state = Db.VM.get_power_state ~__context ~self:vm in
        with_xc_and_xs (fun xc xs ->
                let vbds = get_flushable_vbds ~__context vm in
diff -r 75d9c25311cf -r f9273c413c8e ocaml/xapi/xapi_vmpp.ml
--- a/ocaml/xapi/xapi_vmpp.ml
+++ b/ocaml/xapi/xapi_vmpp.ml
@@ -16,6 +16,7 @@
 
 let vmpr_plugin = "vmpr"
 let vmpr_username = "__dom0__vmpr"
+let vmpr_snapshot_other_config_show_in_xencenter = "ShowInXenCenter"
 
 let assert_licensed ~__context =
   if (not (Features.is_enabled ~__context Features.VMPR))
@@ -640,3 +641,30 @@
     Db.VMPP.destroy ~__context ~self
   )
 
+(* verify if this action is happening due to a VM protection policy *)
+let is_snapshot_from_vmpp ~__context =
+  try
+    (let session = Xapi_session.get_top ~__context 
~self:(Context.get_session_id __context) in
+     let uname = Db.Session.get_auth_user_name ~__context ~self:session in
+     let is_lsu = Db.Session.get_is_local_superuser ~__context ~self:session in
+     is_lsu && (uname = vmpr_username)
+    )
+  with e ->
+    debug "Error obtaining is_snapshot_from_vmpp: %s" (Printexc.to_string e);
+    false
+
+let show_task_in_xencenter ~__context =
+  if is_snapshot_from_vmpp ~__context then
+    (
+      let task = Context.get_task_id __context in
+      try
+        debug "show_in_xencenter: task=%s" (Ref.string_of task);
+        (* this key is used to make sure the snapshotting task *)
+        (* is seen from all xencenter clients *)
+        Db.Task.add_to_other_config ~__context ~self:task
+          ~key:vmpr_snapshot_other_config_show_in_xencenter
+          ~value:""
+      with e->
+        debug "Error adding other_config:show_in_xencenter to task %s: %s"
+          (Ref.string_of task) (Printexc.to_string e)
+    )

Attachment: xen-api.hg.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>
  • [Xen-API] [PATCH] CA-43645: show VMPR snapshots in task list in xencenter, Marcus Granado <=