Skip to content

Commit 81704e8

Browse files
committed
CP-3574: new error code PATCH_PRECHECK_FAILED_WRONG_SERVER_BUILD
1 parent 1e4a7c8 commit 81704e8

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

ocaml/idl/api_errors.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ let patch_already_applied = "PATCH_ALREADY_APPLIED"
302302
let patch_precheck_failed_unknown_error = "PATCH_PRECHECK_FAILED_UNKNOWN_ERROR"
303303
let patch_precheck_failed_prerequisite_missing = "PATCH_PRECHECK_FAILED_PREREQUISITE_MISSING"
304304
let patch_precheck_failed_wrong_server_version = "PATCH_PRECHECK_FAILED_WRONG_SERVER_VERSION"
305+
let patch_precheck_failed_wrong_server_build = "PATCH_PRECHECK_FAILED_WRONG_SERVER_BUILD"
305306
let patch_precheck_failed_vm_running = "PATCH_PRECHECK_FAILED_VM_RUNNING"
306307
let patch_apply_failed = "PATCH_APPLY_FAILED"
307308
let cannot_find_oem_backup_partition = "CANNOT_FIND_OEM_BACKUP_PARTITION"

ocaml/idl/datamodel.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,8 @@ let _ =
963963
~doc:"The patch precheck stage failed: prerequisite patches are missing." ();
964964
error Api_errors.patch_precheck_failed_wrong_server_version [ "patch"; "found_version"; "required_version"]
965965
~doc:"The patch precheck stage failed: the server is of an incorrect version." ();
966+
error Api_errors.patch_precheck_failed_wrong_server_build [ "patch"; "found_build"; "required_build"]
967+
~doc:"The patch precheck stage failed: the server is of an incorrect build." ();
966968
error Api_errors.patch_precheck_failed_vm_running [ "patch" ]
967969
~doc:"The patch precheck stage failed: there are one or more VMs still running on the server. All VMs must be suspended before the patch can be applied." ();
968970

ocaml/xapi/xapi_pool_patch.ml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,20 @@ let parse_patch_precheck_xml patch = function
617617
let found = findElement "found" children in
618618
let required = findElement "required" children in
619619
raise (Api_errors.Server_error (Api_errors.patch_precheck_failed_wrong_server_version, [Ref.string_of patch; found; required]))
620+
| Element ("error", [("errorcode", "PATCH_PRECHECK_FAILED_WRONG_SERVER_BUILD")], children) ->
621+
(* Exactly like the previous one but SERVER_BUILD instead of SERVER_VERSION *)
622+
(* <error errorcode="PATCH_PRECHECK_FAILED_WRONG_SERVER_BUILD">
623+
<found>50845c</found>
624+
<required>^58332[pc]$</required>
625+
</error> *)
626+
let rec findElement name = function
627+
| Element (tagName, _, (PCData head)::_)::tail -> if tagName = name then head else findElement name tail
628+
| _::tail -> findElement name tail
629+
| [] -> raise (Bad_precheck_xml "Could not find element %s")
630+
in
631+
let found = findElement "found" children in
632+
let required = findElement "required" children in
633+
raise (Api_errors.Server_error (Api_errors.patch_precheck_failed_wrong_server_build, [Ref.string_of patch; found; required]))
620634
| Element ("error", [("errorcode", "PATCH_PRECHECK_FAILED_VM_RUNNING")], _) ->
621635
(* <error errorcode="PATCH_PRECHECK_FAILED_VM_RUNNING" /> *)
622636
raise (Api_errors.Server_error (Api_errors.patch_precheck_failed_vm_running, [Ref.string_of patch]))

0 commit comments

Comments
 (0)