@@ -66,7 +66,7 @@ let get_anti_affinity_alerts ~__context =
6666 .all_vms_in_the_anti_affinity_group_are_running_on_a_single_host
6767 )
6868
69- let alert_of_group ~__context ~label_name ~id alert =
69+ let alert_matched ~__context ~label_name ~id alert =
7070 let alert_rec = snd alert in
7171 match Xml. parse_string alert_rec.API. message_body with
7272 | Xml. Element ("body" , _ , children ) -> (
@@ -94,17 +94,15 @@ let alert_of_group ~__context ~label_name ~id alert =
9494let filter_alerts_with_group ~__context ~group ~alerts =
9595 let group_uuid = Db.VM_group. get_uuid ~__context ~self: group in
9696 List. filter
97- (alert_of_group ~__context ~label_name: " VM_group" ~id: group_uuid)
97+ (alert_matched ~__context ~label_name: " VM_group" ~id: group_uuid)
9898 alerts
9999
100100let filter_alerts_with_host ~__context ~host ~alerts =
101101 let host_uuid = Db.Host. get_uuid ~__context ~self: host in
102- List. filter
103- (alert_of_group ~__context ~label_name: " host" ~id: host_uuid)
104- alerts
102+ List. filter (alert_matched ~__context ~label_name: " host" ~id: host_uuid) alerts
105103
106- (* * If it is breach and no alerts exists , generate one,
107- If it is not breach and alerts exists , dismiss the existing alert *)
104+ (* * If it is a breach and no alerts exist , generate one,
105+ If it is not a breach and alerts exist , dismiss the existing alert *)
108106let update_vm_anti_affinity_alert_for_group ~__context ~group ~alerts =
109107 let breach_on_host =
110108 check_breach_on_vm_anti_affinity_rules ~__context ~group
@@ -147,11 +145,11 @@ let maybe_update_vm_anti_affinity_alert_for_vm ~__context ~vm =
147145 ()
148146 | group :: _ ->
149147 let alerts = get_anti_affinity_alerts ~__context in
150- let alert_of_group =
148+ let alerts_of_group =
151149 filter_alerts_with_group ~__context ~group ~alerts
152150 in
153151 update_vm_anti_affinity_alert_for_group ~__context ~group
154- ~alerts: alert_of_group
152+ ~alerts: alerts_of_group
155153 with e -> error " %s" (Printexc. to_string e)
156154
157155let remove_vm_anti_affinity_alert_for_group ~__context ~group ~alerts =
@@ -173,10 +171,10 @@ let update_alert ~__context ~groups ~action =
173171 Db.VM_group. get_placement ~__context ~self: g = `anti_affinity
174172 )
175173 |> List. iter (fun group ->
176- let alert_of_group =
174+ let alerts_of_group =
177175 filter_alerts_with_group ~__context ~group ~alerts
178176 in
179- action ~__context ~group ~alerts: alert_of_group
177+ action ~__context ~group ~alerts: alerts_of_group
180178 )
181179 with e -> error " %s" (Printexc. to_string e)
182180
@@ -191,8 +189,7 @@ let remove_vm_anti_affinity_alert ~__context ~groups =
191189let maybe_update_alerts_on_feature_change ~__context ~old_restrictions
192190 ~new_restrictions =
193191 try
194- let feature_name = Features. name_of_feature Features. VM_anti_affinity in
195- let feature = " restrict_" ^ String. lowercase_ascii feature_name in
192+ let feature, _ = Features. (string_of_feature Features. VM_anti_affinity ) in
196193 let groups = Db.VM_group. get_all ~__context in
197194 match
198195 ( List. assoc_opt feature old_restrictions
0 commit comments