FS-5832 --resolve this should dedicate the interfaces per box assuming the hostnames on the box are distinct and the switchname param is set to be identical on the 2 boxes allowing the hostname as the sep key for the box-specific tables, the aliases table is still shared and sticky aliases should be used to keep them in tact.
This commit is contained in:
parent
88be913119
commit
ad98f844ba
|
@ -4616,7 +4616,6 @@ SWITCH_STANDARD_API(show_function)
|
|||
char *command = NULL, *as = NULL;
|
||||
switch_core_flag_t cflags = switch_core_flags();
|
||||
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||
const char *hostname = switch_core_get_switchname();
|
||||
int html = 0;
|
||||
char *nl = "\n";
|
||||
stream_format format = { 0 };
|
||||
|
@ -4669,33 +4668,33 @@ SWITCH_STANDARD_API(show_function)
|
|||
if (end_of(command) == 's') {
|
||||
end_of(command) = '\0';
|
||||
}
|
||||
sprintf(sql, "select type, name, ikey from interfaces where hostname='%s' and type = '%s' order by type,name", hostname, command);
|
||||
sprintf(sql, "select type, name, ikey from interfaces where hostname='%s' and type = '%s' order by type,name", switch_core_get_hostname(), command);
|
||||
} else if (!strncasecmp(command, "module", 6)) {
|
||||
if (argv[1] && strcasecmp(argv[1], "as")) {
|
||||
sprintf(sql, "select distinct type, name, ikey, filename from interfaces where hostname='%s' and ikey = '%s' order by type,name",
|
||||
hostname, argv[1]);
|
||||
switch_core_get_hostname(), argv[1]);
|
||||
} else {
|
||||
sprintf(sql, "select distinct type, name, ikey, filename from interfaces where hostname='%s' order by type,name", hostname);
|
||||
sprintf(sql, "select distinct type, name, ikey, filename from interfaces where hostname='%s' order by type,name", switch_core_get_hostname());
|
||||
}
|
||||
} else if (!strcasecmp(command, "interfaces")) {
|
||||
sprintf(sql, "select type, name, ikey from interfaces where hostname='%s' order by type,name", hostname);
|
||||
sprintf(sql, "select type, name, ikey from interfaces where hostname='%s' order by type,name", switch_core_get_hostname());
|
||||
} else if (!strcasecmp(command, "interface_types")) {
|
||||
sprintf(sql, "select type,count(type) as total from interfaces where hostname='%s' group by type order by type", hostname);
|
||||
sprintf(sql, "select type,count(type) as total from interfaces where hostname='%s' group by type order by type", switch_core_get_switchname());
|
||||
} else if (!strcasecmp(command, "tasks")) {
|
||||
sprintf(sql, "select * from %s where hostname='%s'", command, hostname);
|
||||
sprintf(sql, "select * from %s where hostname='%s'", command, switch_core_get_hostname());
|
||||
} else if (!strcasecmp(command, "application") || !strcasecmp(command, "api")) {
|
||||
if (argv[1] && strcasecmp(argv[1], "as")) {
|
||||
sprintf(sql,
|
||||
"select name, description, syntax, ikey from interfaces where hostname='%s' and type = '%s' and description != '' and name = '%s' order by type,name",
|
||||
hostname, command, argv[1]);
|
||||
switch_core_get_hostname(), command, argv[1]);
|
||||
} else {
|
||||
sprintf(sql, "select name, description, syntax, ikey from interfaces where hostname='%s' and type = '%s' and description != '' order by type,name", hostname, command);
|
||||
sprintf(sql, "select name, description, syntax, ikey from interfaces where hostname='%s' and type = '%s' and description != '' order by type,name", switch_core_get_hostname(), command);
|
||||
}
|
||||
/* moved refreshable webpage show commands i.e. show calls|registrations|channels||detailed_calls|bridged_calls|detailed_bridged_calls */
|
||||
} else if (!strcasecmp(command, "aliases")) {
|
||||
sprintf(sql, "select * from aliases where hostname='%s' order by alias", hostname);
|
||||
sprintf(sql, "select * from aliases where hostname='%s' order by alias", switch_core_get_switchname());
|
||||
} else if (!strcasecmp(command, "complete")) {
|
||||
sprintf(sql, "select * from complete where hostname='%s' order by a1,a2,a3,a4,a5,a6,a7,a8,a9,a10", hostname);
|
||||
sprintf(sql, "select * from complete where hostname='%s' order by a1,a2,a3,a4,a5,a6,a7,a8,a9,a10", switch_core_get_switchname());
|
||||
} else if (!strncasecmp(command, "help", 4)) {
|
||||
char *cmdname = NULL;
|
||||
|
||||
|
@ -4705,9 +4704,9 @@ SWITCH_STANDARD_API(show_function)
|
|||
*cmdname++ = '\0';
|
||||
switch_snprintfv(sql, sizeof(sql),
|
||||
"select name, syntax, description, ikey from interfaces where hostname='%s' and type = 'api' and name = '%q' order by name",
|
||||
hostname, cmdname);
|
||||
switch_core_get_hostname(), cmdname);
|
||||
} else {
|
||||
switch_snprintfv(sql, sizeof(sql), "select name, syntax, description, ikey from interfaces where hostname='%q' and type = 'api' order by name", hostname);
|
||||
switch_snprintfv(sql, sizeof(sql), "select name, syntax, description, ikey from interfaces where hostname='%q' and type = 'api' order by name", switch_core_get_hostname());
|
||||
}
|
||||
} else if (!strcasecmp(command, "nat_map")) {
|
||||
switch_snprintf(sql, sizeof(sql) - 1,
|
||||
|
@ -4715,7 +4714,7 @@ SWITCH_STANDARD_API(show_function)
|
|||
" CASE proto "
|
||||
" WHEN 0 THEN 'udp' "
|
||||
" WHEN 1 THEN 'tcp' "
|
||||
" ELSE 'unknown' " " END AS proto, " " proto AS proto_num, " " sticky " " FROM nat where hostname='%s' ORDER BY port, proto", hostname);
|
||||
" ELSE 'unknown' " " END AS proto, " " proto AS proto_num, " " sticky " " FROM nat where hostname='%s' ORDER BY port, proto", switch_core_get_hostname());
|
||||
} else {
|
||||
/* from here on refreshable commands: calls|registrations|channels||detailed_calls|bridged_calls|detailed_bridged_calls */
|
||||
if (holder.format->api) {
|
||||
|
@ -4734,18 +4733,18 @@ SWITCH_STANDARD_API(show_function)
|
|||
}
|
||||
|
||||
if (!strcasecmp(command, "calls")) {
|
||||
sprintf(sql, "select * from basic_calls where hostname='%s' order by call_created_epoch", hostname);
|
||||
sprintf(sql, "select * from basic_calls where hostname='%s' order by call_created_epoch", switch_core_get_switchname());
|
||||
if (argv[1] && !strcasecmp(argv[1], "count")) {
|
||||
sprintf(sql, "select count(*) from basic_calls where hostname='%s'", hostname);
|
||||
sprintf(sql, "select count(*) from basic_calls where hostname='%s'", switch_core_get_switchname());
|
||||
holder.justcount = 1;
|
||||
if (argv[3] && !strcasecmp(argv[2], "as")) {
|
||||
as = argv[3];
|
||||
}
|
||||
}
|
||||
} else if (!strcasecmp(command, "registrations")) {
|
||||
sprintf(sql, "select * from registrations where hostname='%s'", hostname);
|
||||
sprintf(sql, "select * from registrations where hostname='%s'", switch_core_get_switchname());
|
||||
if (argv[1] && !strcasecmp(argv[1], "count")) {
|
||||
sprintf(sql, "select count(*) from registrations where hostname='%s'", hostname);
|
||||
sprintf(sql, "select count(*) from registrations where hostname='%s'", switch_core_get_switchname());
|
||||
holder.justcount = 1;
|
||||
if (argv[3] && !strcasecmp(argv[2], "as")) {
|
||||
as = argv[3];
|
||||
|
@ -4762,39 +4761,39 @@ SWITCH_STANDARD_API(show_function)
|
|||
if (strchr(argv[2], '%')) {
|
||||
sprintf(sql,
|
||||
"select * from channels where hostname='%s' and uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' or presence_data like '%s' order by created_epoch",
|
||||
hostname, argv[2], argv[2], argv[2], argv[2], argv[2]);
|
||||
switch_core_get_switchname(), argv[2], argv[2], argv[2], argv[2], argv[2]);
|
||||
} else {
|
||||
sprintf(sql,
|
||||
"select * from channels where hostname='%s' and uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' or presence_data like '%%%s%%' order by created_epoch",
|
||||
hostname, argv[2], argv[2], argv[2], argv[2], argv[2]);
|
||||
switch_core_get_switchname(), argv[2], argv[2], argv[2], argv[2], argv[2]);
|
||||
}
|
||||
if (argv[4] && !strcasecmp(argv[3], "as")) {
|
||||
as = argv[4];
|
||||
}
|
||||
} else {
|
||||
sprintf(sql, "select * from channels where hostname='%s' order by created_epoch", hostname);
|
||||
sprintf(sql, "select * from channels where hostname='%s' order by created_epoch", switch_core_get_switchname());
|
||||
}
|
||||
} else if (!strcasecmp(command, "channels")) {
|
||||
sprintf(sql, "select * from channels where hostname='%s' order by created_epoch", hostname);
|
||||
sprintf(sql, "select * from channels where hostname='%s' order by created_epoch", switch_core_get_switchname());
|
||||
if (argv[1] && !strcasecmp(argv[1], "count")) {
|
||||
sprintf(sql, "select count(*) from channels where hostname='%s'", hostname);
|
||||
sprintf(sql, "select count(*) from channels where hostname='%s'", switch_core_get_switchname());
|
||||
holder.justcount = 1;
|
||||
if (argv[3] && !strcasecmp(argv[2], "as")) {
|
||||
as = argv[3];
|
||||
}
|
||||
}
|
||||
} else if (!strcasecmp(command, "detailed_calls")) {
|
||||
sprintf(sql, "select * from detailed_calls where hostname='%s' order by created_epoch", hostname);
|
||||
sprintf(sql, "select * from detailed_calls where hostname='%s' order by created_epoch", switch_core_get_switchname());
|
||||
if (argv[2] && !strcasecmp(argv[1], "as")) {
|
||||
as = argv[2];
|
||||
}
|
||||
} else if (!strcasecmp(command, "bridged_calls")) {
|
||||
sprintf(sql, "select * from basic_calls where b_uuid is not null and hostname='%s' order by created_epoch", hostname);
|
||||
sprintf(sql, "select * from basic_calls where b_uuid is not null and hostname='%s' order by created_epoch", switch_core_get_switchname());
|
||||
if (argv[2] && !strcasecmp(argv[1], "as")) {
|
||||
as = argv[2];
|
||||
}
|
||||
} else if (!strcasecmp(command, "detailed_bridged_calls")) {
|
||||
sprintf(sql, "select * from detailed_calls where b_uuid is not null and hostname='%s' order by created_epoch", hostname);
|
||||
sprintf(sql, "select * from detailed_calls where b_uuid is not null and hostname='%s' order by created_epoch", switch_core_get_switchname());
|
||||
if (argv[2] && !strcasecmp(argv[1], "as")) {
|
||||
as = argv[2];
|
||||
}
|
||||
|
|
|
@ -1859,7 +1859,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)
|
|||
}
|
||||
}
|
||||
}
|
||||
mystream.write_function(&mystream, " '%s')", switch_core_get_switchname());
|
||||
mystream.write_function(&mystream, " '%s')", switch_core_get_hostname());
|
||||
switch_core_sql_exec(mystream.data);
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
} else if (!strcasecmp(argv[0], "add")) {
|
||||
|
@ -1875,7 +1875,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)
|
|||
}
|
||||
}
|
||||
}
|
||||
mystream.write_function(&mystream, " '%s')", switch_core_get_switchname());
|
||||
mystream.write_function(&mystream, " '%s')", switch_core_get_hostname());
|
||||
|
||||
switch_core_sql_exec(mystream.data);
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
|
@ -1892,7 +1892,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_complete(const char *string)
|
|||
mystream.write_function(&mystream, "a%d = '%w'%w", x + 1, switch_str_nil(argv[x + 1]), x == argc - 2 ? "" : " and ");
|
||||
}
|
||||
}
|
||||
mystream.write_function(&mystream, " and hostname='%s'", switch_core_get_switchname());
|
||||
mystream.write_function(&mystream, " and hostname='%s'", switch_core_get_hostname());
|
||||
switch_core_sql_exec(mystream.data);
|
||||
}
|
||||
status = SWITCH_STATUS_SUCCESS;
|
||||
|
|
|
@ -2012,7 +2012,7 @@ static void core_event_handler(switch_event_t *event)
|
|||
new_sql() = switch_mprintf("insert into tasks values(%q,'%q','%q',%q, '%q')",
|
||||
id,
|
||||
switch_event_get_header_nil(event, "task-desc"),
|
||||
switch_event_get_header_nil(event, "task-group"), manager ? manager : "0", switch_core_get_switchname()
|
||||
switch_event_get_header_nil(event, "task-group"), manager ? manager : "0", switch_core_get_hostname()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -2020,7 +2020,7 @@ static void core_event_handler(switch_event_t *event)
|
|||
case SWITCH_EVENT_DEL_SCHEDULE:
|
||||
case SWITCH_EVENT_EXE_SCHEDULE:
|
||||
new_sql() = switch_mprintf("delete from tasks where task_id=%q and hostname='%q'",
|
||||
switch_event_get_header_nil(event, "task-id"), switch_core_get_switchname());
|
||||
switch_event_get_header_nil(event, "task-id"), switch_core_get_hostname());
|
||||
break;
|
||||
case SWITCH_EVENT_RE_SCHEDULE:
|
||||
{
|
||||
|
@ -2031,7 +2031,7 @@ static void core_event_handler(switch_event_t *event)
|
|||
new_sql() = switch_mprintf("update tasks set task_desc='%q',task_group='%q', task_sql_manager=%q where task_id=%q and hostname='%q'",
|
||||
switch_event_get_header_nil(event, "task-desc"),
|
||||
switch_event_get_header_nil(event, "task-group"), manager ? manager : "0", id,
|
||||
switch_core_get_switchname());
|
||||
switch_core_get_hostname());
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -2335,7 +2335,7 @@ static void core_event_handler(switch_event_t *event)
|
|||
switch_mprintf
|
||||
("insert into interfaces (type,name,description,syntax,ikey,filename,hostname) values('%q','%q','%q','%q','%q','%q','%q')", type, name,
|
||||
switch_str_nil(description), switch_str_nil(syntax), switch_str_nil(key), switch_str_nil(filename),
|
||||
switch_core_get_switchname()
|
||||
switch_core_get_hostname()
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
@ -2346,7 +2346,7 @@ static void core_event_handler(switch_event_t *event)
|
|||
const char *name = switch_event_get_header_nil(event, "name");
|
||||
if (!zstr(type) && !zstr(name)) {
|
||||
new_sql() = switch_mprintf("delete from interfaces where type='%q' and name='%q' and hostname='%q'", type, name,
|
||||
switch_core_get_switchname());
|
||||
switch_core_get_hostname());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2369,12 +2369,12 @@ static void core_event_handler(switch_event_t *event)
|
|||
if (!strcmp("add", op)) {
|
||||
new_sql() = switch_mprintf("insert into nat (port, proto, sticky, hostname) values (%s, %s, %d,'%q')",
|
||||
switch_event_get_header_nil(event, "port"),
|
||||
switch_event_get_header_nil(event, "proto"), sticky, switch_core_get_switchname()
|
||||
switch_event_get_header_nil(event, "proto"), sticky, switch_core_get_hostname()
|
||||
);
|
||||
} else if (!strcmp("del", op)) {
|
||||
new_sql() = switch_mprintf("delete from nat where port=%s and proto=%s and hostname='%q'",
|
||||
switch_event_get_header_nil(event, "port"),
|
||||
switch_event_get_header_nil(event, "proto"), switch_core_get_switchname());
|
||||
switch_event_get_header_nil(event, "proto"), switch_core_get_hostname());
|
||||
} else if (!strcmp("status", op)) {
|
||||
/* call show nat api */
|
||||
} else if (!strcmp("status_response", op)) {
|
||||
|
|
Loading…
Reference in New Issue