Skip to content

Commit 87b1325

Browse files
committed
Fix issue of local SR
1 parent 4921d12 commit 87b1325

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

ocaml/xapi/xapi_vm_helpers.ml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -769,20 +769,35 @@ let assert_can_be_recovered ~__context ~self ~session_to =
769769

770770
let required_list_of_SRs ~__context ~self ~session_to =
771771
let required_SR_list = list_required_SRs ~__context ~self in
772+
let required_SR_uuids = List.map( fun sr ->Db.SR.get_uuid ~__context ~self:sr) required_SR_list
773+
in
772774
try
775+
let sr_uuids_list=
776+
debug "AKSHAY";
773777
Server_helpers.exec_with_new_task ~session_id:session_to
774778
"Looking for the required SRs"
775-
(fun __context_to -> List.filter
776-
( fun sr_ref ->
777-
let pbds = Db.SR.get_PBDs ~__context:__context_to ~self:sr_ref in
779+
(fun __context_to -> List.filter
780+
( fun sr_uuid ->
781+
try
782+
let sr = Db.SR.get_by_uuid ~__context:__context_to ~uuid:sr_uuid in
783+
let pbds = Db.SR.get_PBDs ~__context:__context_to ~self:sr in
778784
let attached_pbds = List.filter
779785
(fun pbd -> Db.PBD.get_currently_attached ~__context:__context_to ~self:pbd)
780786
pbds
781787
in
782788
if attached_pbds = [] then true else false
789+
with Db_exn.Read_missing_uuid(_ , _ , sr_uuid) -> true
783790
)
784-
required_SR_list)
791+
required_SR_uuids)
792+
in
793+
List.map(fun sr -> Db.SR.get_by_uuid ~__context ~uuid:sr)sr_uuids_list
785794
with e -> raise e;;
795+
(*(*Finally pass a reference of the SRs*)
796+
List.map(fun sr-> Db.SR.get_by_uuid ~__context ~uuid:sr_uuid)required_SR_uuids
797+
with Db_exn.Read_missing_uuid(_ , _ , sr_uuid) ->
798+
(*Add that SR to the required_SR_list*)
799+
List.map(fun sr -> Db.SR.get_by_uuid ~__context ~uuid:sr_uuid)required_SR_uuids*)
800+
786801

787802
(* BIOS strings *)
788803

0 commit comments

Comments
 (0)