mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-04 03:50:31 +00:00
Git does not support the ability to replace a token with a version string during check-in. While it does have support for replacing a token on clone, this is somewhat sub-optimal: the token is replaced with the object hash, which is not particularly easy for human consumption. What's more, in practice, the source file version was often not terribly useful. Generally, when triaging bugs, the overall version of Asterisk is far more useful than an individual SVN version of a file. As a result, this patch removes Asterisk's support for showing source file versions. Specifically, it does the following: * Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and remove passing the version in with the macro. Other facilities than 'core show file version' make use of the file names, such as setting a debug level only on a specific file. As such, the act of registering source files with the Asterisk core still has use. The macro rename now reflects the new macro purpose. * main/asterisk: - Refactor the file_version structure to reflect that it no longer tracks a version field. - Remove the "core show file version" CLI command. Without the file version, it is no longer useful. - Remove the ast_file_version_find function. The file version is no longer tracked. - Rename ast_register_file_version/ast_unregister_file_version to ast_register_file/ast_unregister_file, respectively. * main/manager: Remove value from the Version key of the ModuleCheck Action. The actual key itself has not been removed, as doing so would absolutely constitute a backwards incompatible change. However, since the file version is no longer tracked, there is no need to attempt to include it in the Version key. * UPGRADE: Add notes for: - Modification to the ModuleCheck AMI Action - Removal of the "core show file version" CLI command Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
194 lines
4.6 KiB
C
194 lines
4.6 KiB
C
/* -*- C -*-
|
|
* Asterisk -- An open source telephony toolkit.
|
|
*
|
|
* Copyright (C) 2012 - 2013, Digium, Inc.
|
|
*
|
|
* David M. Lee, II <dlee@digium.com>
|
|
*
|
|
* See http://www.asterisk.org for more information about
|
|
* the Asterisk project. Please do not directly contact
|
|
* any of the maintainers of this project for assistance;
|
|
* the project provides a web site, mailing lists and IRC
|
|
* channels for your use.
|
|
*
|
|
* This program is free software, distributed under the terms of
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
* at the top of the source tree.
|
|
*/
|
|
|
|
/*! \file
|
|
*
|
|
* \brief Implementation for ARI stubs.
|
|
*
|
|
* \author David M. Lee, II <dlee@digium.com>
|
|
*/
|
|
|
|
/*** MODULEINFO
|
|
<support_level>core</support_level>
|
|
***/
|
|
|
|
#include "asterisk.h"
|
|
|
|
ASTERISK_REGISTER_FILE()
|
|
|
|
#include "asterisk/ast_version.h"
|
|
#include "asterisk/buildinfo.h"
|
|
#include "asterisk/paths.h"
|
|
#include "asterisk/pbx.h"
|
|
#include "resource_asterisk.h"
|
|
|
|
void ast_ari_asterisk_get_info(struct ast_variable *headers,
|
|
struct ast_ari_asterisk_get_info_args *args,
|
|
struct ast_ari_response *response)
|
|
{
|
|
RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
|
|
int show_all = args->only_count == 0;
|
|
int show_build = show_all;
|
|
int show_system = show_all;
|
|
int show_config = show_all;
|
|
int show_status = show_all;
|
|
size_t i;
|
|
int res = 0;
|
|
|
|
for (i = 0; i < args->only_count; ++i) {
|
|
if (strcasecmp("build", args->only[i]) == 0) {
|
|
show_build = 1;
|
|
} else if (strcasecmp("system", args->only[i]) == 0) {
|
|
show_system = 1;
|
|
} else if (strcasecmp("config", args->only[i]) == 0) {
|
|
show_config = 1;
|
|
} else if (strcasecmp("status", args->only[i]) == 0) {
|
|
show_status = 1;
|
|
} else {
|
|
ast_log(LOG_WARNING, "Unrecognized info section '%s'\n",
|
|
args->only[i]);
|
|
}
|
|
}
|
|
|
|
json = ast_json_object_create();
|
|
|
|
if (show_build) {
|
|
res |= ast_json_object_set(json, "build",
|
|
ast_json_pack(
|
|
"{ s: s, s: s, s: s,"
|
|
" s: s, s: s, s: s }",
|
|
|
|
"os", ast_build_os,
|
|
"kernel", ast_build_kernel,
|
|
"machine", ast_build_machine,
|
|
|
|
"options", AST_BUILDOPTS,
|
|
"date", ast_build_date,
|
|
"user", ast_build_user));
|
|
}
|
|
|
|
if (show_system) {
|
|
char eid_str[128];
|
|
|
|
ast_eid_to_str(eid_str, sizeof(eid_str), &ast_eid_default);
|
|
|
|
res |= ast_json_object_set(json, "system",
|
|
ast_json_pack("{ s: s, s: s }",
|
|
"version", ast_get_version(),
|
|
"entity_id", eid_str));
|
|
}
|
|
|
|
if (show_config) {
|
|
struct ast_json *config = ast_json_pack(
|
|
"{ s: s, s: s,"
|
|
" s: { s: s, s: s } }",
|
|
|
|
"name", ast_config_AST_SYSTEM_NAME,
|
|
"default_language", ast_defaultlanguage,
|
|
|
|
"setid",
|
|
"user", ast_config_AST_RUN_USER,
|
|
"group", ast_config_AST_RUN_GROUP);
|
|
|
|
res |= ast_json_object_set(json, "config", config);
|
|
|
|
if (ast_option_maxcalls) {
|
|
res |= ast_json_object_set(config, "max_channels",
|
|
ast_json_integer_create(ast_option_maxcalls));
|
|
}
|
|
|
|
if (ast_option_maxfiles) {
|
|
res |= ast_json_object_set(config, "max_open_files",
|
|
ast_json_integer_create(ast_option_maxfiles));
|
|
}
|
|
|
|
if (ast_option_maxload) {
|
|
res |= ast_json_object_set(config, "max_load",
|
|
ast_json_real_create(ast_option_maxload));
|
|
}
|
|
}
|
|
|
|
if (show_status) {
|
|
res |= ast_json_object_set(json, "status",
|
|
ast_json_pack("{ s: o, s: o }",
|
|
"startup_time",
|
|
ast_json_timeval(ast_startuptime, NULL),
|
|
"last_reload_time",
|
|
ast_json_timeval(ast_lastreloadtime, NULL)));
|
|
}
|
|
|
|
if (res != 0) {
|
|
ast_ari_response_alloc_failed(response);
|
|
return;
|
|
}
|
|
|
|
ast_ari_response_ok(response, ast_json_ref(json));
|
|
}
|
|
|
|
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)
|
|
{
|
|
RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
|
|
RAII_VAR(struct ast_str *, tmp, NULL, ast_free);
|
|
|
|
const char *value;
|
|
|
|
ast_assert(response != NULL);
|
|
|
|
if (ast_strlen_zero(args->variable)) {
|
|
ast_ari_response_error(
|
|
response, 400, "Bad Request",
|
|
"Variable name is required");
|
|
return;
|
|
}
|
|
|
|
tmp = ast_str_create(32);
|
|
if (!tmp) {
|
|
ast_ari_response_alloc_failed(response);
|
|
return;
|
|
}
|
|
|
|
value = ast_str_retrieve_variable(&tmp, 0, NULL, NULL, args->variable);
|
|
|
|
if (!(json = ast_json_pack("{s: s}", "value", S_OR(value, "")))) {
|
|
ast_ari_response_alloc_failed(response);
|
|
return;
|
|
}
|
|
|
|
ast_ari_response_ok(response, ast_json_ref(json));
|
|
}
|
|
|
|
void ast_ari_asterisk_set_global_var(struct ast_variable *headers,
|
|
struct ast_ari_asterisk_set_global_var_args *args,
|
|
struct ast_ari_response *response)
|
|
{
|
|
ast_assert(response != NULL);
|
|
|
|
if (ast_strlen_zero(args->variable)) {
|
|
ast_ari_response_error(
|
|
response, 400, "Bad Request",
|
|
"Variable name is required");
|
|
return;
|
|
}
|
|
|
|
pbx_builtin_setvar_helper(NULL, args->variable, args->value);
|
|
|
|
ast_ari_response_no_content(response);
|
|
}
|