Skip to content

Commit

Permalink
CP-52115: Add v6d interface error License_server_certificate_error
Browse files Browse the repository at this point in the history
This error is raised by v6d when user apply a different edition
but license server certificate check error. Currently only pool
coordinator will return license server certificate check error.

Signed-off-by: Changlei Li <[email protected]>
  • Loading branch information
changlei-li committed Dec 25, 2024
1 parent 7c09797 commit 367b0ba
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ocaml/idl/datamodel_errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ let _ =
() ;
error Api_errors.license_checkout_error ["reason"]
~doc:"The license for the edition you requested is not available." () ;
error Api_errors.license_server_certificate_error ["reason"]
~doc:"The license server certificate check error." () ;
error Api_errors.license_file_deprecated []
~doc:
"This type of license file is for previous versions of the server. \
Expand Down
7 changes: 5 additions & 2 deletions ocaml/xapi-cli-server/cli_operations.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5249,9 +5249,12 @@ let with_license_server_changes printer rpc session_id params hosts f =
hosts
) ;
let now = Unix.gettimeofday () in
let need_roll_back errname =
errname = Api_errors.license_checkout_error
|| errname = Api_errors.license_server_certificate_error
in
try f rpc session_id with
| Api_errors.Server_error (name, _) as e
when name = Api_errors.license_checkout_error ->
| Api_errors.Server_error (name, _) as e when need_roll_back name ->
(* Put back original license_server_details *)
List.iter
(fun (host, license_server) ->
Expand Down
3 changes: 3 additions & 0 deletions ocaml/xapi-consts/api_errors.ml
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,9 @@ let missing_connection_details = add_error "MISSING_CONNECTION_DETAILS"

let license_checkout_error = add_error "LICENSE_CHECKOUT_ERROR"

let license_server_certificate_error =
add_error "LICENSE_SERVER_CERTIFICATE_ERROR"

let license_file_deprecated = add_error "LICENSE_FILE_DEPRECATED"

let activation_while_not_free = add_error "ACTIVATION_WHILE_NOT_FREE"
Expand Down
2 changes: 2 additions & 0 deletions ocaml/xapi-idl/v6/v6_interface.ml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ type errors =
date *)
| License_processing_error (** License could not be processed *)
| License_checkout_error of string (** License could not be checked out *)
| License_server_certificate_error of string
(** License server certificate error *)
| Missing_connection_details
(** Thrown if connection port or address parameter not supplied to
check_license *)
Expand Down
2 changes: 2 additions & 0 deletions ocaml/xapi/xapi_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,8 @@ let apply_edition_internal ~__context ~host ~edition ~additional =
raise Api_errors.(Server_error (missing_connection_details, []))
| V6_interface.(V6_error (License_checkout_error s)) ->
raise Api_errors.(Server_error (license_checkout_error, [s]))
| V6_interface.(V6_error (License_server_certificate_error s)) ->
raise Api_errors.(Server_error (license_server_certificate_error, [s]))
| V6_interface.(V6_error (Internal_error e)) ->
raise Api_errors.(Server_error (internal_error, [e]))
in
Expand Down

0 comments on commit 367b0ba

Please sign in to comment.