File tree Expand file tree Collapse file tree 10 files changed +31
-45
lines changed Expand file tree Collapse file tree 10 files changed +31
-45
lines changed Original file line number Diff line number Diff line change @@ -304,7 +304,7 @@ module Ds_selector = struct
304
304
if fs = [] then
305
305
true
306
306
else
307
- List. fold_left (fun acc f -> acc || filter11 f d) false fs
307
+ List. exists (fun f -> filter11 f d) fs
308
308
309
309
(* Returns the d \in ds that passes at least one of the filters
310
310
fs *)
Original file line number Diff line number Diff line change @@ -45,10 +45,7 @@ let check_plan config dead_hosts plan =
45
45
let memory_remaining = account config.hosts config.vms plan in
46
46
(* List.iter (fun mem -> Printf.printf "%Ld\n" mem) free; *)
47
47
(* No host should be overcommitted: *)
48
- if
49
- List. fold_left ( || ) false
50
- (List. map (fun x -> x < 0L ) (List. map snd memory_remaining))
51
- then
48
+ if List. exists (fun (_ , x ) -> x < 0L ) memory_remaining then
52
49
raise BadPlan ;
53
50
(* All failed VMs should be restarted: *)
54
51
let failed_vms = get_failed_vms config dead_hosts in
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ let track callback rpc (session_id : API.ref_session) task =
91
91
| _ ->
92
92
false
93
93
in
94
- finished := List. fold_left ( || ) false ( List. map matches events)
94
+ finished := List. exists matches events
95
95
done
96
96
with
97
97
| Api_errors. Server_error (code, _)
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ let names =
63
63
64
64
let vdi_exists sr vdi =
65
65
let all = Client.SR. scan dbg sr in
66
- List. fold_left (fun acc vdi_info -> acc || vdi_info.vdi = vdi) false all
66
+ List. exists (fun vdi_info -> vdi_info.vdi = vdi) all
67
67
68
68
let create sr name_label =
69
69
let vdi_info =
Original file line number Diff line number Diff line change @@ -94,15 +94,9 @@ let ( + ) state operation =
94
94
95
95
let superstate states =
96
96
let activated =
97
- List. fold_left
98
- (fun acc s -> acc || s = Activated RO || s = Activated RW )
99
- false states
100
- in
101
- let rw =
102
- List. fold_left
103
- (fun acc s -> acc || s = Activated RW || s = Attached RW )
104
- false states
97
+ List. exists (fun s -> s = Activated RO || s = Activated RW ) states
105
98
in
99
+ let rw = List. exists (fun s -> s = Activated RW || s = Attached RW ) states in
106
100
if states = [] then
107
101
Detached
108
102
else if activated then
Original file line number Diff line number Diff line change @@ -1012,7 +1012,7 @@ let pool_has_different_host_platform_versions ~__context =
1012
1012
let is_different_to_me platform_version =
1013
1013
platform_version <> Xapi_version. platform_version ()
1014
1014
in
1015
- List. fold_left ( || ) false ( List. map is_different_to_me platform_versions)
1015
+ List. exists is_different_to_me platform_versions
1016
1016
1017
1017
(* Checks that a host has a PBD for a particular SR (meaning that the
1018
1018
SR is visible to the host) *)
Original file line number Diff line number Diff line change @@ -58,17 +58,16 @@ let rec compute_additional_restrictions all_host_params = function
58
58
[]
59
59
| flag :: rest ->
60
60
let switches =
61
- List. map
61
+ List. exists
62
62
(function
63
63
| params ->
64
- if List. mem_assoc flag params then
65
- bool_of_string (List. assoc flag params)
66
- else
67
- true
64
+ List. assoc_opt flag params
65
+ |> Fun. flip Option. bind bool_of_string_opt
66
+ |> Option. value ~default: true
68
67
)
69
68
all_host_params
70
69
in
71
- (flag, string_of_bool ( List. fold_left ( || ) false switches) )
70
+ (flag, string_of_bool switches)
72
71
:: compute_additional_restrictions all_host_params rest
73
72
74
73
(* Combine the host-level feature restrictions into pool-level ones, and write
Original file line number Diff line number Diff line change @@ -427,9 +427,9 @@ let create ~__context ~network ~members ~mAC ~mode ~properties =
427
427
in
428
428
let disallow_unplug =
429
429
(* this is always true if one of the PIFs is a cluster_host.PIF *)
430
- List. fold_left
431
- (fun a m -> Db.PIF. get_disallow_unplug ~__context ~self: m || a )
432
- false members
430
+ List. exists
431
+ (fun m -> Db.PIF. get_disallow_unplug ~__context ~self: m)
432
+ members
433
433
in
434
434
(* Validate constraints: *)
435
435
(* 1. Members must not be in a bond already *)
Original file line number Diff line number Diff line change @@ -1334,18 +1334,14 @@ let gen_list_option name desc of_string string_of opt =
1334
1334
let sm_plugins = ref []
1335
1335
1336
1336
let accept_sm_plugin name =
1337
- List. (
1338
- fold_left ( || ) false
1339
- (map
1340
- (function
1341
- | `All ->
1342
- true
1343
- | `Sm x ->
1344
- String. lowercase_ascii x = String. lowercase_ascii name
1345
- )
1346
- ! sm_plugins
1337
+ List. exists
1338
+ (function
1339
+ | `All ->
1340
+ true
1341
+ | `Sm x ->
1342
+ String. lowercase_ascii x = String. lowercase_ascii name
1347
1343
)
1348
- )
1344
+ ! sm_plugins
1349
1345
1350
1346
let nvidia_multi_vgpu_enabled_driver_versions =
1351
1347
ref [" 430.42" ; " 430.62" ; " 440.00+" ]
Original file line number Diff line number Diff line change @@ -2185,19 +2185,19 @@ let reset_networking ~__context ~host =
2185
2185
(Db.PIF. get_all ~__context)
2186
2186
in
2187
2187
let bond_is_local bond =
2188
- List. fold_left
2189
- (fun a pif -> Db.Bond. get_master ~__context ~self: bond = pif || a )
2190
- false local_pifs
2188
+ List. exists
2189
+ (fun pif -> Db.Bond. get_master ~__context ~self: bond = pif)
2190
+ local_pifs
2191
2191
in
2192
2192
let vlan_is_local vlan =
2193
- List. fold_left
2194
- (fun a pif -> Db.VLAN. get_untagged_PIF ~__context ~self: vlan = pif || a )
2195
- false local_pifs
2193
+ List. exists
2194
+ (fun pif -> Db.VLAN. get_untagged_PIF ~__context ~self: vlan = pif)
2195
+ local_pifs
2196
2196
in
2197
2197
let tunnel_is_local tunnel =
2198
- List. fold_left
2199
- (fun a pif -> Db.Tunnel. get_access_PIF ~__context ~self: tunnel = pif || a )
2200
- false local_pifs
2198
+ List. exists
2199
+ (fun pif -> Db.Tunnel. get_access_PIF ~__context ~self: tunnel = pif)
2200
+ local_pifs
2201
2201
in
2202
2202
let bonds = List. filter bond_is_local (Db.Bond. get_all ~__context) in
2203
2203
List. iter
You can’t perform that action at this time.
0 commit comments