[Ocfs2-tools-commits] jlbec commits r1077 -
branches/global-heartbeat/o2cb_ctl
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Tue Sep 6 22:14:04 CDT 2005
Author: jlbec
Date: 2005-09-06 22:14:03 -0500 (Tue, 06 Sep 2005)
New Revision: 1077
Modified:
branches/global-heartbeat/o2cb_ctl/o2cb_hb_config.c
Log:
o Add info options.
Modified: branches/global-heartbeat/o2cb_ctl/o2cb_hb_config.c
===================================================================
--- branches/global-heartbeat/o2cb_ctl/o2cb_hb_config.c 2005-09-07 02:48:13 UTC (rev 1076)
+++ branches/global-heartbeat/o2cb_ctl/o2cb_hb_config.c 2005-09-07 03:14:03 UTC (rev 1077)
@@ -650,6 +650,97 @@
return rc;
}
+static void hbconf_info_one(HBConfContext *ctxt, JConfigStanza *cfs)
+{
+ gchar *cluster;
+ gchar *layout;
+ gchar *uuid;
+
+ cluster = j_config_get_attribute(cfs, "cluster");
+ layout = j_config_get_attribute(cfs, "layout");
+ uuid = j_config_get_attribute(cfs, "uuid");
+
+ if (ctxt->c_print_mode == HBCONF_PRINT_READABLE)
+ fprintf(stdout,
+ "region:\n"
+ "\tuuid = %s\n"
+ "\tlayout = %s\n"
+ "\tcluster = %s\n"
+ "\n",
+ uuid, layout, cluster);
+ else if (ctxt->c_print_mode == HBCONF_PRINT_PARSEABLE)
+ fprintf(stdout, "%s:%s:%s\n", uuid, layout, cluster);
+}
+
+static gint hbconf_info(HBConfContext *ctxt)
+{
+ gint rc = 0;
+ gint matchcount = 0;
+ JIterator *iter;
+ JConfigStanza *cfs;
+ JConfigMatch match[3];
+
+ if (ctxt->c_dev && ctxt->c_uuid)
+ {
+ fprintf(stderr,
+ PROGNAME ": Only specify one of \'-d\' and \'-u\'.\n");
+ print_usage(-EINVAL);
+ }
+
+ if (ctxt->c_dev)
+ {
+ if (!ctxt->c_layout)
+ {
+ fprintf(stderr,
+ PROGNAME ": Layout required to query by device.\n");
+ rc = -EINVAL;
+ goto out;
+ }
+
+ rc = dev_to_uuid(ctxt->c_layout, ctxt->c_dev, &ctxt->c_uuid);
+ if (rc)
+ goto out;
+ }
+
+ if (ctxt->c_cluster)
+ {
+ match[matchcount].type = J_CONFIG_MATCH_VALUE;
+ match[matchcount].name = "cluster";
+ match[matchcount].value = ctxt->c_cluster;
+ matchcount++;
+ }
+ if (ctxt->c_layout)
+ {
+ match[matchcount].type = J_CONFIG_MATCH_VALUE;
+ match[matchcount].name = "layout";
+ match[matchcount].value = ctxt->c_layout;
+ matchcount++;
+ }
+ if (ctxt->c_cluster)
+ {
+ match[matchcount].type = J_CONFIG_MATCH_VALUE;
+ match[matchcount].name = "uuid";
+ match[matchcount].value = ctxt->c_uuid;
+ matchcount++;
+ }
+
+ iter = j_config_get_stanzas(ctxt->c_cf, "region", match,
+ matchcount);
+
+ if (ctxt->c_print_mode == HBCONF_PRINT_PARSEABLE)
+ fprintf(stdout, "#uuid:layout:cluster\n");
+
+ while (j_iterator_has_more(iter))
+ {
+ cfs = (JConfigStanza *)j_iterator_get_next(iter);
+ hbconf_info_one(ctxt, cfs);
+ }
+ j_iterator_free(iter);
+
+out:
+ return rc;
+}
+
static void print_usage(gint rc)
{
FILE *output = rc ? stderr : stdout;
@@ -658,7 +749,8 @@
"Usage: " PROGNAME " -M [-c <cluster>] [-o|-z]\n"
" " PROGNAME " -M -c <cluster> -m <mode>\n"
" " PROGNAME " -A -c <cluster> -l <layout> {-u <uuid> | -d <device>}\n"
- " " PROGNAME " -R {-u <uuid> | -d <device>}\n");
+ " " PROGNAME " -R {-u <uuid> | -d <device>}\n"
+ " " PROGNAME " -I [-c <cluster>] [-l <layout>] [-u <uuid> | -d <device>]\n");
exit(rc);
}
@@ -712,6 +804,10 @@
op = HBCONF_OP_REMOVE;
break;
+ case 'I':
+ op = HBCONF_OP_INFO;
+ break;
+
case 'M':
op = HBCONF_OP_MODE;
break;
@@ -808,6 +904,10 @@
rc = hbconf_remove(&ctxt);
break;
+ case HBCONF_OP_INFO:
+ rc = hbconf_info(&ctxt);
+ break;
+
default:
fprintf(stderr, PROGNAME ": Can't get here! op %d\n",
ctxt.c_op);
More information about the Ocfs2-tools-commits
mailing list