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] CP-1833: fix check for lsu vmpr during snapshot in sla

To: xen-api <xen-api@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-API] [PATCH] CP-1833: fix check for lsu vmpr during snapshot in slaves
From: Marcus Granado <marcus.granado@xxxxxxxxxx>
Date: Wed, 1 Sep 2010 11:20:31 +0100
Delivery-date: Wed, 01 Sep 2010 03:31:40 -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_session.ml  |  22 ++++++++++++++++++++++
 ocaml/xapi/xapi_session.mli |   1 +
 ocaml/xapi/xapi_vm_clone.ml |   2 +-
 3 files changed, 24 insertions(+), 1 deletions(-)


# HG changeset patch
# User Marcus Granado <marcus.granado@xxxxxxxxxx>
# Date 1283276475 -3600
# Node ID 30021d67bb3e7620c9ce6b551a0f3a394951ac94
# Parent  07042ce11840f5c534d0637054e2584deea7f307
CP-1833: fix check for lsu vmpr during snapshot in slaves

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

diff -r 07042ce11840 -r 30021d67bb3e ocaml/xapi/xapi_session.ml
--- a/ocaml/xapi/xapi_session.ml
+++ b/ocaml/xapi/xapi_session.ml
@@ -691,3 +691,25 @@
        (* kill all filtered sessions *)
        List.iter (fun s -> destroy_db_session ~__context ~self:s) sessions
 
+
+(* returns the ancestry chain of session s, starting with s *)
+let rec get_ancestry ~__context ~self =
+  if (self=Ref.null) then [] (* top of session tree *)
+  else (
+    let parent =
+      try Db.Session.get_parent ~__context ~self
+      with e->
+        debug "error %s getting ancestry for session %s"
+          (ExnHelper.string_of_exn e) (trackid self)
+        ;
+        Ref.null
+    in
+      self::(get_ancestry ~__context ~self:parent)
+  )
+
+(* returns the original session up the ancestry chain that created s *)
+let get_top ~__context ~self =
+  let ancestry = get_ancestry ~__context ~self in
+  match ancestry with
+  | [] -> Ref.null
+  | ancestry -> List.nth ancestry ((List.length ancestry)-1)
diff -r 07042ce11840 -r 30021d67bb3e ocaml/xapi/xapi_session.mli
--- a/ocaml/xapi/xapi_session.mli
+++ b/ocaml/xapi/xapi_session.mli
@@ -34,3 +34,4 @@
 val get_group_subject_identifier_from_session: __context:Context.t -> 
session:[ `session ] Ref.t -> string
 val get_all_subject_identifiers: __context:Context.t -> string list
 val logout_subject_identifier: __context:Context.t -> 
subject_identifier:string -> unit
+val get_top: __context:Context.t -> self:API.ref_session -> API.ref_session
diff -r 07042ce11840 -r 30021d67bb3e ocaml/xapi/xapi_vm_clone.ml
--- a/ocaml/xapi/xapi_vm_clone.ml
+++ b/ocaml/xapi/xapi_vm_clone.ml
@@ -251,7 +251,7 @@
   let is_snapshot_from_vmpp =
     (try
       is_a_snapshot &&
-      (let session = Context.get_session_id __context in
+      (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)

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>