diff --git a/ocaml/idl/datamodel_errors.ml b/ocaml/idl/datamodel_errors.ml index abd0490ee64..8407711d21f 100644 --- a/ocaml/idl/datamodel_errors.ml +++ b/ocaml/idl/datamodel_errors.ml @@ -1955,6 +1955,9 @@ let _ = error Api_errors.invalid_update_sync_day ["day"] ~doc:"Invalid day of the week chosen for weekly update sync." () ; + error Api_errors.no_repositories_configured [] + ~doc:"No update repositories have been configured." () ; + message (fst Api_messages.ha_pool_overcommitted) ~doc: diff --git a/ocaml/xapi-consts/api_errors.ml b/ocaml/xapi-consts/api_errors.ml index 1da1799230e..70557f54ee9 100644 --- a/ocaml/xapi-consts/api_errors.ml +++ b/ocaml/xapi-consts/api_errors.ml @@ -1283,6 +1283,8 @@ let update_guidance_changed = "UPDATE_GUIDANCE_CHANGED" let invalid_update_sync_day = "INVALID_UPDATE_SYNC_DAY" +let no_repositories_configured = "NO_REPOSITORIES_CONFIGURED" + (* VTPMs *) let vtpm_max_amount_reached = "VTPM_MAX_AMOUNT_REACHED" diff --git a/ocaml/xapi/xapi_pool.ml b/ocaml/xapi/xapi_pool.ml index 1cbaf207e40..240075c9edb 100644 --- a/ocaml/xapi/xapi_pool.ml +++ b/ocaml/xapi/xapi_pool.ml @@ -3667,6 +3667,10 @@ let configure_update_sync ~__context ~self ~update_sync_frequency Pool_periodic_update_sync.set_enabled ~__context ~value:true let set_update_sync_enabled ~__context ~self ~value = + if value && Db.Pool.get_repositories ~__context ~self = [] then ( + error "Cannot enable automatic update syncing if there are no repositories." ; + raise Api_errors.(Server_error (no_repositories_configured, [])) + ) ; Pool_periodic_update_sync.set_enabled ~__context ~value ; Db.Pool.set_update_sync_enabled ~__context ~self ~value