summaryrefslogtreecommitdiff
path: root/res/ari/resource_asterisk.c
diff options
context:
space:
mode:
authorBenjamin Ford <bford@digium.com>2015-07-14 13:12:32 -0500
committerBenjamin Keith Ford <bford@digium.com>2015-07-14 13:17:30 -0500
commit9d458b8311d6f897b4ac16401727efecaf043101 (patch)
tree52de471710d6bf9e96888fe9062e5b310aaf559d /res/ari/resource_asterisk.c
parent3ebe5cd7666f1f7de3c73b51c0cb610d61f23917 (diff)
ARI: Added new functionality to reload a single module.
An http request can be sent to reload an Asterisk module. If the module can not be reloaded or is not already loaded, an error response will be returned. The command "curl -v -u user:pass -X PUT 'http://localhost:8088 /ari/asterisk/modules/{moduleName}'" (or something similar, based on configuration) can be run in the terminal to access this new functionality. For more information, see: https://wiki.asterisk.org/wiki.display/~bford/Asterisk+ARI+Resource * Added new ARI functionality * Asterisk modules can be reloaded through http requests ASTERISK-25173 Change-Id: I289188bcae182b2083bdbd9ebfffd50b62f58ae1
Diffstat (limited to 'res/ari/resource_asterisk.c')
-rw-r--r--res/ari/resource_asterisk.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/res/ari/resource_asterisk.c b/res/ari/resource_asterisk.c
index 13f459eec..e76179131 100644
--- a/res/ari/resource_asterisk.c
+++ b/res/ari/resource_asterisk.c
@@ -323,6 +323,56 @@ void ast_ari_asterisk_unload_module(struct ast_variable *headers,
ast_ari_response_no_content(response);
}
+void ast_ari_asterisk_reload_module(struct ast_variable *headers,
+ struct ast_ari_asterisk_reload_module_args *args,
+ struct ast_ari_response *response)
+{
+ enum ast_module_reload_result reload_result;
+
+ ast_assert(response != NULL);
+
+ if (!ast_module_check(args->module_name)) {
+ ast_ari_response_error(
+ response, 404, "Not Found",
+ "Module not found in running modules");
+ return;
+ }
+
+ reload_result = ast_module_reload(args->module_name);
+
+ if (reload_result == AST_MODULE_RELOAD_NOT_FOUND) {
+ ast_ari_response_error(
+ response, 404, "Not Found",
+ "Module could not be found");
+ return;
+ } else if (reload_result == AST_MODULE_RELOAD_ERROR) {
+ ast_ari_response_error(
+ response, 409, "Conflict",
+ "An unknown error occurred while reloading the module");
+ return;
+ } else if (reload_result == AST_MODULE_RELOAD_IN_PROGRESS) {
+ ast_ari_response_error(
+ response, 409, "Conflict",
+ "Another reload is currently in progress");
+ return;
+ } else if (reload_result == AST_MODULE_RELOAD_UNINITIALIZED) {
+ ast_ari_response_error(
+ response, 409, "Conflict",
+ "Module has not been initialized");
+ return;
+ } else if (reload_result == AST_MODULE_RELOAD_NOT_IMPLEMENTED) {
+ ast_ari_response_error(
+ response, 409, "Conflict",
+ "Module does not support reloading");
+ return;
+ } else if (reload_result == AST_MODULE_RELOAD_QUEUED) {
+ ast_ari_response_accepted(response);
+ return;
+ }
+
+ ast_ari_response_no_content(response);
+}
+
void ast_ari_asterisk_get_global_var(struct ast_variable *headers,
struct ast_ari_asterisk_get_global_var_args *args,
struct ast_ari_response *response)