|
|
|
|
|
|
|
|
|
|
xen-api
[Xen-API] [PATCH 1 of 2] [CP-1698] Refactors the HA codebase to extract
# HG changeset patch
# User Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>
# Date 1281460715 -3600
# Node ID 4236a320c9bfa1f80d1aad56b0f77eb872812c84
# Parent 9e30c7a856c06ebf4c0170ffbb610d1a7aee60cb
[CP-1698] Refactors the HA codebase to extract out a common, repeated
definition. (Fixes a minor violation of the DRY principle.)
Signed-off-by: Jonathan Knowles <jonathan.knowles@xxxxxxxxxxxxx>
diff -r 9e30c7a856c0 -r 4236a320c9bf ocaml/idl/constants.ml
--- a/ocaml/idl/constants.ml Tue Aug 10 18:18:35 2010 +0100
+++ b/ocaml/idl/constants.ml Tue Aug 10 18:18:35 2010 +0100
@@ -65,6 +65,7 @@
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"
diff -r 9e30c7a856c0 -r 4236a320c9bf ocaml/xapi/xapi_pool.ml
--- a/ocaml/xapi/xapi_pool.ml Tue Aug 10 18:18:35 2010 +0100
+++ b/ocaml/xapi/xapi_pool.ml Tue Aug 10 18:18:35 2010 +0100
@@ -1004,9 +1004,8 @@
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
diff -r 9e30c7a856c0 -r 4236a320c9bf ocaml/xapi/xapi_vm.ml
--- a/ocaml/xapi/xapi_vm.ml Tue Aug 10 18:18:35 2010 +0100
+++ b/ocaml/xapi/xapi_vm.ml Tue Aug 10 18:18:35 2010 +0100
@@ -75,9 +75,8 @@
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 =
diff -r 9e30c7a856c0 -r 4236a320c9bf ocaml/xapi/xapi_vm.mli
--- a/ocaml/xapi/xapi_vm.mli Tue Aug 10 18:18:35 2010 +0100
+++ b/ocaml/xapi/xapi_vm.mli Tue Aug 10 18:18:35 2010 +0100
@@ -47,7 +47,6 @@
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
4 files changed, 3 insertions(+), 5 deletions(-)
ocaml/idl/constants.ml | 1 +
ocaml/xapi/xapi_pool.ml | 3 +--
ocaml/xapi/xapi_vm.ml | 3 +--
ocaml/xapi/xapi_vm.mli | 1 -
xen-api.hg-2.patch
Description: Text Data
_______________________________________________
xen-api mailing list
xen-api@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/mailman/listinfo/xen-api
|
|
|
|
|