[PATCH 1/2] cts: Make votequorum agent work

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

 



Previously, votequorum getinfo call accepted 0 as nodeid, meaning
current node. After changes, this is no longer case, so we need to read
cmap to get current nodeid.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 cts/agents/Makefile.am             |    2 +-
 cts/agents/votequorum_test_agent.c |   26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/cts/agents/Makefile.am b/cts/agents/Makefile.am
index 6e8bb6a..eb85c5b 100644
--- a/cts/agents/Makefile.am
+++ b/cts/agents/Makefile.am
@@ -58,7 +58,7 @@ sam_test_agent_LDADD =  -lsam -lquorum -lcmap -lcorosync_common $(LIBQB_LIBS)
 sam_test_agent_LDFLAGS =  -L../../lib -L../../common_lib
 
 votequorum_test_agent_SOURCES = votequorum_test_agent.c common_test_agent.c
-votequorum_test_agent_LDADD =  -lvotequorum -lquorum -lcorosync_common $(LIBQB_LIBS)
+votequorum_test_agent_LDADD =  -lvotequorum -lquorum -lcmap -lcorosync_common $(LIBQB_LIBS)
 votequorum_test_agent_LDFLAGS =  -L../../lib -L../../common_lib
 
 clean-local:
diff --git a/cts/agents/votequorum_test_agent.c b/cts/agents/votequorum_test_agent.c
index b27d1da..dd23929 100644
--- a/cts/agents/votequorum_test_agent.c
+++ b/cts/agents/votequorum_test_agent.c
@@ -51,11 +51,14 @@
 #include <corosync/corotypes.h>
 #include <corosync/votequorum.h>
 #include <corosync/quorum.h>
+#include <corosync/cmap.h>
 #include "common_test_agent.h"
 #include "../../lib/util.h"
 
 static quorum_handle_t q_handle = 0;
 static votequorum_handle_t vq_handle = 0;
+static uint32_t our_nodeid = 0;
+static cmap_handle_t cmap_handle = 0;
 
 static void votequorum_notification_fn(
 	votequorum_handle_t handle,
@@ -164,6 +167,23 @@ static int q_lib_init(void)
 				POLLIN|POLLNVAL, NULL, q_dispatch_wrapper_fn);
 		}
 	}
+
+	if (cmap_handle == 0) {
+		if ((ret = cmap_initialize(&cmap_handle)) != CS_OK) {
+			qb_log(LOG_ERR, "Couldn't initialize CMAP");
+			cmap_handle = 0;
+			goto out;
+		}
+
+		ret = cmap_get_uint32(cmap_handle, "runtime.votequorum.this_node_id", &our_nodeid);
+		if (ret != CS_OK) {
+			qb_log(LOG_ERR, "Unable to retrive this node nodeid");
+			cmap_handle = 0;
+			goto out;
+		}
+	}
+
+out:
 	return ret;
 }
 
@@ -175,7 +195,7 @@ static void getinfo (int sock)
 
 	q_lib_init ();
 
-	ret = votequorum_getinfo(vq_handle, 0, &info);
+	ret = votequorum_getinfo(vq_handle, our_nodeid, &info);
 	if (ret != CS_OK) {
 		snprintf (response, 100, "%s", FAIL_STR);
 		qb_log (LOG_ERR, "votequorum_getinfo FAILED: %d", ret);
@@ -323,6 +343,10 @@ static void my_pre_exit(void)
 		quorum_finalize(q_handle);
 		q_handle = 0;
 	}
+	if (cmap_handle) {
+		cmap_finalize(cmap_handle);
+		cmap_handle = 0;
+	}
 }
 
 int
-- 
1.7.10.4

_______________________________________________
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