]> sourceware.org Git - lvm2.git/commitdiff
Add a fully-functional get_cluster_name() to clvmd corosync interface.
authorChristine Caulfield <ccaulfie@redhat.com>
Wed, 11 Feb 2009 10:13:20 +0000 (10:13 +0000)
committerChristine Caulfield <ccaulfie@redhat.com>
Wed, 11 Feb 2009 10:13:20 +0000 (10:13 +0000)
WHATS_NEW
daemons/clvmd/Makefile.in
daemons/clvmd/clvmd-corosync.c

index 23bf1fa3a2d63d14e17fa1ad72e12c5466451c13..66a7ed19242f7480141ffda14c67f006670af6de 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.45 - 
 ===================================
+  Add a fully-functional get_cluster_name() to clvmd corosync interface.
   Remove duplicate cpg_initialize from clvmd startup.
   Add option to /etc/sysconfig/cluster to select cluster type for clvmd.
   Allow clvmd to start up if its lockspace already exists.
index 268084d5c96c333fb32c7de0abaf433b8f23882e..b7d8757e244146148819836db4988cd6efb6945f 100644 (file)
@@ -68,7 +68,7 @@ endif
 
 ifeq ("$(COROSYNC)", "yes")
         SOURCES += clvmd-corosync.c
-        LMLIBS += -lquorum -lcpg -ldlm
+        LMLIBS += -lquorum -lconfdb -lcpg -ldlm
         DEFS += -DUSE_COROSYNC
 endif
 
index 427ac7fe71229019325c02c5a174e1d07d943d32..4807a15f3ab3238630c57358a6ddb56d2f6ba32d 100644 (file)
@@ -42,6 +42,7 @@
 #include <corosync/corotypes.h>
 #include <corosync/cpg.h>
 #include <corosync/quorum.h>
+#include <corosync/confdb.h>
 #include <libdlm.h>
 
 #include "locking.h"
@@ -507,7 +508,6 @@ static int _unlock_resource(const char *resource, int lockid)
        return 0;
 }
 
-/* We are always quorate ! */
 static int _is_quorate()
 {
        int quorate;
@@ -556,10 +556,49 @@ static int _cluster_send_message(const void *buf, int msglen, const char *csid,
        return cs_to_errno(err);
 }
 
-/* We don't have a cluster name to report here */
+/*
+ * We are not necessarily connected to a Red Hat Cluster system,
+ * but if we are, this returns the cluster name from cluster.conf.
+ * I've used confdb rather than ccs to reduce the inter-package
+ * dependancies as well as to allow people to set a cluster name
+ * for themselves even if they are not running on RH cluster.
+ */
 static int _get_cluster_name(char *buf, int buflen)
 {
+       confdb_handle_t handle;
+       int result;
+       int namelen = buflen;
+       unsigned int cluster_handle;
+       confdb_callbacks_t callbacks = {
+               .confdb_key_change_notify_fn = NULL,
+               .confdb_object_create_change_notify_fn = NULL,
+               .confdb_object_delete_change_notify_fn = NULL
+       };
+
+       /* This is a default in case everything else fails */
        strncpy(buf, "Corosync", buflen);
+
+       /* Look for a cluster name in confdb */
+       result = confdb_initialize (&handle, &callbacks);
+        if (result != CS_OK)
+               return 0;
+
+        result = confdb_object_find_start(handle, OBJECT_PARENT_HANDLE);
+       if (result != CS_OK)
+               goto out;
+
+        result = confdb_object_find(handle, OBJECT_PARENT_HANDLE, (void *)"cluster", strlen("cluster"), &cluster_handle);
+        if (result != CS_OK)
+               goto out;
+
+        result = confdb_key_get(handle, cluster_handle, (void *)"name", strlen("name"), buf, &namelen);
+        if (result != CS_OK)
+               goto out;
+
+       buf[namelen] = '\0';
+
+out:
+       confdb_finalize(handle);
        return 0;
 }
 
This page took 0.047517 seconds and 5 git commands to generate.