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]

master - ccs: move ccsais plugin to config/plugins/ccsais and mark itlegacy code


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=04df458184148162c46545d7d04d415c1ab8a361
Commit:        04df458184148162c46545d7d04d415c1ab8a361
Parent:        5e2365b70614c8319cc9a7b7b890bb81661bbbeb
Author:        Fabio M. Di Nitto <fdinitto@redhat.com>
AuthorDate:    Thu Aug 7 08:25:32 2008 +0200
Committer:     Fabio M. Di Nitto <fdinitto@redhat.com>
CommitterDate: Thu Aug 14 15:18:02 2008 +0200

ccs: move ccsais plugin to config/plugins/ccsais and mark it legacy code

Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
---
 ccs/Makefile                   |    2 +-
 ccs/ccsais/Makefile            |   33 ------
 ccs/ccsais/config.c            |  224 ----------------------------------------
 config/plugins/Makefile        |    5 +-
 config/plugins/ccsais/Makefile |   33 ++++++
 config/plugins/ccsais/config.c |  224 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 262 insertions(+), 259 deletions(-)

diff --git a/ccs/Makefile b/ccs/Makefile
index c7158b5..7eab21a 100644
--- a/ccs/Makefile
+++ b/ccs/Makefile
@@ -1,4 +1,4 @@
 include ../make/defines.mk
 include $(OBJDIR)/make/passthrough.mk
 
-SUBDIRS=daemon ccsais man
+SUBDIRS=daemon man
diff --git a/ccs/ccsais/Makefile b/ccs/ccsais/Makefile
deleted file mode 100644
index f484ea3..0000000
--- a/ccs/ccsais/Makefile
+++ /dev/null
@@ -1,33 +0,0 @@
-TARGET= config_ccs.lcrso
-
-LCRSOT=$(TARGET)
-
-all: depends ${TARGET}
-
-include ../../make/defines.mk
-include $(OBJDIR)/make/cobj.mk
-include $(OBJDIR)/make/clean.mk
-include $(OBJDIR)/make/install.mk
-include $(OBJDIR)/make/uninstall.mk
-
-CFLAGS += -fPIC
-CFLAGS += -I$(SRCDIR)/config/libs/libccscompat
-CFLAGS += -I${cmanincdir}/../daemon
-CFLAGS += -I${incdir}
-
-LDFLAGS += -L$(OBJDIR)/config/libs/libccscompat -lccscompat
-LDFLAGS += -L${libdir}
-
-LDDEPS += $(OBJDIR)/config/libs/libccscompat/libccscompat.a
-
-OBJS=	config.o
-
-${TARGET}: ${OBJS} ${LDDEPS}
-	$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
-
-depends:
-	$(MAKE) -C $(OBJDIR)/config/libs/libccscompat all
-
-clean: generalclean 
-
--include $(OBJS:.o=.d)
diff --git a/ccs/ccsais/config.c b/ccs/ccsais/config.c
deleted file mode 100644
index b56a24f..0000000
--- a/ccs/ccsais/config.c
+++ /dev/null
@@ -1,224 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdint.h>
-#include <string.h>
-#include <syslog.h>
-#include <netinet/in.h>
-
-#include "list.h"
-#include "cnxman-socket.h"
-#include "cnxman-private.h"
-
-#include <corosync/lcr/lcr_comp.h>
-#include <corosync/engine/objdb.h>
-#include <corosync/engine/config.h>
-
-#include "libccscompat.h"
-#include "logging.h"
-
-#define CONFIG_VERSION_PATH	"/cluster/@config_version"
-#define CONFIG_NAME_PATH	"/cluster/@name"
-
-static int ccs_readconfig(struct objdb_iface_ver0 *objdb, char **error_string);
-static int init_config(struct objdb_iface_ver0 *objdb, char *error_string);
-static char error_reason[1024];
-
-/*
- * Exports the interface for the service
- */
-
-static struct config_iface_ver0 ccsconfig_iface_ver0 = {
-	.config_readconfig        = ccs_readconfig
-};
-
-static struct lcr_iface ifaces_ver0[2] = {
-	{
-		.name		       	= "ccsconfig",
-		.version	       	= 0,
-		.versions_replace      	= 0,
-		.versions_replace_count	= 0,
-		.dependencies	       	= 0,
-		.dependency_count      	= 0,
-		.constructor	       	= NULL,
-		.destructor	       	= NULL,
-		.interfaces	       	= NULL,
-	}
-};
-
-static struct lcr_comp ccs_comp_ver0 = {
-	.iface_count				= 1,
-	.ifaces					= ifaces_ver0,
-};
-
-
-
-__attribute__ ((constructor)) static void ccs_comp_register(void) {
-	lcr_interfaces_set(&ifaces_ver0[0], &ccsconfig_iface_ver0);
-	lcr_component_register(&ccs_comp_ver0);
-};
-
-static int should_alloc(int ccs_fd, char *key)
-{
-	int keyerror, childerr;
-	char path[256];
-	char *str = NULL;
-
-	sprintf(path, "%s/@*", key);
-	keyerror = ccs_get_list(ccs_fd, path, &str);
-	if(str) {
-		free(str);
-		str = NULL;
-	}
-
-	sprintf(path, "%s/child::*", key);
-	childerr = ccs_get_list(ccs_fd, path, &str);
-	if(str)
-		free(str);
-
-	if (childerr && keyerror)
-		return 0;
-
-	return 1;
-}
-
-static int read_config_for(int ccs_fd, struct objdb_iface_ver0 *objdb, unsigned int parent,
-			   char *object, char *key, int always_create)
-{
-	int error;
-	char *str;
-	unsigned int object_handle = 0;
-	char path[256];
-	int gotcount = 0;
-	char *subkeys[52];
-	int subkeycount = 0;
-	int i;
-
-	if (should_alloc(ccs_fd, key) || always_create)
-		objdb->object_create(parent, &object_handle, object, strlen(object));
-
-	sprintf(path, "%s/@*", key);
-
-	/* Get the keys */
-	for (;;)
-	{
-		char *equal;
-
-		error = ccs_get_list(ccs_fd, path, &str);
-		if (error || !str)
-                        break;
-
-		equal = strchr(str, '=');
-		if (equal)
-		{
-			*equal = 0;
-			objdb->object_key_create(object_handle, str, strlen(str),
-						 equal+1, strlen(equal+1)+1);
-			gotcount++;
-		}
-		free(str);
-	}
-
-	/* Now look for sub-objects.
-	   CCS can't cope with recursive queries so we have to store the result of
-	   the subkey search */
-	memset(subkeys, 0, sizeof(subkeys));
-	sprintf(path, "%s/child::*", key);
-	for (;;)
-	{
-		char *equal;
-
-		error = ccs_get_list(ccs_fd, path, &str);
-		if (error || !str)
-                        break;
-
-		/* CCS returns duplicate values for the numbered entries we use below.
-		   eg. if there are 4 <clusternode/> entries it will return
-		     clusternode=
-		     clusternode=
-		     clusternode=
-		     clusternode=
-		   which is not helpful to us cos we retrieve them as
-		     clusternode[1]
-		     clusternode[2]
-		     clusternode[3]
-		     clusternode[4]
-		   so we just store unique keys.
-		*/
-		equal = strchr(str, '=');
-		if (equal)
-			*equal = 0;
-
-		if (subkeycount > 0 && strcmp(str, subkeys[subkeycount-1]) == 0)
-		{
-			free(str);
-			break;
-		}
-		subkeys[subkeycount++] = str;
-	}
-
-	for (i=0; i<subkeycount; i++)
-	{
-		int count = 0;
-		str = subkeys[i];
-		gotcount++;
-
-		for (;;)
-		{
-			char subpath[1024];
-
-			/* Found a subkey, iterate through it's sub sections */
-			sprintf(subpath, "%s/%s[%d]", key, str, ++count);
-			if (!read_config_for(ccs_fd, objdb, object_handle, str, subpath, 0))
-				break;
-		}
-		free(str);
-	}
-	return gotcount;
-}
-
-static int ccs_readconfig(struct objdb_iface_ver0 *objdb, char **error_string)
-{
-	int ret;
-
-	/* We need to set this up to internal defaults too early */
-	openlog("corosync", LOG_CONS|LOG_PID, SYSLOGFACILITY);
-
-	/* Read low-level totem/aisexec etc config from CCS */
-	if ( !(ret = init_config(objdb, error_reason)) )
-	    sprintf (error_reason, "%s", "Successfully read config from CCS\n");
-
-        *error_string = error_reason;
-
-	return ret;
-}
-
-
-static int init_config(struct objdb_iface_ver0 *objdb, char *error_string)
-{
-	int cd;
-	char *cname = NULL;
-
-	/* Connect to ccsd */
-	if (getenv("CCS_CLUSTER_NAME")) {
-		cname = getenv("CCS_CLUSTER_NAME");
-	}
-
-	cd = ccs_force_connect(cname, 0);
-	if (cd < 0) {
-		strcpy(error_string, "Error connecting to CCS to get configuration. Check ccsd is running");
-		return -1;
-	}
-
-	/* These first few are just versions of openais.conf */
-	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "totem", "/cluster/totem", 1);
-	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "logging", "/cluster/logging", 1);
-	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "event", "/cluster/event", 1);
-	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "aisexec", "/cluster/aisexec", 1);
-	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "amf", "/cluster/amf", 1);
-
-	/* This is stuff specific to us, eg quorum device timeout */
-	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "cluster", "/cluster", 1);
-
-	ccs_disconnect(cd);
-	return 0;
-}
diff --git a/config/plugins/Makefile b/config/plugins/Makefile
index a067c80..7cbd811 100644
--- a/config/plugins/Makefile
+++ b/config/plugins/Makefile
@@ -1,4 +1,7 @@
 include ../../make/defines.mk
 include $(OBJDIR)/make/passthrough.mk
 
-SUBDIRS=xml ldap
+SUBDIRS = xml ldap
+ifdef legacy_code
+SUBDIRS += ccsais
+endif
diff --git a/config/plugins/ccsais/Makefile b/config/plugins/ccsais/Makefile
new file mode 100644
index 0000000..40ac0ec
--- /dev/null
+++ b/config/plugins/ccsais/Makefile
@@ -0,0 +1,33 @@
+TARGET= config_ccs.lcrso
+
+LCRSOT=$(TARGET)
+
+all: depends ${TARGET}
+
+include ../../../make/defines.mk
+include $(OBJDIR)/make/cobj.mk
+include $(OBJDIR)/make/clean.mk
+include $(OBJDIR)/make/install.mk
+include $(OBJDIR)/make/uninstall.mk
+
+CFLAGS += -fPIC
+CFLAGS += -I$(SRCDIR)/config/libs/libccscompat
+CFLAGS += -I${cmanincdir}/../daemon
+CFLAGS += -I${incdir}
+
+LDFLAGS += -L$(OBJDIR)/config/libs/libccscompat -lccscompat
+LDFLAGS += -L${libdir}
+
+LDDEPS += $(OBJDIR)/config/libs/libccscompat/libccscompat.a
+
+OBJS=	config.o
+
+${TARGET}: ${OBJS} ${LDDEPS}
+	$(CC) -shared -Wl,-soname,$@ -o $@ $^ $(LDFLAGS)
+
+depends:
+	$(MAKE) -C $(OBJDIR)/config/libs/libccscompat all
+
+clean: generalclean 
+
+-include $(OBJS:.o=.d)
diff --git a/config/plugins/ccsais/config.c b/config/plugins/ccsais/config.c
new file mode 100644
index 0000000..b56a24f
--- /dev/null
+++ b/config/plugins/ccsais/config.c
@@ -0,0 +1,224 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <syslog.h>
+#include <netinet/in.h>
+
+#include "list.h"
+#include "cnxman-socket.h"
+#include "cnxman-private.h"
+
+#include <corosync/lcr/lcr_comp.h>
+#include <corosync/engine/objdb.h>
+#include <corosync/engine/config.h>
+
+#include "libccscompat.h"
+#include "logging.h"
+
+#define CONFIG_VERSION_PATH	"/cluster/@config_version"
+#define CONFIG_NAME_PATH	"/cluster/@name"
+
+static int ccs_readconfig(struct objdb_iface_ver0 *objdb, char **error_string);
+static int init_config(struct objdb_iface_ver0 *objdb, char *error_string);
+static char error_reason[1024];
+
+/*
+ * Exports the interface for the service
+ */
+
+static struct config_iface_ver0 ccsconfig_iface_ver0 = {
+	.config_readconfig        = ccs_readconfig
+};
+
+static struct lcr_iface ifaces_ver0[2] = {
+	{
+		.name		       	= "ccsconfig",
+		.version	       	= 0,
+		.versions_replace      	= 0,
+		.versions_replace_count	= 0,
+		.dependencies	       	= 0,
+		.dependency_count      	= 0,
+		.constructor	       	= NULL,
+		.destructor	       	= NULL,
+		.interfaces	       	= NULL,
+	}
+};
+
+static struct lcr_comp ccs_comp_ver0 = {
+	.iface_count				= 1,
+	.ifaces					= ifaces_ver0,
+};
+
+
+
+__attribute__ ((constructor)) static void ccs_comp_register(void) {
+	lcr_interfaces_set(&ifaces_ver0[0], &ccsconfig_iface_ver0);
+	lcr_component_register(&ccs_comp_ver0);
+};
+
+static int should_alloc(int ccs_fd, char *key)
+{
+	int keyerror, childerr;
+	char path[256];
+	char *str = NULL;
+
+	sprintf(path, "%s/@*", key);
+	keyerror = ccs_get_list(ccs_fd, path, &str);
+	if(str) {
+		free(str);
+		str = NULL;
+	}
+
+	sprintf(path, "%s/child::*", key);
+	childerr = ccs_get_list(ccs_fd, path, &str);
+	if(str)
+		free(str);
+
+	if (childerr && keyerror)
+		return 0;
+
+	return 1;
+}
+
+static int read_config_for(int ccs_fd, struct objdb_iface_ver0 *objdb, unsigned int parent,
+			   char *object, char *key, int always_create)
+{
+	int error;
+	char *str;
+	unsigned int object_handle = 0;
+	char path[256];
+	int gotcount = 0;
+	char *subkeys[52];
+	int subkeycount = 0;
+	int i;
+
+	if (should_alloc(ccs_fd, key) || always_create)
+		objdb->object_create(parent, &object_handle, object, strlen(object));
+
+	sprintf(path, "%s/@*", key);
+
+	/* Get the keys */
+	for (;;)
+	{
+		char *equal;
+
+		error = ccs_get_list(ccs_fd, path, &str);
+		if (error || !str)
+                        break;
+
+		equal = strchr(str, '=');
+		if (equal)
+		{
+			*equal = 0;
+			objdb->object_key_create(object_handle, str, strlen(str),
+						 equal+1, strlen(equal+1)+1);
+			gotcount++;
+		}
+		free(str);
+	}
+
+	/* Now look for sub-objects.
+	   CCS can't cope with recursive queries so we have to store the result of
+	   the subkey search */
+	memset(subkeys, 0, sizeof(subkeys));
+	sprintf(path, "%s/child::*", key);
+	for (;;)
+	{
+		char *equal;
+
+		error = ccs_get_list(ccs_fd, path, &str);
+		if (error || !str)
+                        break;
+
+		/* CCS returns duplicate values for the numbered entries we use below.
+		   eg. if there are 4 <clusternode/> entries it will return
+		     clusternode=
+		     clusternode=
+		     clusternode=
+		     clusternode=
+		   which is not helpful to us cos we retrieve them as
+		     clusternode[1]
+		     clusternode[2]
+		     clusternode[3]
+		     clusternode[4]
+		   so we just store unique keys.
+		*/
+		equal = strchr(str, '=');
+		if (equal)
+			*equal = 0;
+
+		if (subkeycount > 0 && strcmp(str, subkeys[subkeycount-1]) == 0)
+		{
+			free(str);
+			break;
+		}
+		subkeys[subkeycount++] = str;
+	}
+
+	for (i=0; i<subkeycount; i++)
+	{
+		int count = 0;
+		str = subkeys[i];
+		gotcount++;
+
+		for (;;)
+		{
+			char subpath[1024];
+
+			/* Found a subkey, iterate through it's sub sections */
+			sprintf(subpath, "%s/%s[%d]", key, str, ++count);
+			if (!read_config_for(ccs_fd, objdb, object_handle, str, subpath, 0))
+				break;
+		}
+		free(str);
+	}
+	return gotcount;
+}
+
+static int ccs_readconfig(struct objdb_iface_ver0 *objdb, char **error_string)
+{
+	int ret;
+
+	/* We need to set this up to internal defaults too early */
+	openlog("corosync", LOG_CONS|LOG_PID, SYSLOGFACILITY);
+
+	/* Read low-level totem/aisexec etc config from CCS */
+	if ( !(ret = init_config(objdb, error_reason)) )
+	    sprintf (error_reason, "%s", "Successfully read config from CCS\n");
+
+        *error_string = error_reason;
+
+	return ret;
+}
+
+
+static int init_config(struct objdb_iface_ver0 *objdb, char *error_string)
+{
+	int cd;
+	char *cname = NULL;
+
+	/* Connect to ccsd */
+	if (getenv("CCS_CLUSTER_NAME")) {
+		cname = getenv("CCS_CLUSTER_NAME");
+	}
+
+	cd = ccs_force_connect(cname, 0);
+	if (cd < 0) {
+		strcpy(error_string, "Error connecting to CCS to get configuration. Check ccsd is running");
+		return -1;
+	}
+
+	/* These first few are just versions of openais.conf */
+	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "totem", "/cluster/totem", 1);
+	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "logging", "/cluster/logging", 1);
+	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "event", "/cluster/event", 1);
+	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "aisexec", "/cluster/aisexec", 1);
+	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "amf", "/cluster/amf", 1);
+
+	/* This is stuff specific to us, eg quorum device timeout */
+	read_config_for(cd, objdb, OBJECT_PARENT_HANDLE, "cluster", "/cluster", 1);
+
+	ccs_disconnect(cd);
+	return 0;
+}


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