Permalink
Browse files

CA-90263: Improve efficiency of Cancel_tasks.update_all_allowed_opera…

…tions.

Instead of calling Xapi_vdi.update_allowed_operations, call
Xapi_vdi.update_allowed_operations_internal and pass in cached lists of
SR, PBD and VBD records.

Signed-off-by: John Else <john.else@citrix.com>
  • Loading branch information...
johnelse authored and jonludlam committed Sep 20, 2012
1 parent 43e05b7 commit 3569d51def968a82f4548eb2ea4cbd74f51f9a2d
Showing with 6 additions and 1 deletion.
  1. +6 −1 ocaml/xapi/cancel_tasks.ml
@@ -29,6 +29,7 @@ let update_all_allowed_operations ~__context =
and all_vifs = Db.VIF.get_all ~__context
and all_vdis = Db.VDI.get_all ~__context
and all_srs = Db.SR.get_all ~__context
+ and all_pbds = Db.PBD.get_all ~__context
and all_hosts = Db.Host.get_all ~__context in
debug "Updating allowed operations: VM";
List.iter (safe_wrapper "allowed_ops - VMs" (fun self -> Xapi_vm_lifecycle.update_allowed_operations ~__context ~self)) all_vms;
@@ -40,7 +41,11 @@ let update_all_allowed_operations ~__context =
List.iter (safe_wrapper "allowed_ops - VIFs" (fun self -> Xapi_vif_helpers.update_allowed_operations ~__context ~self)) all_vifs;
debug "Finished updating allowed operations: VIF";
debug "Updating allowed operations: VDI";
- List.iter (safe_wrapper "allowed_ops - VDIs" (fun self -> Xapi_vdi.update_allowed_operations ~__context ~self)) all_vdis;
+ let sr_records = List.map (fun sr -> (sr, Db.SR.get_record_internal ~__context ~self:sr)) all_srs in
+ let pbd_records = List.map (fun pbd -> (pbd, Db.PBD.get_record ~__context ~self:pbd)) all_pbds in
+ let vbd_records = List.map (fun vbd -> (vbd, Db.VBD.get_record_internal ~__context ~self:vbd)) all_vbds in
+ List.iter (safe_wrapper "allowed_ops - VDIs"
+ (fun self -> Xapi_vdi.update_allowed_operations_internal ~__context ~self ~sr_records ~pbd_records ~vbd_records)) all_vdis;
debug "Finished updating allowed operations: VDI";
debug "Updating allowed operations: SR";
List.iter (safe_wrapper "allowed_ops" (fun self ->

0 comments on commit 3569d51

Please sign in to comment.