mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-08 06:12:45 +00:00
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
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user