[asterisk-commits] mmichelson: branch mmichelson/queue-reset r99003 - /team/mmichelson/queue-res...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jan 17 16:29:22 CST 2008
Author: mmichelson
Date: Thu Jan 17 16:29:21 2008
New Revision: 99003
URL: http://svn.digium.com/view/asterisk?view=rev&rev=99003
Log:
Adding the queue reload CLI command. It works by assuming that you want to reload everything
but you can whittle down the reload scope with various extra arguments.
Modified:
team/mmichelson/queue-reset/apps/app_queue.c
Modified: team/mmichelson/queue-reset/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/queue-reset/apps/app_queue.c?view=diff&rev=99003&r1=99002&r2=99003
==============================================================================
--- team/mmichelson/queue-reset/apps/app_queue.c (original)
+++ team/mmichelson/queue-reset/apps/app_queue.c Thu Jan 17 16:29:21 2008
@@ -5078,7 +5078,6 @@
ao2_ref(cur, -1);
continue;
}
- ast_log(LOG_DEBUG, "%s in queue marked as delme, we should be deleting...\n", cur->interface);
q->membercount--;
ao2_unlink(q->members, cur);
remove_from_interfaces(cur->interface);
@@ -5104,11 +5103,6 @@
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ao2_iterator queue_iter;
- /*First things first. Let's load queuerules.conf*/
- /* Commenting this out. It's handled in the reload_handler...
- if (reload_queue_rules(reload) == AST_MODULE_LOAD_FAILURE)
- return AST_MODULE_LOAD_FAILURE;
- */
if (!(cfg = ast_config_load("queues.conf", config_flags))) {
ast_log(LOG_NOTICE, "No call queueing config file (queues.conf), so no call queues\n");
return 0;
@@ -5192,13 +5186,23 @@
static int reload_handler(int reload, enum queue_reload_mask mask, const char *queuename)
{
+ /*DEBUG STUFF REMOVE WHEN MERGING*/
+ if (mask & QUEUE_RELOAD)
+ ast_log(LOG_DEBUG, "Gonna reload the queue info\n");
+ if (mask & QUEUE_RELOAD_RULES)
+ ast_log(LOG_DEBUG, "Gonna reload the queue rules\n");
+ if (mask & QUEUE_RELOAD_MEMBER)
+ ast_log(LOG_DEBUG, "Gonna reload queue members\n");
+ if (mask & QUEUE_RESET_STATS)
+ ast_log(LOG_DEBUG, "Gonna reset the stats\n");
+ ast_log(LOG_DEBUG, "The above applies to %s\n", S_OR(queuename, "all queues"));
if (mask & QUEUE_RELOAD_RULES)
reload_queue_rules(reload);
if (mask & QUEUE_RESET_STATS)
clear_stats(queuename);
if (mask & (QUEUE_RELOAD | QUEUE_RELOAD_MEMBER))
reload_queues(reload, mask, queuename);
- return AST_MODULE_LOAD_SUCCESS;
+ return 1;
}
/*! \brief direct ouput to manager or cli with proper terminator */
@@ -6096,7 +6100,57 @@
case CLI_GENERATE:
return NULL;
}
- reload_queue_rules(1);
+ reload_handler(1, QUEUE_RELOAD_RULES, NULL);
+ return CLI_SUCCESS;
+}
+
+static char *handle_queue_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ enum queue_reload_mask mask = QUEUE_RELOAD_ALL;
+ int i;
+ char *queuename = NULL;
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "queue reload";
+ e->usage =
+ "Usage: queue reload [<queuename>] [nomembers] [norules] [noreset]\n"
+ "Reload queues. If <queuename> is specified, only reload information pertaining\n"
+ "to <queuename>. If \"nomembers\" is specified, then member information will not be\n"
+ "reloaded. If \"norules\" is specified, then queuerules.conf will not be reloaded.\n"
+ "If \"noreset\" is specified, then queue stats will not be reset\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ }
+
+ if (a->argc < 2 || a->argc > 6)
+ return CLI_SHOWUSAGE;
+
+ if (a->argc == 2) {
+ /*Reload everything*/
+ reload_handler(1, mask, NULL);
+ return CLI_SUCCESS;
+ }
+
+ for (i = 2; i < a->argc; i++) {
+ if(!strcasecmp(a->argv[i], "nomembers"))
+ mask &= ~QUEUE_RELOAD_MEMBER;
+ else if(!strcasecmp(a->argv[i], "norules"))
+ mask &= ~QUEUE_RELOAD_RULES;
+ else if(!strcasecmp(a->argv[i], "noreset")) {
+ mask &= ~QUEUE_RESET_STATS;
+ } else {
+ /*They must have specified a queue*/
+ if (queuename)
+ ast_log(LOG_WARNING, "Queue '%s' has already been specified. skipping '%s'\n", queuename, a->argv[i]);
+ else {
+ queuename = a->argv[i];
+ }
+ }
+ }
+
+ reload_handler(1, mask, queuename);
+
return CLI_SUCCESS;
}
@@ -6117,6 +6171,8 @@
AST_CLI_DEFINE(handle_queue_set_member_penalty, "Set penalty for a channel of a specified queue"),
AST_CLI_DEFINE(handle_queue_rule_show, "Show the rules defined in queuerules.conf"),
AST_CLI_DEFINE(handle_queue_rule_reload, "Reload the rules defined in queuerules.conf"),
+ AST_CLI_DEFINE(handle_queue_reload, "Reload queues, members, queue rules, or any combination"),
+ //AST_CLI_DEFINE(handle_queue_reset, "Reset queue statistics"),
};
static int unload_module(void)
More information about the asterisk-commits
mailing list