summaryrefslogtreecommitdiff
path: root/res/ari
diff options
context:
space:
mode:
authorBenjamin Ford <bford@digium.com>2015-07-14 13:12:32 -0500
committerBenjamin Ford <bford@digium.com>2015-07-14 13:15:39 -0500
commit1aafadf8148a7cf66f73beeb6fe711d98b678fc5 (patch)
treecf4d8e057b7c39fba6cc4706bd00c01cd62a5dad /res/ari
parent9dcae23cfceedece83568d2194df00ca62f7d53c (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')
-rw-r--r--res/ari/resource_asterisk.c50
-rw-r--r--res/ari/resource_asterisk.h13
2 files changed, 63 insertions, 0 deletions
diff --git a/res/ari/resource_asterisk.c b/res/ari/resource_asterisk.c
index 4c2948d2b..1b9bf2120 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)
diff --git a/res/ari/resource_asterisk.h b/res/ari/resource_asterisk.h
index 5e3ff9b15..574d947e4 100644
--- a/res/ari/resource_asterisk.h
+++ b/res/ari/resource_asterisk.h
@@ -117,6 +117,19 @@ struct ast_ari_asterisk_unload_module_args {
* \param[out] response HTTP response
*/
void ast_ari_asterisk_unload_module(struct ast_variable *headers, struct ast_ari_asterisk_unload_module_args *args, struct ast_ari_response *response);
+/*! Argument struct for ast_ari_asterisk_reload_module() */
+struct ast_ari_asterisk_reload_module_args {
+ /*! Module's name */
+ const char *module_name;
+};
+/*!
+ * \brief Reload an Asterisk module.
+ *
+ * \param headers HTTP headers
+ * \param args Swagger parameters
+ * \param[out] response HTTP response
+ */
+void ast_ari_asterisk_reload_module(struct ast_variable *headers, struct ast_ari_asterisk_reload_module_args *args, struct ast_ari_response *response);
/*! Argument struct for ast_ari_asterisk_get_global_var() */
struct ast_ari_asterisk_get_global_var_args {
/*! The variable to get */