[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-API] [PATCH] CP-1833: fix check for lsu vmpr during snapshot in slaves
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 1283866374 -3600 # Node ID cf1c91fb04c36e206c1728a05df50d2951ca3e2a # Parent 58cd7e67e97ac61aae732458a0ca67c4f5d42477 CP-1833: fix check for lsu vmpr during snapshot in slaves Signed-off-by: Marcus Granado <marcus.granado@xxxxxxxxxxxxx> diff -r 58cd7e67e97a -r cf1c91fb04c3 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 58cd7e67e97a -r cf1c91fb04c3 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 58cd7e67e97a -r cf1c91fb04c3 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 _______________________________________________ xen-api mailing list xen-api@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/mailman/listinfo/xen-api
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |