]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
[CP-1698] Refactors the HA codebase to extract out a common, repeated definition...
authorJonathan Knowles <jonathan.knowles@eu.citrix.com>
Mon, 23 Aug 2010 12:25:16 +0000 (13:25 +0100)
committerJonathan Knowles <jonathan.knowles@eu.citrix.com>
Mon, 23 Aug 2010 12:25:16 +0000 (13:25 +0100)
Signed-off-by: Jonathan Knowles <jonathan.knowles@eu.citrix.com>
ocaml/idl/constants.ml
ocaml/xapi/xapi_pool.ml
ocaml/xapi/xapi_vm.ml
ocaml/xapi/xapi_vm.mli

index 19ce572c1efd733321f86c2f37bf2787eda23928..b47afa2bfe87e0359630caed5c130cc88f3189ec 100644 (file)
@@ -65,6 +65,7 @@ let fix_firewall_script = "/opt/xensource/bin/fix_firewall.sh"
 let ha_armed = "ha.armed"
 let ha_disable_failover_decisions = "ha.disable_failover_decisions"
 let ha_restart_best_effort = "best-effort"
+let ha_valid_restart_priorities = [ "1"; "2"; "3"; ha_restart_best_effort ]
 let ha_base_t = "ha_base_t"
 let ballooning_enabled = "ballooning.enabled"
 let redo_log_enabled = "redo_log.enabled"
index 204a1894a5a41f4e6d2660c64eb7991014fe5653..52099d01888d15644b3bebdae8a7f1cf2481d459 100644 (file)
@@ -1004,9 +1004,8 @@ let ha_compute_max_host_failures_to_tolerate ~__context =
 
 let ha_compute_hypothetical_max_host_failures_to_tolerate ~__context ~configuration = 
   (* Check the restart priorities all look valid *)
-  let valid_priorities = [ "1"; "2"; "3"; Constants.ha_restart_best_effort ] in
   List.iter (fun (_, pri) -> 
-              if not(List.mem pri valid_priorities)
+              if not(List.mem pri Constants.ha_valid_restart_priorities)
               then raise (Api_errors.Server_error(Api_errors.invalid_value, [ "ha_restart_priority"; pri ]))) configuration;
 
   let protected_vms = List.map fst (List.filter (fun (vm, priority) -> Helpers.vm_should_always_run true priority) configuration) in
index c0d4dbced69aecd576283f658d2e6794810e8e5e..029517dcbab58ac09f3ec1b739b0bcca5c96a04c 100644 (file)
@@ -75,9 +75,8 @@ let set_actions_after_crash ~__context ~self ~value =
 let set_is_a_template ~__context ~self ~value = 
        set_is_a_template ~__context ~self ~value
 
-let valid_restart_priorities = [ Constants.ha_restart_best_effort; "1"; "2"; "3" ]
 let validate_restart_priority include_empty_string x = 
-  if not(List.mem x (valid_restart_priorities @ (if include_empty_string then [ "" ] else [])))
+  if not(List.mem x (Constants.ha_valid_restart_priorities @ (if include_empty_string then [ "" ] else [])))
   then raise (Api_errors.Server_error(Api_errors.invalid_value, [ "ha_restart_priority"; x ]))
 
 let set_ha_always_run ~__context ~self ~value = 
index fdb7f4bbcb88588b64513cb4eefee9c0af5529cf..0b3e9698f79434da85fedabcf615309698a018ec 100644 (file)
@@ -47,7 +47,6 @@ val set_actions_after_crash :
   unit
 val set_is_a_template :
   __context:Context.t -> self:[ `VM ] Ref.t -> value:bool -> unit
-val valid_restart_priorities : string list
 val validate_restart_priority : bool -> string -> unit
 val set_ha_always_run :
   __context:Context.t -> self:API.ref_VM -> value:bool -> unit