main/sorcery: Provide log messages when a wizard does not support an operation

If a sorcery wizard does not support one of the 'optional' CRUD
operations (namely the CUD), log a WARNING message so we are aware of
why the operation failed. This also removes an assert in this case, as
the CUD operation may have been triggered by an external system, in
which case it is not a programming error but a configuration error.

Change-Id: Ifecd9df946d9deaa86235257b49c6e5e24423b53
changes/72/872/1
Matt Jordan 10 years ago
parent 5266796432
commit ffadb5f1de

@ -1945,9 +1945,7 @@ static int sorcery_wizard_create(void *obj, void *arg, int flags)
const struct sorcery_details *details = arg;
if (!object_wizard->wizard->callbacks.create) {
ast_assert(0);
ast_log(LOG_ERROR, "Sorcery wizard '%s' doesn't contain a 'create' virtual function.\n",
object_wizard->wizard->callbacks.name);
ast_debug(5, "Sorcery wizard '%s' does not support creation\n", object_wizard->wizard->callbacks.name);
return 0;
}
return (!object_wizard->caching && !object_wizard->wizard->callbacks.create(details->sorcery, object_wizard->data, details->obj)) ? CMP_MATCH | CMP_STOP : 0;
@ -2040,7 +2038,12 @@ static int sorcery_wizard_update(void *obj, void *arg, int flags)
const struct ast_sorcery_object_wizard *object_wizard = obj;
const struct sorcery_details *details = arg;
return (object_wizard->wizard->callbacks.update && !object_wizard->wizard->callbacks.update(details->sorcery, object_wizard->data, details->obj) &&
if (!object_wizard->wizard->callbacks.update) {
ast_debug(5, "Sorcery wizard '%s' does not support updating\n", object_wizard->wizard->callbacks.name);
return 0;
}
return (!object_wizard->wizard->callbacks.update(details->sorcery, object_wizard->data, details->obj) &&
!object_wizard->caching) ? CMP_MATCH | CMP_STOP : 0;
}
@ -2108,7 +2111,12 @@ static int sorcery_wizard_delete(void *obj, void *arg, int flags)
const struct ast_sorcery_object_wizard *object_wizard = obj;
const struct sorcery_details *details = arg;
return (object_wizard->wizard->callbacks.delete && !object_wizard->wizard->callbacks.delete(details->sorcery, object_wizard->data, details->obj) &&
if (!object_wizard->wizard->callbacks.delete) {
ast_debug(5, "Sorcery wizard '%s' does not support deletion\n", object_wizard->wizard->callbacks.name);
return 0;
}
return (!object_wizard->wizard->callbacks.delete(details->sorcery, object_wizard->data, details->obj) &&
!object_wizard->caching) ? CMP_MATCH | CMP_STOP : 0;
}

Loading…
Cancel
Save