public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
From: David Teigland <teigland@fedoraproject.org>
To: cluster-cvs-relay@redhat.com
Subject: cluster: STABLE3 - group_tool: -g option for controlling query
Date: Tue, 07 Apr 2009 21:10:00 -0000	[thread overview]
Message-ID: <20090407210812.C6F2B1201B6@lists.fedorahosted.org> (raw)

Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=71acc49eadd17dcd132df673bfb8120bb2821671
Commit:        71acc49eadd17dcd132df673bfb8120bb2821671
Parent:        2c607cbc7d1371db48d47082b42c18dc16de8b70
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Tue Apr 7 16:00:14 2009 -0500
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Tue Apr 7 16:00:14 2009 -0500

group_tool: -g option for controlling query

Allow the same -g0, -g1, -g2 style option that all daemons use to
select the old/new mode for queries.  0 for new, noncompat queries
to individual daemons, 1 for old compat query to groupd, 2 to
dynamically use 0 if daemons running in new mode or 1 if groupd
is running in old mode.  Default is 0.

Signed-off-by: David Teigland <teigland@redhat.com>
---
 group/tool/main.c |   69 +++++++++++++++++++++++++++++++++--------------------
 1 files changed, 43 insertions(+), 26 deletions(-)

diff --git a/group/tool/main.c b/group/tool/main.c
index 683323f..b65e156 100644
--- a/group/tool/main.c
+++ b/group/tool/main.c
@@ -32,13 +32,15 @@
 #define OP_DUMP				2
 #define OP_COMPAT			3
 
+#define DEFAULT_GROUPD_COMPAT		0
+
 static char *prog_name;
 static int operation;
 static int opt_ind;
 static int verbose;
-static int all_daemons;
 static int ls_all_nodes;
-static int print_header_done;
+static int opt_groupd_compat;
+static int cfg_groupd_compat = DEFAULT_GROUPD_COMPAT;
 
 
 static int do_write(int fd, void *buf, size_t count)
@@ -92,9 +94,14 @@ static void print_usage(void)
 	printf("\n");
 
 	printf("ls                 Show group state for fence, dlm, gfs\n");
-	printf("   -a              fence_tool ls; dlm_tool ls; gfs_control ls\n");
-	printf("   -n              Show all node information with -a\n");
-	printf("   -v              Show extra event information (with compat 1)\n");
+	printf("   -g <num>        select daemons to query\n");
+	printf("                   0: query fenced, dlm_controld, gfs_controld\n");
+	printf("                   1: query groupd (for old compat mode)\n");
+	printf("                   2: use 0 if daemons running in new mode,\n");
+	printf("                   or 1 if groupd running in old mode.\n");
+	printf("                   Default %d\n", DEFAULT_GROUPD_COMPAT);
+	printf("   -n              Show all node information (with -g0)\n");
+	printf("   -v              Show extra event information (with -g1)\n");
 	printf("\n");
 
 	printf("dump               Show debug log from groupd\n");
@@ -106,7 +113,7 @@ static void print_usage(void)
 	printf("\n");
 }
 
-#define OPTION_STRING "ahVvn"
+#define OPTION_STRING "g:hVvn"
 
 static void decode_arguments(int argc, char **argv)
 {
@@ -117,8 +124,10 @@ static void decode_arguments(int argc, char **argv)
 		optchar = getopt(argc, argv, OPTION_STRING);
 
 		switch (optchar) {
-		case 'a':
-			all_daemons = 1;
+		
+		case 'g':
+			opt_groupd_compat = 1;
+			cfg_groupd_compat = atoi(optarg);
 			break;
 
 		case 'n':
@@ -355,6 +364,9 @@ static int groupd_list(int argc, char **argv)
 	return ret;
 }
 
+#if 0
+static int print_header_done;
+
 static int fenced_node_compare(const void *va, const void *vb)
 {
 	const struct fenced_node *a = va;
@@ -543,6 +555,7 @@ static void gfs_controld_list(void)
 		printf("]\n");
 	}
 }
+#endif
 
 static int connect_daemon(char *path)
 {
@@ -635,6 +648,7 @@ int main(int argc, char **argv)
 		switch (version) {
 		case -1:
 			printf("groupd not running\n");
+			version = GROUP_LIBCPG;
 			break;
 		case -EAGAIN:
 			printf("groupd compatibility mode 2 (pending)\n");
@@ -650,7 +664,8 @@ int main(int argc, char **argv)
 			break;
 		}
 
-		if (all_daemons) {
+		if ((cfg_groupd_compat == 0) ||
+		    (cfg_groupd_compat == 2 && version == GROUP_LIBCPG)) {
 			/* show the new cluster3 data (from daemons) in
 			   the new daemon-specific format */
 
@@ -665,27 +680,29 @@ int main(int argc, char **argv)
 			}
 
 			if (version == GROUP_LIBGROUP)
-				printf("Run 'group_tool ls' for groupd information.\n");
-
-		} else {
-			if (version == GROUP_LIBGROUP) {
-				/* show the same old cluster2 data (from groupd)
-				   in the same old format as cluster2 */
-
-				groupd_list(argc, argv);
+				printf("Run 'group_tool ls -g1' for groupd information.\n");
+			break;
+		}
 
-			} else if (version == GROUP_LIBCPG || version == -1) {
-				/* show the new cluster3 data (from daemons)
-				   in the (nearly) same old format as cluster2 */
+		if ((cfg_groupd_compat == 1) ||
+		    (cfg_groupd_compat == 2 && version == GROUP_LIBGROUP)) {
+			/* show the same old cluster2 data (from groupd)
+			   in the same old format as cluster2 */
 
-				fenced_list();
-				dlm_controld_list();
-				gfs_controld_list();
+			groupd_list(argc, argv);
 
-				printf("Run 'group_tool ls -a' for daemon information.\n");
-			}
+			if (version == GROUP_LIBCPG)
+				printf("Run 'group_tool ls -g0' for daemon information.\n");
+			break;
 		}
-		break;
+				
+#if 0
+		/* do we want to add an option that will use these functions
+		   to "fake" new cluster3 data in the old cluster2 format? */
+		fenced_list();
+		dlm_controld_list();
+		gfs_controld_list();
+#endif
 
 	case OP_DUMP:
 		if (opt_ind && opt_ind < argc) {


                 reply	other threads:[~2009-04-07 21:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090407210812.C6F2B1201B6@lists.fedorahosted.org \
    --to=teigland@fedoraproject.org \
    --cc=cluster-cvs-relay@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).