[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-API] [PATCH 4 of 4] Update pool join code to use new modules
# HG changeset patch # User Rob Hoes <rob.hoes@xxxxxxxxxx> # Date 1279116492 -3600 # Node ID f1e5c460e4d47d2f1c2730cb34b53251829f8871 # Parent 5e1ae12e5f4531a3fdc1de93535dece93be62456 Update pool join code to use new modules Signed-off-by: Rob Hoes <rob.hoes@xxxxxxxxxx> diff -r 5e1ae12e5f45 -r f1e5c460e4d4 ocaml/license/edition.ml --- a/ocaml/license/edition.ml +++ b/ocaml/license/edition.ml @@ -36,3 +36,12 @@ let to_features = function | Free -> all_features +let edition_to_int = function + | Free | _ -> 0 + +let equal e0 e1 = + edition_to_int e0 = edition_to_int e1 + +let min l = + Free + diff -r 5e1ae12e5f45 -r f1e5c460e4d4 ocaml/license/edition.mli --- a/ocaml/license/edition.mli +++ b/ocaml/license/edition.mli @@ -19,7 +19,7 @@ type edition = | Free (** Default Edition *) -(** Raised by {!edition_of_string} if the given string does not map to an edition. *) +(** Raised by {!of_string} if the given string does not map to an edition. *) exception Undefined_edition of string (** Convert a string to an {!edition}. *) @@ -37,3 +37,9 @@ (** Get the list of {!feature}s enabled for a given {!edition}. *) val to_features : edition -> Features.feature list +(** Compare two editions for equality (used before pool join). *) +val equal : edition -> edition -> bool + +(** Return the "least capable" edition (used to determine the pool edition). *) +val min : edition list -> edition + diff -r 5e1ae12e5f45 -r f1e5c460e4d4 ocaml/xapi/xapi_pool.ml --- a/ocaml/xapi/xapi_pool.ml +++ b/ocaml/xapi/xapi_pool.ml @@ -61,23 +61,13 @@ let assert_restrictions_match () = let host_records = List.map snd (Client.Host.get_all_records ~rpc ~session_id) in (* check pool edition *) - let pool_editions = List.map (fun host_r -> host_r.API.host_edition) host_records in - let edition_to_int = function - | "platinum" -> 2 - | "enterprise" | "enterprise-xd" -> 1 - | "free" | _ -> 0 - in - let int_to_edition = function - | 2 -> "platinum" - | 1 -> "enterprise" - | 0 | _ -> "free" - in - let pool_edition = List.fold_left (fun m e -> min m (edition_to_int e)) 2 pool_editions in - let my_edition = edition_to_int (Db.Host.get_edition ~__context ~self:(Helpers.get_localhost ~__context)) in - if pool_edition <> my_edition then begin + let pool_editions = List.map (fun host_r -> Edition.of_string host_r.API.host_edition) host_records in + let pool_edition = Edition.min pool_editions in + let my_edition = Edition.of_string (Db.Host.get_edition ~__context ~self:(Helpers.get_localhost ~__context)) in + if not (Edition.equal pool_edition my_edition) then begin error "Pool.join failed because of editions mismatch"; - error "Remote has %s" (int_to_edition pool_edition); - error "Local has %s" (int_to_edition my_edition); + error "Remote has %s" (Edition.to_string pool_edition); + error "Local has %s" (Edition.to_string my_edition); raise (Api_errors.Server_error(Api_errors.license_restriction, [])) end in ocaml/license/edition.ml | 9 +++++++++ ocaml/license/edition.mli | 8 +++++++- ocaml/xapi/xapi_pool.ml | 22 ++++++---------------- 3 files changed, 22 insertions(+), 17 deletions(-) Attachment:
xen-api.hg-4.patch _______________________________________________ xen-api mailing list xen-api@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/mailman/listinfo/xen-api
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |