[PATCH 10/14] Move quorumtool to use cmap service

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 tools/Makefile.am           |    2 +-
 tools/corosync-quorumtool.c |   53 ++++++++++--------------------------------
 2 files changed, 14 insertions(+), 41 deletions(-)

diff --git a/tools/Makefile.am b/tools/Makefile.am
index c9505a2..425a1b1 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -53,7 +53,7 @@ corosync_cfgtool_LDADD	= -lcfg $(LIBQB_LIBS)
 corosync_cfgtool_LDFLAGS= -L../lib
 corosync_cpgtool_LDADD	= -lcfg -lcpg $(LIBQB_LIBS)
 corosync_cpgtool_LDFLAGS= -L../lib
-corosync_quorumtool_LDADD = -lconfdb -lcfg -lquorum \
+corosync_quorumtool_LDADD = -lcmap -lcfg -lquorum \
 			    -lvotequorum ../lcr/liblcr.a $(LIBQB_LIBS)
 corosync_quorumtool_LDFLAGS = -L../lib
 
diff --git a/tools/corosync-quorumtool.c b/tools/corosync-quorumtool.c
index fceb407..d0b6335 100644
--- a/tools/corosync-quorumtool.c
+++ b/tools/corosync-quorumtool.c
@@ -52,7 +52,7 @@
 #include <corosync/corotypes.h>
 #include <corosync/totem/totem.h>
 #include <corosync/cfg.h>
-#include <corosync/confdb.h>
+#include <corosync/cmap.h>
 #include <corosync/quorum.h>
 #include <corosync/votequorum.h>
 
@@ -80,14 +80,9 @@ typedef enum {
  */
 
 /*
- * confdb bits
+ * cmap bits
  */
-static confdb_handle_t confdb_handle;
-static confdb_callbacks_t confdb_callbacks = {
-	.confdb_key_change_notify_fn = NULL,
-	.confdb_object_create_change_notify_fn = NULL,
-	.confdb_object_delete_change_notify_fn = NULL
-};
+static cmap_handle_t cmap_handle;
 
 /*
  * quorum bits
@@ -152,44 +147,22 @@ static void show_usage(const char *name)
 	printf("\n");
 }
 
-/*
- * Caller should free the returned string
- */
 static int get_quorum_type(char *quorum_type, size_t quorum_type_len)
 {
 	int err;
-	hdb_handle_t quorum_handle;
-	char buf[256];
-	size_t namelen = 0;
+	char *str;
 
 	if ((!quorum_type) || (quorum_type_len <= 0)) {
 		errno = EINVAL;
 		return -1;
 	}
 
-	memset(quorum_type, 0, quorum_type_len);
-
-	err = confdb_object_find_start(confdb_handle, OBJECT_PARENT_HANDLE);
-	if (err != CS_OK) {
+	if ((err = cmap_get_string(cmap_handle, "quorum.provider", &str)) != CS_OK) {
 		goto out;
 	}
 
-	err = confdb_object_find(confdb_handle, OBJECT_PARENT_HANDLE, (void *)"quorum", strlen("quorum"), &quorum_handle);
-	if (err != CS_OK) {
-		goto out;
-	}
-
-	err = confdb_key_get(confdb_handle, quorum_handle, (void *)"provider", strlen("provider"), buf, &namelen);
-	if (err != CS_OK) {
-		goto out;
-	}
-
-	if (namelen >= sizeof(buf)) {
-		namelen = sizeof(buf) - 1;
-	}
-	buf[namelen] = '\0';
-
-	strncpy(quorum_type, buf, quorum_type_len - 1);
+	strncpy(quorum_type, str, quorum_type_len - 1);
+	free(str);
 
 	return 0;
 out:
@@ -497,14 +470,14 @@ err_exit:
  */
 
 static int init_all(void) {
-	confdb_handle = 0;
+	cmap_handle = 0;
 	q_handle = 0;
 	v_handle = 0;
 	c_handle = 0;
 
-	if (confdb_initialize(&confdb_handle, &confdb_callbacks) != CS_OK) {
-		fprintf(stderr, "Cannot initialize CONFDB service\n");
-		confdb_handle = 0;
+	if (cmap_initialize(&cmap_handle) != CS_OK) {
+		fprintf(stderr, "Cannot initialize CMAP service\n");
+		cmap_handle = 0;
 		goto out;
 	}
 
@@ -536,8 +509,8 @@ out:
 }
 
 static void close_all(void) {
-	if (confdb_handle) {
-		confdb_finalize(confdb_handle);
+	if (cmap_handle) {
+		cmap_finalize(cmap_handle);
 	}
 	if (q_handle) {
 		quorum_finalize(q_handle);
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux