[asterisk-commits] mmichelson: branch mmichelson/queue-reset r166898 - /team/mmichelson/queue-re...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 29 16:47:26 CST 2008


Author: mmichelson
Date: Mon Dec 29 16:47:26 2008
New Revision: 166898

URL: http://svn.digium.com/view/asterisk?view=rev&rev=166898
Log:
Some changes to the CLI commands involved in reloading queues

It was pointed out to me on IRC that some of the CLI commands I have
added violate the typical "module verb object" order of things, so
I have decided to redo the CLI commands from scratch. It's not very
difficult to do, so I don't mind. This is the first commit to that
end. Now there is a single "queue reload" command which may be used
to reload any combination of queue members, parameters, stats, and rules
for all queues or for a single queue. The idea is also to introduce
one or multiple CLI aliases so that there may be multiple methods
to execute a single logical path.

Introducing CLI aliases is probably also going to require me to make
the name of the queue the final argument for these CLI commands. For
now, the next step is to write the tab-completion function


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=166898&r1=166897&r2=166898
==============================================================================
--- team/mmichelson/queue-reset/apps/app_queue.c (original)
+++ team/mmichelson/queue-reset/apps/app_queue.c Mon Dec 29 16:47:26 2008
@@ -499,7 +499,7 @@
 	QUEUE_RELOAD_MEMBER = (1 << 1),
 	QUEUE_RELOAD_RULES = (1 << 2),
 	QUEUE_RESET_STATS = (1 << 3),
-	QUEUE_RELOAD_ALL = ((1 << 4) - 1),
+	QUEUE_RELOAD_PARAMETERS = (1 << 4),
 };
 
 static const struct strategy {
@@ -6722,123 +6722,58 @@
 	return CLI_SUCCESS; 
 }
 
-static char *handle_queue_rule_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+static char *handle_queue_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
 {
 	struct ast_flags mask = {0,};
-
-	switch (cmd) {
-		case CLI_INIT:
-			e->command = "queue rules reload";
-			e->usage = 
-				"Usage: queue rules reload\n"
-				"	Reloads rules defined in queuerules.conf\n";
-			return NULL;
-		case CLI_GENERATE:
-			return NULL;
-	}
-
-	ast_set_flag(&mask, QUEUE_RELOAD_RULES);
-	reload_handler(1, &mask, NULL);
-	return CLI_SUCCESS;
-}
-
-static char *handle_queue_reset(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	char *queuename = NULL;
-	struct ast_flags mask = {0,};
-	switch(cmd) {
-		case CLI_INIT:
-			e->command = "queue reset stats";
-			e->usage = 
-				"Usage: queue reset stats <queuename>\n"
-				"Reset stats for <queuename> if specified. Otherwise resets stats for all queues\n";
-			return NULL;
-		case CLI_GENERATE:
-			if (a->pos == 3) {
-				return complete_queue(a->line, a->word, a->pos, a->n);
-			} else {
-				return NULL;
-			}
-	}
-
-	if (a->argc < 3 || a->argc > 4)
-		return CLI_SHOWUSAGE;
-
-	if (a->argc == 4) /*queue specified*/
-		queuename = a->argv[3];
-
-	ast_set_flag(&mask, QUEUE_RESET_STATS);
-	reload_handler(1, &mask, queuename);
-	return CLI_SUCCESS;
-}
-
-static char *handle_queue_member_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	char *queuename = NULL;
-	struct ast_flags mask = {0,};
-	switch(cmd) {
-		case CLI_INIT:
-			e->command = "queue member reload\n";
-			e->usage =
-				"Usage: queue member reload <queuename>\n"
-				"Reload queue members in <queuename> if specified. Otherwise, reload members in all queues\n";
-			return NULL;
-		case CLI_GENERATE:
-			if (a->pos == 4) {
-				return complete_queue(a->line, a->word, a->pos, a->n);
-			} else {
-				return NULL;
-			}
-	}
-
-	if (a->argc < 3 || a->argc > 4)
-		return CLI_SHOWUSAGE;
-
-	if (a->argc == 4) /*queue specified*/
-		queuename = a->argv[3];
-
-	ast_set_flag(&mask, QUEUE_RELOAD_MEMBER);
-	reload_handler(1, &mask, queuename);
-	return CLI_SUCCESS;
-}
-
-static char *handle_queue_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	struct ast_flags mask;
 	int i;
 	char *queuename = NULL;
 	switch (cmd) {
 		case CLI_INIT:
 			e->command = "queue reload";
 			e->usage =
-				"Usage: queue reload [<queuename>] [nomembers] [norules] [noreset]\n"
+				"Usage: queue reload [<queuename>] [parameters] [members] [rules] [stats]\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";
+				"to <queuename>. If no extra qualifiers appear, then all aspects of the queue\n"
+				"will be reloaded. If, however, qualifiers are added, then only those portions of\n"
+				"the queue will be reloaded. As an example:\n"
+				"\"queue reload myqueue\" would cause myqueue's members, parameters, and stats to\n"
+				"be reloaded, and would cause a reload of queue rules, too.\n"
+				"\"queue reload myqueue members\" would cause myqueue's members to be reloaded but\n"
+				"no other queue parameters would be reloaded. myqueue's stats would not be reset and\n"
+				"queue rules would also not be reloaded.\n"
+				"\"queue reload parameters rules\" would cause all queues' parameters to be reloaded,\n"
+				"but would not affect their members. The queues' stats would also not be reset. Queue\n"
+				"rules would also be reloaded due to this command\n"
+				"\n"
+				"Note: the 'rules' qualifier here cannot actually be applied to a specific queue.\n"
+				"Use of the 'rules' qualifier causes queuerules.conf to be reloaded. Even if only\n"
+				"one queue is specified when using this command, reloading queue rules may cause\n"
+				"other queues to be affected\n";
 			return NULL;
 		case CLI_GENERATE:
+			/* This will be a fun one to write :) */
 			return NULL;
 	}
 
 	if (a->argc < 2 || a->argc > 6)
 		return CLI_SHOWUSAGE;
 
-	ast_set_flag(&mask, AST_FLAGS_ALL);
-
 	if (a->argc == 2) {
 		/*Reload everything*/
+		ast_set_flag(&mask, AST_FLAGS_ALL);
 		reload_handler(1, &mask, NULL);
 		return CLI_SUCCESS;
 	}
 
 	for (i = 2; i < a->argc; i++) {
-		if (!strcasecmp(a->argv[i], "nomembers")) {
-			ast_clear_flag(&mask, QUEUE_RELOAD_MEMBER);
-		} else if (!strcasecmp(a->argv[i], "norules")) {
-			ast_clear_flag(&mask, QUEUE_RELOAD_RULES);
-		} else if (!strcasecmp(a->argv[i], "noreset")) {
-			ast_clear_flag(&mask, QUEUE_RESET_STATS);
+		if (!strcasecmp(a->argv[i], "members")) {
+			ast_set_flag(&mask, QUEUE_RELOAD_MEMBER);
+		} else if (!strcasecmp(a->argv[i], "rules")) {
+			ast_set_flag(&mask, QUEUE_RELOAD_RULES);
+		} else if (!strcasecmp(a->argv[i], "stats")) {
+			ast_set_flag(&mask, QUEUE_RESET_STATS);
+		} else if (!strcasecmp(a->argv[i], "parameters")) {
+			ast_set_flag(&mask, QUEUE_RELOAD_PARAMETERS);
 		} else {
 			/*They must have specified a queue*/
 			if (queuename)
@@ -6870,10 +6805,7 @@
 	AST_CLI_DEFINE(handle_queue_pause_member, "Pause or unpause a queue member"),
 	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"),
-	AST_CLI_DEFINE(handle_queue_member_reload, "Reload queue members"),
 };
 
 static int unload_module(void)




More information about the asterisk-commits mailing list