diff --git a/ocaml/idl/datamodel_errors.ml b/ocaml/idl/datamodel_errors.ml index 80b36218f25..5477713f19f 100644 --- a/ocaml/idl/datamodel_errors.ml +++ b/ocaml/idl/datamodel_errors.ml @@ -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. \ diff --git a/ocaml/xapi-cli-server/cli_operations.ml b/ocaml/xapi-cli-server/cli_operations.ml index 1e8ba0f3b37..21a5ea52ab7 100644 --- a/ocaml/xapi-cli-server/cli_operations.ml +++ b/ocaml/xapi-cli-server/cli_operations.ml @@ -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) -> diff --git a/ocaml/xapi-consts/api_errors.ml b/ocaml/xapi-consts/api_errors.ml index 53e9e06176b..1bb64e90aaa 100644 --- a/ocaml/xapi-consts/api_errors.ml +++ b/ocaml/xapi-consts/api_errors.ml @@ -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" diff --git a/ocaml/xapi-idl/v6/v6_interface.ml b/ocaml/xapi-idl/v6/v6_interface.ml index 74b8201dbc7..76e025e3c45 100644 --- a/ocaml/xapi-idl/v6/v6_interface.ml +++ b/ocaml/xapi-idl/v6/v6_interface.ml @@ -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 *) diff --git a/ocaml/xapi/xapi_host.ml b/ocaml/xapi/xapi_host.ml index 23cbd6747b5..8577ee681b1 100644 --- a/ocaml/xapi/xapi_host.ml +++ b/ocaml/xapi/xapi_host.ml @@ -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