@@ -310,7 +310,14 @@ let setup_export_test_vm session_id =
310310  debug test (Printf. sprintf " Template has uuid: %s%!" 
311311  let  vm =  vm_install test session_id uuid " quicktest-export" in 
312312  debug test (Printf. sprintf " Installed new VM" 
313-   let  cd =  List. hd (Client.VDI. get_by_name_label ! rpc session_id " xs-tools.iso" in 
313+   let  cd = 
314+     let  tools_iso_filter =  " field \" is_tools_iso\" =\" true\" " in 
315+     match  Client.VDI. get_all_records_where ! rpc session_id tools_iso_filter with 
316+     |  (vdi , _ )::_  -> vdi
317+     |  []  ->
318+       failed test " Failed to find tools ISO VDI" 
319+       failwith " setup_export_test_vm" 
320+   in 
314321  debug test " Looking for the SR which supports the smallest disk size" 
315322  let  all_srs =  all_srs_with_vdi_create session_id in 
316323  let  smallest  : int64 option list  =  List. map (fun  sr  -> Quicktest_storage. find_smallest_disk_size session_id sr) all_srs in 
@@ -320,12 +327,13 @@ let setup_export_test_vm session_id =
320327	     |  sr , None  -> debug test (Printf. sprintf " SR %s has no minimum disk size!" 
321328	    ) (List. combine sr_names smallest);
322329  let  minimum =  List. fold_left min (1L  **  gib) (List. map (fun  x  -> Opt. default (1L  **  gib) x) smallest) in 
323-   let  possible_srs =  List. filter (fun  (sr , size ) -> size =  Some  minimum) (List. combine all_srs smallest) in 
324-   if  List. length possible_srs =  0  then  begin 
325-     failed test " Failed to find an SR which can create a VDI" 
326-     failwith " setup_export_test_vm" 
327-   end ;
328-   let  sr =  fst (List. hd possible_srs) in 
330+   let  sr = 
331+     match  List. filter (fun  (_ , size ) -> size =  Some  minimum) (List. combine all_srs smallest) with 
332+     |  (sr , _ )::_  -> sr
333+     |  []  ->
334+       failed test " Failed to find an SR which can create a VDI" 
335+       failwith " setup_export_test_vm" 
336+   in 
329337  debug test (Printf. sprintf " Using a disk size of: %Ld on SR: %s" Quicktest_storage. name_of_sr session_id sr));
330338  let  vdi =  Client.VDI. create ! rpc session_id " small" 
331339    " description" 4194304L  `user  false  false  []  []  []  []  in 
0 commit comments