(* 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)
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
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)