This is the mail archive of the cluster-cvs@sourceware.org mailing list for the cluster.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Cluster Project branch, master, updated. cluster-2.99.00-14-g0b62a9c


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=0b62a9cde0a0a5ad9d7cb2a55492bf5bb9a372e7

The branch, master has been updated
       via  0b62a9cde0a0a5ad9d7cb2a55492bf5bb9a372e7 (commit)
       via  4019c7162bcf3d8021780fff1f59e5afa6767185 (commit)
      from  41f2735e80acff590c08161e76ce0d25ca5e9c66 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0b62a9cde0a0a5ad9d7cb2a55492bf5bb9a372e7
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date:   Fri May 2 12:43:34 2008 +0200

    [CCS] Detach dependency on ccsd to run the cluster
    
    The old static libccs is now called libccscompat and should not be used
    by anything outside ccs/. Note that the headers and the library are not
    installed, nor configure knows about it. All application paths that require
    compat are made static and non-configurable.
    
    Allow ccsais and ccs_tool to use libccscompat.
    
    Stop linking ccsd with libccs. It was not required before either.
    
    Add new shared library called libccs that uses aisexec confdb directly.
    The new libccs retains API compatibility with the old library so it was
    possible to "unplug" the old and "plug" the new one in one go. All the
    applications in the stack are now quering aisexec db directly.
    
    NOTES:
     - the new library does not emulate all the libccscompat calls as some
       of them are not used anywhere but this is not a problem since libccs
       was static. We are shipping it now shared and we a new soname.
     - the library implements only a small subset of xpath to query the aisexec
       config db.
    
    Port ccs_test to use the new libccs and drop all calls that are not used anywhere.
    
    Set new default ccsincdir and ccslibdir to ccs/libccsconfdb in configure.
    
    NOTE to developers: you will need to rerun configure.
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

commit 4019c7162bcf3d8021780fff1f59e5afa6767185
Author: Fabio M. Di Nitto <fdinitto@redhat.com>
Date:   Fri May 2 10:46:23 2008 +0200

    [CMAN] Do not query ccs as it might not be the right config plugin
    
    Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>

-----------------------------------------------------------------------

Summary of changes:
 ccs/Makefile                                      |    2 +-
 ccs/ccs_test/Makefile                             |    2 +-
 ccs/ccs_test/ccs_test.c                           |   73 +--
 ccs/ccs_tool/Makefile                             |   11 +-
 ccs/ccs_tool/update.c                             |    2 +-
 ccs/ccsais/Makefile                               |    7 +-
 ccs/ccsais/config.c                               |    2 +-
 ccs/daemon/Makefile                               |    7 +-
 ccs/{lib => libccscompat}/Makefile                |    7 +-
 ccs/{lib/libccs.c => libccscompat/libccscompat.c} |    2 +-
 ccs/{lib/ccs.h => libccscompat/libccscompat.h}    |   12 +-
 {cman/lib => ccs/libccsconfdb}/Makefile           |   13 +-
 ccs/{lib => libccsconfdb}/ccs.h                   |    8 +-
 ccs/libccsconfdb/libccs.c                         |  575 +++++++++++++++++++++
 cman/cman_tool/Makefile                           |    4 +-
 cman/cman_tool/cman_tool.h                        |    4 +-
 cman/cman_tool/join.c                             |   14 +-
 cman/cman_tool/main.c                             |    9 +-
 cman/daemon/cman-preconfig.c                      |    2 +-
 configure                                         |    8 +-
 20 files changed, 648 insertions(+), 116 deletions(-)
 rename ccs/{lib => libccscompat}/Makefile (93%)
 rename ccs/{lib/libccs.c => libccscompat/libccscompat.c} (99%)
 copy ccs/{lib/ccs.h => libccscompat/libccscompat.h} (79%)
 copy {cman/lib => ccs/libccsconfdb}/Makefile (82%)
 rename ccs/{lib => libccsconfdb}/ccs.h (82%)
 create mode 100644 ccs/libccsconfdb/libccs.c

diff --git a/ccs/Makefile b/ccs/Makefile
index 0bf7c8c..ed456a1 100644
--- a/ccs/Makefile
+++ b/ccs/Makefile
@@ -13,4 +13,4 @@
 include ../make/defines.mk
 include $(OBJDIR)/make/passthrough.mk
 
-SUBDIRS=lib daemon ccsais ccs_test ccs_tool man
+SUBDIRS=libccscompat libccsconfdb daemon ccsais ccs_test ccs_tool man
diff --git a/ccs/ccs_test/Makefile b/ccs/ccs_test/Makefile
index 81a3298..8819828 100644
--- a/ccs/ccs_test/Makefile
+++ b/ccs/ccs_test/Makefile
@@ -35,7 +35,7 @@ ${TARGET}: ${OBJS}
 	$(CC) -o $@ $^ $(LDFLAGS)
 
 depends:
-	$(MAKE) -C ../lib all
+	$(MAKE) -C ../libccsconfdb all
 
 clean: generalclean
 
diff --git a/ccs/ccs_test/ccs_test.c b/ccs/ccs_test/ccs_test.c
index 6f92d09..e8e96a6 100644
--- a/ccs/ccs_test/ccs_test.c
+++ b/ccs/ccs_test/ccs_test.c
@@ -20,12 +20,19 @@
 
 static void print_usage(FILE *stream);
 
+static int disconnect() {
+	if (ccs_disconnect(1) < 0)
+		return 1;
+
+	return 0;
+}
+
 int main(int argc, char *argv[]){
   int desc=0;
   int i=0;
   int error = 0;
   int force = 0, blocking = 0;
-  char *str=NULL, *str2=NULL;
+  char *str=NULL;
   char *cluster_name = NULL;
 
   if(argc <= 1){
@@ -77,6 +84,7 @@ int main(int argc, char *argv[]){
     } else {
       printf("Connect successful.\n");
       printf(" Connection descriptor = %d\n", desc);
+      disconnect();
     }
   }
   else if(!strcmp(argv[1], "disconnect")){
@@ -84,8 +92,8 @@ int main(int argc, char *argv[]){
       fprintf(stderr, "Wrong number of arguments.\n");
       exit(EXIT_FAILURE);
     }
-    desc = atoi(argv[2]);
-    if((error = ccs_disconnect(desc))){
+    desc = ccs_connect();
+    if((error = disconnect())){
       fprintf(stderr, "ccs_disconnect failed: %s\n", strerror(-error));
       exit(EXIT_FAILURE);
     } else {
@@ -97,29 +105,15 @@ int main(int argc, char *argv[]){
       fprintf(stderr, "Wrong number of arguments.\n");
       exit(EXIT_FAILURE);
     }
-    desc = atoi(argv[2]);
-    if((error = ccs_get(desc, argv[3], &str))){
-      fprintf(stderr, "ccs_get failed: %s\n", strerror(-error));
-      exit(EXIT_FAILURE);
-    } else {
-      printf("Get successful.\n");
-      printf(" Value = <%s>\n", str);
-      if(str)free(str);
-    }
-  }
-  else if(!strcmp(argv[1], "get_list")){
-    if(argc < 4){
-      fprintf(stderr, "Wrong number of arguments.\n");
-      exit(EXIT_FAILURE);
-    }
-    desc = atoi(argv[2]);
-    if((error = ccs_get_list(desc, argv[3], &str))){
+    desc = ccs_connect();
+    if((desc < 0) || (error = ccs_get(desc, argv[3], &str))){
       fprintf(stderr, "ccs_get failed: %s\n", strerror(-error));
       exit(EXIT_FAILURE);
     } else {
       printf("Get successful.\n");
       printf(" Value = <%s>\n", str);
       if(str)free(str);
+      disconnect();
     }
   }
   else if(!strcmp(argv[1], "set")){
@@ -127,44 +121,16 @@ int main(int argc, char *argv[]){
       fprintf(stderr, "Wrong number of arguments.\n");
       exit(EXIT_FAILURE);
     }
-    desc = atoi(argv[2]);
-    if((error = ccs_set(desc, argv[3], argv[4]))){
+    desc = ccs_connect();
+    if((desc < 0) || (error = ccs_set(desc, argv[3], argv[4]))){
       fprintf(stderr, "ccs_set failed: %s\n", strerror(-error));
       exit(EXIT_FAILURE);
     } else {
       printf("Set successful.\n");
+      disconnect();
     }
   }
-  else if(!strcmp(argv[1], "get_state")){
-    if(argc < 3){
-      fprintf(stderr, "Wrong number of arguments.\n");
-      exit(EXIT_FAILURE);
-    }
-    desc = atoi(argv[2]);
-    if((error = ccs_get_state(desc, &str, &str2))){
-      fprintf(stderr, "ccs_get_state failed: %s\n", strerror(-error));
-      exit(EXIT_FAILURE);
-    } else {
-      printf("Get state successful.\n");
-      printf(" Current working path: %s\n", str);
-      printf(" Previous query      : %s\n", str2);
-      if(str) free(str);
-      if(str2) free(str2);
-    }
-  }
-  else if(!strcmp(argv[1], "set_state")){
-    if(argc < 4){
-      fprintf(stderr, "Wrong number of arguments.\n");
-      exit(EXIT_FAILURE);
-    }
-    desc = atoi(argv[2]);
-    if((error = ccs_set_state(desc, argv[3], 0))){
-      fprintf(stderr, "ccs_set_state failed: %s\n", strerror(-error));
-      exit(EXIT_FAILURE);
-    } else {
-      printf("Set state successful.\n");
-    }
-  } else {
+  else {
     fprintf(stderr, "Unknown command: %s\n", argv[1]);
     exit(EXIT_FAILURE);
   }
@@ -187,9 +153,6 @@ static void print_usage(FILE *stream){
 	  "  connect <force> <block>   Connect to CCS and return connection descriptor.\n"
 	  "  disconnect <desc>         Disconnect from CCS.\n"
 	  "  get <desc> <request>      Get a value from CCS.\n"
-	  "  get_list <desc> <request> Get a value from CCS.\n"
 	  "  set <desc> <path> <val>   Set a value in CCS.\n"
-	  "  get_state <desc>          Get the state in the connection.\n"
-	  "  set_state <desc> <ncwp>   Set the current working path.\n"
 	  );
 }
diff --git a/ccs/ccs_tool/Makefile b/ccs/ccs_tool/Makefile
index a375a7e..ebb1e43 100644
--- a/ccs/ccs_tool/Makefile
+++ b/ccs/ccs_tool/Makefile
@@ -1,7 +1,7 @@
 ###############################################################################
 ###############################################################################
 ##
-##  Copyright (C) 2005 Red Hat, Inc.  All rights reserved.
+##  Copyright (C) 2005-2008 Red Hat, Inc.  All rights reserved.
 ##  
 ##  This copyrighted material is made available to anyone wishing to use,
 ##  modify, copy, or redistribute it subject to the terms and conditions
@@ -29,11 +29,12 @@ OBJS=	ccs_tool.o \
 	editconf.o
 
 CFLAGS += -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE
-CFLAGS += -I${ccsincdir} -I${cmanincdir} `xml2-config --cflags`
-CFLAGS += -I$(S)/../include
+CFLAGS += -I${cmanincdir} `xml2-config --cflags`
+CFLAGS += -I$(S)/../libccscompat -I$(S)/../include
 CFLAGS += -I${incdir}
 
-LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -lccs -lcman
+LDFLAGS += -L../libccscompat -lccscompat
+LDFLAGS += -L${cmanlibdir} -lcman
 LDFLAGS += `xml2-config --libs` -L${libdir}
 
 
@@ -41,7 +42,7 @@ ${TARGET}: ${OBJS}
 	$(CC) -o $@ $^ $(LDFLAGS)
 
 depends:
-	$(MAKE) -C ../lib all
+	$(MAKE) -C ../libccscompat all
 
 clean: generalclean
 
diff --git a/ccs/ccs_tool/update.c b/ccs/ccs_tool/update.c
index 062c8b1..2009b90 100644
--- a/ccs/ccs_tool/update.c
+++ b/ccs/ccs_tool/update.c
@@ -24,7 +24,7 @@
 #include <arpa/inet.h>
 
 #include "comm_headers.h"
-#include "ccs.h"
+#include "libccscompat.h"
 #include "libcman.h"
 
 typedef struct member_list {
diff --git a/ccs/ccsais/Makefile b/ccs/ccsais/Makefile
index 422b886..e53729c 100644
--- a/ccs/ccsais/Makefile
+++ b/ccs/ccsais/Makefile
@@ -23,10 +23,11 @@ include $(OBJDIR)/make/install.mk
 include $(OBJDIR)/make/uninstall.mk
 
 CFLAGS += -fPIC
-CFLAGS += -I${ccsincdir} -I${cmanincdir}/../daemon
+CFLAGS += -I$(S)/../libccscompat
+CFLAGS += -I${cmanincdir}/../daemon
 CFLAGS += -I${incdir}
 
-LDFLAGS += -L${ccslibdir} -lccs
+LDFLAGS += -L../libccscompat -lccscompat
 
 OBJS=	config.o
 
@@ -34,7 +35,7 @@ ${TARGET}: ${OBJS}
 	$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
 
 depends:
-	$(MAKE) -C ../lib all
+	$(MAKE) -C ../libccscompat all
 
 clean: generalclean 
 
diff --git a/ccs/ccsais/config.c b/ccs/ccsais/config.c
index fef4b2e..8639c55 100644
--- a/ccs/ccsais/config.c
+++ b/ccs/ccsais/config.c
@@ -29,7 +29,7 @@
 #include <openais/lcr/lcr_comp.h>
 #include <openais/service/swab.h>
 
-#include "ccs.h"
+#include "libccscompat.h"
 #include "logging.h"
 
 #define CONFIG_VERSION_PATH	"/cluster/@config_version"
diff --git a/ccs/daemon/Makefile b/ccs/daemon/Makefile
index e41aec5..21d8f13 100644
--- a/ccs/daemon/Makefile
+++ b/ccs/daemon/Makefile
@@ -14,7 +14,7 @@ TARGET= ccsd
 
 SBINDIRT=$(TARGET)
 
-all: depends ${TARGET}
+all: ${TARGET}
 
 include ../../make/defines.mk
 include $(OBJDIR)/make/cobj.mk
@@ -33,7 +33,7 @@ CFLAGS += -I${cmanincdir} `xml2-config --cflags` -I${openaisincdir}
 CFLAGS += -I$(S) -I$(S)/../include -I$(S)/../common
 CFLAGS += -I${incdir}
 
-LDFLAGS += -L${cmanlibdir} -lcman -L${ccslibdir} -lccs
+LDFLAGS += -L${cmanlibdir} -lcman
 LDFLAGS += -L${openaislibdir} -llogsys
 LDFLAGS += -L${libdir} `xml2-config --libs` -lpthread
 
@@ -41,9 +41,6 @@ LDFLAGS += -L${libdir} `xml2-config --libs` -lpthread
 ${TARGET}: ${OBJS}
 	$(CC) -o $@ $^ $(LDFLAGS)
 
-depends:
-	 $(MAKE) -C ../lib all
-
 clean: generalclean
 
 .PHONY: all ${TARGET}
diff --git a/ccs/lib/Makefile b/ccs/libccscompat/Makefile
similarity index 93%
rename from ccs/lib/Makefile
rename to ccs/libccscompat/Makefile
index 820342f..0f5f2d9 100644
--- a/ccs/lib/Makefile
+++ b/ccs/libccscompat/Makefile
@@ -10,10 +10,7 @@
 ###############################################################################
 ###############################################################################
 
-TARGET= libccs.a
-
-LIBDIRT=$(TARGET)
-INCDIRT=ccs.h
+TARGET= libccscompat.a
 
 all: ${TARGET}
 
@@ -23,7 +20,7 @@ include $(OBJDIR)/make/clean.mk
 include $(OBJDIR)/make/install.mk
 include $(OBJDIR)/make/uninstall.mk
 
-OBJS=	libccs.o
+OBJS=	libccscompat.o
 
 CFLAGS += -D_FILE_OFFSET_BITS=64
 CFLAGS += -fPIC
diff --git a/ccs/lib/libccs.c b/ccs/libccscompat/libccscompat.c
similarity index 99%
rename from ccs/lib/libccs.c
rename to ccs/libccscompat/libccscompat.c
index ad566d8..b9144a1 100644
--- a/ccs/lib/libccs.c
+++ b/ccs/libccscompat/libccscompat.c
@@ -23,7 +23,7 @@
 
 #include "debug.h"
 #include "comm_headers.h"
-#include "ccs.h"
+#include "libccscompat.h"
 
 #include <stdio.h>
 
diff --git a/ccs/lib/ccs.h b/ccs/libccscompat/libccscompat.h
similarity index 79%
copy from ccs/lib/ccs.h
copy to ccs/libccscompat/libccscompat.h
index 0ce58ff..ddd0c04 100644
--- a/ccs/lib/ccs.h
+++ b/ccs/libccscompat/libccscompat.h
@@ -1,7 +1,7 @@
 /******************************************************************************
 *******************************************************************************
 **
-**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2008 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -9,8 +9,12 @@
 **
 *******************************************************************************
 ******************************************************************************/
-#ifndef __CCS_DOT_H__
-#define __CCS_DOT_H__
+#ifdef __CCS_DOT_H__
+#error DO NOT INCLUDE libccscompat.h and ccs.h at the same time. it is BAD!
+#endif
+
+#ifndef __CCS_COMPAT_DOT_H__
+#define __CCS_COMPAT_DOT_H__
 
 int ccs_connect(void);
 int ccs_force_connect(char const *cluster_name, int blocking);
@@ -22,4 +26,4 @@ int ccs_get_state(int desc, char **cw_path, char **prev_query);
 int ccs_set_state(int desc, const char *cw_path, int reset_query);
 int ccs_lookup_nodename(int desc, const char *nodename, char **rtn);
 
-#endif /*  __CCS_DOT_H__ */
+#endif /*  __CCS_COMPAT_DOT_H__ */
diff --git a/cman/lib/Makefile b/ccs/libccsconfdb/Makefile
similarity index 82%
copy from cman/lib/Makefile
copy to ccs/libccsconfdb/Makefile
index 13c6f6e..91bf214 100644
--- a/cman/lib/Makefile
+++ b/ccs/libccsconfdb/Makefile
@@ -2,7 +2,7 @@
 ###############################################################################
 ##
 ##  Copyright (C) Sistina Software, Inc.  1997-2004  All rights reserved.
-##  Copyright (C) 2004 Red Hat, Inc.  All rights reserved.
+##  Copyright (C) 2004-2008 Red Hat, Inc.  All rights reserved.
 ##  
 ##  This copyrighted material is made available to anyone wishing to use,
 ##  modify, copy, or redistribute it subject to the terms and conditions
@@ -11,7 +11,7 @@
 ###############################################################################
 ###############################################################################
 
-TARGET= libcman
+TARGET= libccs
 
 LIBDIRT=$(TARGET).a \
 	$(TARGET).so.$(SOMAJOR).$(SOMINOR)
@@ -19,7 +19,7 @@ LIBDIRT=$(TARGET).a \
 LIBSYMT=$(TARGET).so \
 	$(TARGET).so.$(SOMAJOR)
 
-INCDIRT=$(TARGET).h
+INCDIRT=ccs.h
 
 include ../../make/defines.mk
 
@@ -36,15 +36,18 @@ include $(OBJDIR)/make/uninstall.mk
 OBJS=	$(TARGET).o
 
 CFLAGS += -fPIC
-CFLAGS += -I${cmanincdir} -I$(S)/../daemon
+CFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
+CFLAGS += -I${openaisincdir}
 CFLAGS += -I${incdir}
 
+LDFLAGS += -L${openaislibdir} -lconfdb
+
 $(TARGET).a: $(OBJS)
 	${AR} r $@ $^
 	${RANLIB} $@
 
 $(TARGET).so.${SOMAJOR}.${SOMINOR}: $(OBJS)
-	$(CC) -shared -o $@ -Wl,-soname=$(TARGET).so.$(SOMAJOR) $<
+	$(CC) -shared -o $@ -Wl,-soname=$(TARGET).so.$(SOMAJOR) $< $(LDFLAGS)
 	ln -sf $(TARGET).so.$(SOMAJOR).$(SOMINOR) $(TARGET).so
 	ln -sf $(TARGET).so.$(SOMAJOR).$(SOMINOR) $(TARGET).so.$(SOMAJOR)
 
diff --git a/ccs/lib/ccs.h b/ccs/libccsconfdb/ccs.h
similarity index 82%
rename from ccs/lib/ccs.h
rename to ccs/libccsconfdb/ccs.h
index 0ce58ff..91e63cd 100644
--- a/ccs/lib/ccs.h
+++ b/ccs/libccsconfdb/ccs.h
@@ -1,7 +1,7 @@
 /******************************************************************************
 *******************************************************************************
 **
-**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
+**  Copyright (C) 2004-2008 Red Hat, Inc.  All rights reserved.
 **
 **  This copyrighted material is made available to anyone wishing to use,
 **  modify, copy, or redistribute it subject to the terms and conditions
@@ -9,6 +9,10 @@
 **
 *******************************************************************************
 ******************************************************************************/
+#ifdef __CCS_COMPAT_DOT_H__
+#error DO NOT INCLUDE libccscompat.h and ccs.h at the same time. it is BAD!
+#endif
+
 #ifndef __CCS_DOT_H__
 #define __CCS_DOT_H__
 
@@ -18,8 +22,6 @@ int ccs_disconnect(int desc);
 int ccs_get(int desc, const char *query, char **rtn);
 int ccs_get_list(int desc, const char *query, char **rtn);
 int ccs_set(int desc, const char *path, char *val);
-int ccs_get_state(int desc, char **cw_path, char **prev_query);
-int ccs_set_state(int desc, const char *cw_path, int reset_query);
 int ccs_lookup_nodename(int desc, const char *nodename, char **rtn);
 
 #endif /*  __CCS_DOT_H__ */
diff --git a/ccs/libccsconfdb/libccs.c b/ccs/libccsconfdb/libccs.c
new file mode 100644
index 0000000..6806d7a
--- /dev/null
+++ b/ccs/libccsconfdb/libccs.c
@@ -0,0 +1,575 @@
+/******************************************************************************
+*******************************************************************************
+**
+**  Copyright (C) 2004-2008 Red Hat, Inc.  All rights reserved.
+**
+**  This copyrighted material is made available to anyone wishing to use,
+**  modify, copy, or redistribute it subject to the terms and conditions
+**  of the GNU General Public License v.2.
+**
+*******************************************************************************
+******************************************************************************/
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <ctype.h>
+#include <errno.h>
+#include <openais/saAis.h>
+#include <openais/confdb.h>
+
+#include "ccs.h"
+
+/* Callbacks are not supported yet */
+static confdb_callbacks_t callbacks = {
+	.confdb_change_notify_fn = NULL,
+};
+
+static confdb_handle_t handle = 0;
+
+static char current_pos[PATH_MAX];
+static char current_query[PATH_MAX];
+static char previous_query[PATH_MAX];
+static unsigned int query_handle;
+static unsigned int list_handle;
+
+/**
+ * ccs_connect
+ *
+ * This function will only allow a connection if the node is part of
+ * a quorate cluster.
+ *
+ * Returns: ccs_desc on success, < 0 on failure
+ */
+int ccs_connect(void){
+	int res;
+
+	memset(current_pos, 0, PATH_MAX);
+	memset(current_query, 0, PATH_MAX);
+	memset(previous_query, 0, PATH_MAX);
+	query_handle = OBJECT_PARENT_HANDLE;
+	list_handle = OBJECT_PARENT_HANDLE;
+
+	res = confdb_initialize (&handle, &callbacks);
+	if (res != SA_AIS_OK)
+		return -1;
+
+	return 1;
+}
+
+/**
+ * ccs_force_connect
+ *
+ * This function will only allow a connection even if the node is not
+ * part of a quorate cluster.  It will use the configuration file
+ * as specified at build time (default: /etc/cluster/cluster.conf).  If that
+ * file does not exist, a copy of the file will be broadcasted for.  If
+ * blocking is specified, the broadcasts will be retried until a config file
+ * is located.  Otherwise, the fuction will return an error if the initial
+ * broadcast is not successful.
+ *
+ * Returns: ccs_desc on success, < 0 on failure
+ */
+int ccs_force_connect(const char *cluster_name, int blocking){
+	int res = -1;
+
+	if (blocking) {
+		while ( res < 0 ) {
+			res = ccs_connect();
+			if (res < 0)
+				sleep(1);
+		}
+		return res;
+	} else
+		return ccs_connect();
+}
+
+/**
+ * ccs_disconnect
+ * @desc: the descriptor returned by ccs_connect
+ *
+ * This function frees all associated state kept with an open connection
+ *
+ * Returns: 0 on success, < 0 on error
+ */
+int ccs_disconnect(int desc){
+	int res;
+
+	if (!handle)
+		return 0;
+
+	res = confdb_finalize (handle);
+	if (res != CONFDB_OK)
+		return -1;
+
+	handle = 0;
+	return 0;
+}
+
+/*
+ * return 0 on success
+ * return -1 on errors
+ */
+int path_dive()
+{
+	char *pos=NULL;
+	unsigned int new_obj_handle;
+
+	// for now we only handle absolute path queries
+	if (strncmp(current_query, "/", 1))
+		goto fail;
+
+	pos = current_query + 1;
+
+	while (pos)
+	{
+		char *next;
+
+		/*
+		 * if we still have "/" in the query we are still diving in the path
+		 *
+		 * XXX: what about /cluster/foo[@bar="/crap/whatever"]/@baz kind of queries?
+		 * we _need_ sanity checks here
+		 */
+
+		next = strstr(pos, "/");
+
+		if(!next) {
+			pos = 0;
+			continue;
+		}
+
+		memset(next, 0, 1);
+
+		if(confdb_object_find_start(handle, query_handle) != SA_AIS_OK)
+			goto fail;
+
+		if (!strstr(pos, "[")) { /* straight path diving */
+			if (confdb_object_find(handle, query_handle, pos, strlen(pos), &new_obj_handle) != SA_AIS_OK)
+				goto fail;
+			else
+				query_handle = new_obj_handle;
+		} else {
+			/*
+			 * /something[int]/ or /something[@foo="bar"]/
+			 * start and end will identify []
+			 * middle will point to the inside request
+			 */
+
+			char *start = NULL, *middle = NULL, *end = NULL;
+
+			// we need a bit of sanity check to make sure we did parse everything correctly
+			// for example end should always be > start...
+
+			start=strstr(pos, "[");
+			end=strstr(pos, "]");
+			middle=start+1;
+			memset(start, 0, 1);
+			memset(end, 0, 1);
+
+			if (!strstr(middle, "@")) { /* lookup something with index num = int */
+				int val, i;
+
+				val = atoi(middle);
+
+				for (i = 1; i <= val; i++) {
+					if (confdb_object_find(handle, query_handle, pos, strlen(pos), &new_obj_handle) != SA_AIS_OK)
+						goto fail;
+				}
+				query_handle = new_obj_handle;
+
+			} else { /* lookup something with obj foo = bar */
+				char *equal = NULL, *value = NULL;
+				char data[PATH_MAX];
+				int goout = 0, datalen;
+
+				memset(data, 0, PATH_MAX);
+
+				// we need sanity checks here too!
+				equal=strstr(middle, "=");
+				memset(equal, 0, 1);
+
+				value=strstr(equal + 1, "\"") + 1;
+				memset(strstr(value, "\""), 0, 1);
+
+				middle=strstr(middle, "@") + 1;
+
+				// middle points to foo
+				// value to bar
+
+				while(!goout) {
+					if (confdb_object_find(handle, query_handle, pos, strlen(pos), &new_obj_handle) != SA_AIS_OK)
+						goto fail;
+					else {
+						if(confdb_key_get(handle, new_obj_handle, middle, strlen(middle), data, &datalen) == SA_AIS_OK) {
+							if (!strcmp(data, value))
+								goout=1;
+						}
+					}
+				}
+				query_handle=new_obj_handle;
+			}
+		}
+
+		/* magic magic */
+		pos = next + 1;
+		memset(current_pos, 0, PATH_MAX);
+		strcpy(current_pos, pos);
+	}
+
+	return 0;
+
+fail:
+	return -1;
+}
+
+int get_data(char **rtn, int list, int is_oldlist)
+{
+	int datalen, cmp;
+	char data[PATH_MAX];
+	char resval[PATH_MAX];
+	char keyval[PATH_MAX];
+	int keyvallen=PATH_MAX;
+	unsigned int new_obj_handle;
+
+	memset(data, 0, PATH_MAX);
+	memset(resval, 0, PATH_MAX);
+	memset(keyval, 0, PATH_MAX);
+
+	// we need to handle child::*[int value] in non list mode.
+	cmp = strcmp(current_pos, "child::*");
+	if (cmp >= 0) {
+		char *start = NULL, *end=NULL;
+		int value = 1;
+
+		// a pure child::* request should come down as list
+		if (!cmp && !list)
+			goto fail;
+
+		if (!is_oldlist || cmp) {
+			if(confdb_object_iter_start(handle, query_handle) != SA_AIS_OK)
+				goto fail;
+
+			list_handle = query_handle;
+		}
+
+		if(cmp) {
+			// usual sanity checks here
+			start=strstr(current_pos, "[") + 1;
+			end=strstr(start, "]");
+			memset(end, 0, 1);
+			value=atoi(start);
+			if (value <= 0)
+				goto fail;
+		}
+
+		while (value) {
+			if(confdb_object_iter(handle, query_handle, &new_obj_handle, data, &datalen) != SA_AIS_OK)
+				goto fail;
+
+			value--;
+		}
+
+		snprintf(resval, sizeof(resval), "%s=%s", data, keyval);
+		*rtn = strndup(resval, datalen + keyvallen + 2);
+
+	} else if (!strncmp(current_pos, "@*", strlen("@*"))) {
+
+		// this query makes sense only if we are in list mode
+		if(!list)
+			goto fail;
+
+		if (!is_oldlist)
+			if(confdb_key_iter_start(handle, query_handle) != SA_AIS_OK)
+				goto fail;
+
+		list_handle = query_handle;
+
+		if(confdb_key_iter(handle, query_handle, data, &datalen, keyval, &keyvallen) != SA_AIS_OK)
+			goto fail;
+
+		snprintf(resval, sizeof(resval), "%s=%s", data, keyval);
+		*rtn = strndup(resval, datalen+keyvallen+2);
+
+	} else { /* pure data request */
+		char *query;
+
+		// this query doesn't make sense in list mode
+		if(list)
+			goto fail;
+
+		if(confdb_object_find_start(handle, query_handle) != SA_AIS_OK)
+			goto fail;
+
+		query = strstr(current_pos, "@") + 1;
+
+		if(confdb_key_get(handle, query_handle, query, strlen(query), data, &datalen) != SA_AIS_OK)
+			goto fail;
+
+		*rtn = strndup(data, datalen);
+	}
+
+	return 0;
+
+fail:
+	return -1;
+}
+
+/**
+ * _ccs_get
+ * @desc:
+ * @query:
+ * @rtn: value returned
+ * @list: 1 to operate in list fashion
+ *
+ * This function will allocate space for the value that is the result
+ * of the given query.  It is the user's responsibility to ensure that
+ * the data returned is freed.
+ *
+ * Returns: 0 on success, < 0 on failure
+ */
+int _ccs_get(int desc, const char *query, char **rtn, int list)
+{
+	int res = 0, confdbres = 0, is_oldlist = 0;
+
+	/* we should be able to mangle the world here without destroying anything */
+	strncpy(current_query, query, PATH_MAX-1);
+
+	/* we need to check list mode */
+	if (list && !strcmp(current_query, previous_query)) {
+		query_handle = list_handle;
+		is_oldlist = 1;
+	} else {
+		query_handle = OBJECT_PARENT_HANDLE;
+		memset(previous_query, 0, PATH_MAX);
+	}
+
+	confdbres = confdb_object_find_start(handle, query_handle);
+	if (confdbres != SA_AIS_OK) {
+		res = -1;
+		goto fail;
+	}
+
+	if(!is_oldlist) {
+		res = path_dive(); /* remember path_dive cripples current_query */
+		if (res < 0)
+			goto fail;
+	}
+
+	strncpy(current_query, query, PATH_MAX-1); /* restore current_query */
+
+	res = get_data(rtn, list, is_oldlist);
+	if (res < 0)
+		goto fail;
+
+	if(list)
+		strncpy(previous_query, query, PATH_MAX-1);
+
+fail:
+	return res;
+}
+
+int ccs_get(int desc, const char *query, char **rtn){
+	return _ccs_get(desc, query, rtn, 0);
+}
+
+int ccs_get_list(int desc, const char *query, char **rtn){
+	return _ccs_get(desc, query, rtn, 1);
+}
+
+
+/**
+ * ccs_set: set an individual element's value in the config file.
+ * @desc:
+ * @path:
+ * @val:
+ *
+ * This function is used to update individual elements in a config file.
+ * It's effects are cluster wide.  It only succeeds when the node is part
+ * of a quorate cluster.
+ *
+ * Note currently implemented.
+ * 
+ * Returns: 0 on success, < 0 on failure
+ */
+int ccs_set(int desc, const char *path, char *val){
+	return -ENOSYS;
+}
+
+/**
+ * ccs_lookup_nodename
+ * @cd: ccs descriptor
+ * @nodename: node name string
+ * @retval: pointer to location to assign the result, if found
+ *
+ * This function takes any valid representation (FQDN, non-qualified
+ * hostname, IP address, IPv6 address) of a node's name and finds its
+ * canonical name (per cluster.conf). This function will find the primary
+ * node name if passed a node's "altname" or any valid representation
+ * of it.
+ *
+ * Returns: 0 on success, < 0 on failure
+ */
+int ccs_lookup_nodename(int cd, const char *nodename, char **retval) {
+	char path[256];
+	char host_only[128];
+	char *str;
+	char *p;
+	int error;
+	int ret;
+	unsigned int i;
+	size_t nodename_len;
+	struct addrinfo hints;
+
+	if (nodename == NULL)
+		return (-1);
+
+	nodename_len = strlen(nodename);
+	ret = snprintf(path, sizeof(path),
+			"/cluster/clusternodes/clusternode[@name=\"%s\"]/@name", nodename);
+	if (ret < 0 || (size_t) ret >= sizeof(path))
+		return (-E2BIG);
+
+	str = NULL;
+	error = ccs_get(cd, path, &str);
+	if (!error) {
+		*retval = str;
+		return (0);
+	}
+
+	if (nodename_len >= sizeof(host_only))
+		return (-E2BIG);
+
+	/* Try just the hostname */
+	strcpy(host_only, nodename);
+	p = strchr(host_only, '.');
+	if (p != NULL) {
+		*p = '\0';
+
+		ret = snprintf(path, sizeof(path),
+				"/cluster/clusternodes/clusternode[@name=\"%s\"]/@name",
+				host_only);
+		if (ret < 0 || (size_t) ret >= sizeof(path))
+			return (-E2BIG);
+
+		str = NULL;
+		error = ccs_get(cd, path, &str);
+		if (!error) {
+			*retval = str;
+			return (0);
+		}
+	}
+
+	memset(&hints, 0, sizeof(hints));
+	if (strchr(nodename, ':') != NULL)
+		hints.ai_family = AF_INET6;
+	else if (isdigit(nodename[nodename_len - 1]))
+		hints.ai_family = AF_INET;
+	else
+		hints.ai_family = AF_UNSPEC;
+
+	/*
+	** Try to match against each clusternode in cluster.conf.
+	*/
+	for (i = 1 ; ; i++) {
+		char canonical_name[128];
+		unsigned int altcnt;
+
+		ret = snprintf(path, sizeof(path),
+				"/cluster/clusternodes/clusternode[%u]/@name", i);
+		if (ret < 0 || (size_t) ret >= sizeof(path))
+			continue;
+
+		for (altcnt = 0 ; ; altcnt++) {
+			size_t len;
+			struct addrinfo *ai = NULL;
+			char cur_node[128];
+
+			if (altcnt != 0) {
+				ret = snprintf(path, sizeof(path), 
+					"/cluster/clusternodes/clusternode[%u]/altname[%u]/@name",
+					i, altcnt);
+				if (ret < 0 || (size_t) ret >= sizeof(path))
+					continue;
+			}
+
+			str = NULL;
+			error = ccs_get(cd, path, &str);
+			if (error || !str) {
+				if (altcnt == 0)
+					goto out_fail;
+				break;
+			}
+
+			if (altcnt == 0) {
+				if (strlen(str) >= sizeof(canonical_name)) {
+					free(str);
+					return (-E2BIG);
+				}
+				strcpy(canonical_name, str);
+			}
+
+			if (strlen(str) >= sizeof(cur_node)) {
+				free(str);
+				return (-E2BIG);
+			}
+
+			strcpy(cur_node, str);
+
+			p = strchr(cur_node, '.');
+			if (p != NULL)
+				len = p - cur_node;
+			else
+				len = strlen(cur_node);
+
+			if (strlen(host_only) == len &&
+				!strncasecmp(host_only, cur_node, len))
+			{
+				free(str);
+				*retval = strdup(canonical_name);
+				if (*retval == NULL)
+					return (-ENOMEM);
+				return (0);
+			}
+
+			if (getaddrinfo(str, NULL, &hints, &ai) == 0) {
+				struct addrinfo *cur;
+
+				for (cur = ai ; cur != NULL ; cur = cur->ai_next) {
+					char hostbuf[512];
+					if (getnameinfo(cur->ai_addr, cur->ai_addrlen,
+							hostbuf, sizeof(hostbuf),
+							NULL, 0,
+							hints.ai_family != AF_UNSPEC ? NI_NUMERICHOST : 0))
+					{
+						continue;
+					}
+
+					if (!strcasecmp(hostbuf, nodename)) {
+						freeaddrinfo(ai);
+						free(str);
+						*retval = strdup(canonical_name);
+						if (*retval == NULL)
+							return (-ENOMEM);
+						return (0);
+					}
+				}
+				freeaddrinfo(ai);
+			}
+
+			free(str);
+
+			/* Now try any altnames */
+		}
+	}
+
+out_fail:
+	*retval = NULL;
+	return (-1);
+}
diff --git a/cman/cman_tool/Makefile b/cman/cman_tool/Makefile
index dc6f8cf..8fcf32f 100644
--- a/cman/cman_tool/Makefile
+++ b/cman/cman_tool/Makefile
@@ -26,10 +26,10 @@ OBJS=	main.o \
 	join.o
 
 CFLAGS += -DAISEXECBIN=\"${aisexecbin}\"
-CFLAGS += -I${ccsincdir} -I${cmanincdir}
+CFLAGS += -I${cmanincdir}
 CFLAGS += -I${incdir}
 
-LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -lccs -lcman
+LDFLAGS += -L${cmanlibdir} -lcman
 
 
 ${TARGET}: ${OBJS}
diff --git a/cman/cman_tool/cman_tool.h b/cman/cman_tool/cman_tool.h
index 8a98c12..9ebd810 100644
--- a/cman/cman_tool/cman_tool.h
+++ b/cman/cman_tool/cman_tool.h
@@ -84,7 +84,6 @@ struct commandline
 	int two_node;
 	int port;
 	char clustername[MAX_CLUSTER_NAME_LEN];
-	int no_ccs;
 	int remove;
 	int force;
         int verbose;
@@ -102,13 +101,12 @@ struct commandline
 	int wait_quorate_opt;
 	int fence_opt;
 	int addresses_opt;
-	int noccs_opt;
+	int noconfig_opt;
 	int nosetpri_opt;
 };
 typedef struct commandline commandline_t;
 
 int join(commandline_t *comline);
-int get_ccs_join_info(commandline_t *comline);
 char *cman_error(int err);
 
 #endif  /*  __CMAN_TOOL_DOT_H__  */
diff --git a/cman/cman_tool/join.c b/cman/cman_tool/join.c
index 7cd9016..0774c24 100644
--- a/cman/cman_tool/join.c
+++ b/cman/cman_tool/join.c
@@ -17,7 +17,6 @@
 #include <netinet/in.h>
 #include "libcman.h"
 #include "cman_tool.h"
-#include "ccs.h"
 
 static char *argv[128];
 static char *envp[128];
@@ -60,17 +59,8 @@ int join(commandline_t *comline)
 	cman_handle_t h;
 	int status;
 	pid_t aisexec_pid;
-	int ctree;
 	int p[2];
 
-	if (!comline->noccs_opt) {
-		ctree = ccs_force_connect(NULL, 1);
-		if (ctree < 0) {
-			die("ccsd is not running\n");
-		}
-		ccs_disconnect(ctree);
-	}
-
         /*
 	 * If we can talk to cman then we're already joined (or joining);
 	 */
@@ -119,8 +109,8 @@ int join(commandline_t *comline)
 		snprintf(scratch, sizeof(scratch), "CMAN_DEBUGLOG=%d", comline->verbose);
 		envp[envptr++] = strdup(scratch);
 	}
-	if (comline->noccs_opt) {
-		envp[envptr++] = strdup("CMAN_NOCCS=true");
+	if (comline->noconfig_opt) {
+		envp[envptr++] = strdup("CMAN_NOCONFIG=true");
 		envp[envptr++] = strdup("OPENAIS_DEFAULT_CONFIG_IFACE=cmanpreconfig");
 	}
 	else {
diff --git a/cman/cman_tool/main.c b/cman/cman_tool/main.c
index 4ac0616..f79897d 100644
--- a/cman/cman_tool/main.c
+++ b/cman/cman_tool/main.c
@@ -52,8 +52,9 @@ static void print_usage(int subcmd)
 
 	if (!subcmd || subcmd == OP_JOIN) {
 		printf("join\n");
-		printf("  Cluster & node information is taken from CCS. These switches are provided to \n");
-		printf("  to allow CCS values to be overridden. Use them with extreme care.\n\n");
+		printf("  Cluster & node information is taken from configuration modules.\n");
+		printf("  These switches are provided to allow those values to be overridden.\n");
+		printf("  Use them with extreme care.\n\n");
 
 		printf("  -m <addr>        Multicast address to use\n");
 		printf("  -v <votes>       Number of votes this node has\n");
@@ -68,7 +69,7 @@ static void print_usage(int subcmd)
 		printf("  -t               Maximum time (in seconds) to wait\n");
 		printf("  -k <file>        Private key file for AIS communications\n");
 		printf("  -P               Don't set aisexec to realtime priority\n");
-		printf("  -X               Don't use CCS for configuration\n");
+		printf("  -X               Use internal cman defaults for configuration\n");
 		printf("\n");
 	}
 
@@ -870,7 +871,7 @@ static void decode_arguments(int argc, char *argv[], commandline_t *comline)
 			break;
 
 		case 'X':
-			comline->noccs_opt = TRUE;
+			comline->noconfig_opt = TRUE;
 			break;
 
 		case 'P':
diff --git a/cman/daemon/cman-preconfig.c b/cman/daemon/cman-preconfig.c
index 5810f5a..f549019 100644
--- a/cman/daemon/cman-preconfig.c
+++ b/cman/daemon/cman-preconfig.c
@@ -905,7 +905,7 @@ static int cmanpre_readconfig(struct objdb_iface_ver0 *objdb, char **error_strin
         }
 
 	get_env_overrides();
-	if (getenv("CMAN_NOCCS"))
+	if (getenv("CMAN_NOCONFIG"))
 		ret = set_noccs_defaults(objdb);
 	else
 		ret = get_cman_globals(objdb);
diff --git a/configure b/configure
index c1dba32..caf7d35 100755
--- a/configure
+++ b/configure
@@ -219,8 +219,8 @@ if ($help || !$err) {
   print "--kernel_build=\tthe directory containing the kernel object tree you wish to\n\t\tcompile against. (Default: /lib/modules/`uname -r`/build\n\t\tif available or /usr/src/linux as fallback)\n";
   print "--kernel_src=\tthe directory containing the kernel source you wish to\n\t\tcompile against.  (Default: /lib/modules/`uname -r`/source\n\t\tif available or \$kernel_build as fallback)\n";
   print "--incdir=\tthe base directory for include files.  (Default: {prefix}/include)\n";
-  print "--ccsincdir=\tthe base directory for ccs include files.  (Default: ./ccs/lib)\n";
-  print "--ccslibdir=\tthe base directory for ccs libraries.  (Default: ./ccs/lib)\n";
+  print "--ccsincdir=\tthe base directory for ccs include files.  (Default: ./ccs/libccsconfdb)\n";
+  print "--ccslibdir=\tthe base directory for ccs libraries.  (Default: ./ccs/libccsconfdb)\n";
   print "--cmanincdir=\tthe base directory for cman include files.  (Default: ./cman/lib)\n";
   print "--cmanlibdir=\tthe base directory for cman libraries.  (Default: ./cman/lib)\n";
   print "--dlmincdir=\tthe base directory for dlm include files.  (Default: ./dlm/libdlm)\n";
@@ -416,10 +416,10 @@ if (!$libdir) {
   $libdir="${prefix}/lib";
 }
 if (!$ccsincdir) {
-  $ccsincdir="${cdir}/ccs/lib";
+  $ccsincdir="${cdir}/ccs/libccsconfdb";
 }
 if (!$ccslibdir) {
-  $ccslibdir="${objdir}/ccs/lib";
+  $ccslibdir="${objdir}/ccs/libccsconfdb";
 }
 if (!$cmanincdir) {
   $cmanincdir="${cdir}/cman/lib";


hooks/post-receive
--
Cluster Project


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]