diff options
author | George Joseph <george.joseph@fairview5.com> | 2014-10-13 16:10:06 +0000 |
---|---|---|
committer | George Joseph <george.joseph@fairview5.com> | 2014-10-13 16:10:06 +0000 |
commit | 8bb06d592aea462e53428eb8dd98e6087db79326 (patch) | |
tree | 022fe0cb6b9b6866f127f29e7d4db8956a0eac9c /tests/test_sorcery_realtime.c | |
parent | efefbe15a4bfc42e2f975d5bba07aa9a994da643 (diff) |
manager/config: Support templates and non-unique category names via AMI
This patch provides the capability to manipulate templates and categories
with non-unique names via AMI.
Summary of changes:
GetConfig and GetConfigJSON: Added "Filter" parameter: A comma separated list
of name_regex=value_regex expressions which will cause only categories whose
variables match all expressions to be considered. The special variable name
TEMPLATES can be used to control whether templates are included. Passing
'include' as the value will include templates along with normal categories.
Passing 'restrict' as the value will restrict the operation to ONLY templates.
Not specifying a TEMPLATES expression results in the current default behavior
which is to not include templates.
UpdateConfig: NewCat now includes options for allowing duplicate category
names, indicating if the category should be created as a template, and
specifying templates the category should inherit from. The rest of the
actions now accept a filter string as defined above. If there are non-unique
category names, you can now update specific ones based on variable values.
To facilitate the new capabilities in manager, corresponding changes had to be
made to config, most notably the addition of filter criteria to many of the
APIs. In some cases it was easy to change the references to use the new
prototype but others would have required touching too many files for this
patch so a wrapper with the original prototype was created. Macros couldn't
be used in this case because it would break binary compatibility with modules
such as res_digium_phone that are linked to real symbols.
Tested-by: George Joseph
Review: https://reviewboard.asterisk.org/r/4033/
........
Merged revisions 425383 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@425384 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'tests/test_sorcery_realtime.c')
-rw-r--r-- | tests/test_sorcery_realtime.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/tests/test_sorcery_realtime.c b/tests/test_sorcery_realtime.c index b64ad9389..ab9c18814 100644 --- a/tests/test_sorcery_realtime.c +++ b/tests/test_sorcery_realtime.c @@ -139,15 +139,15 @@ static struct ast_config *realtime_sorcery_multi(const char *database, const cha static int realtime_sorcery_update(const char *database, const char *table, const char *keyfield, const char *entity, const struct ast_variable *fields) { - struct ast_category *object; + struct ast_category *object, *found; - if (!ast_category_exist(realtime_objects, entity)) { + if (!(found = ast_category_get(realtime_objects, entity, NULL))) { return 0; } else if (!(object = ast_category_new(entity, "", 0))) { return -1; } - ast_category_delete(realtime_objects, entity); + ast_category_delete(realtime_objects, found); ast_variable_append(object, ast_variables_dup((struct ast_variable*)fields)); ast_variable_append(object, ast_variable_new(keyfield, entity, "")); ast_category_append(realtime_objects, object); @@ -161,7 +161,7 @@ static int realtime_sorcery_store(const char *database, const char *table, const const struct ast_variable *keyfield = realtime_find_variable(fields, "id"); struct ast_category *object; - if (!keyfield || ast_category_exist(realtime_objects, keyfield->value) || !(object = ast_category_new(keyfield->value, "", 0))) { + if (!keyfield || ast_category_exist(realtime_objects, keyfield->value, NULL) || !(object = ast_category_new(keyfield->value, "", 0))) { return -1; } @@ -173,11 +173,12 @@ static int realtime_sorcery_store(const char *database, const char *table, const static int realtime_sorcery_destroy(const char *database, const char *table, const char *keyfield, const char *entity, const struct ast_variable *fields) { - if (!ast_category_exist(realtime_objects, entity)) { + struct ast_category *found; + if (!(found = ast_category_get(realtime_objects, entity, NULL))) { return 0; } - ast_category_delete(realtime_objects, entity); + ast_category_delete(realtime_objects, found); return 1; } @@ -570,7 +571,7 @@ AST_TEST_DEFINE(object_retrieve_regex) ast_test_status_update(test, "Failed to retrieve a container of objects\n"); return AST_TEST_FAIL; } else if (ao2_container_count(objects) != 2) { - ast_test_status_update(test, "Received a container with incorrect number of objects in it\n"); + ast_test_status_update(test, "Received a container with incorrect number of objects in it: %d instead of 2\n", ao2_container_count(objects)); return AST_TEST_FAIL; } |