In the past, openaisparser.lcrso was responsible for turning on the
openais services as well as configuring the system.  Other systems may
desire to start openais.  Now there is a new plugin called
"openaisserviceenable.lcrso" which can be used with any other set of
plugins (such as pacemaker or cman).

To start openais now, you can run the services/aisexec script which
consists of:
[EMAIL PROTECTED] services]$ more aisexec
#!/bin/sh
export
COROSYNC_DEFAULT_CONFIG_IFACE="openaisserviceenable:openaisparser"
/usr/sbin/corosync -f


Or it may be run manually by setting that environment variable as shown
above.

patch attached.
Index: services/aisexec
===================================================================
--- services/aisexec	(revision 0)
+++ services/aisexec	(revision 0)
@@ -0,0 +1,3 @@
+#!/bin/sh
+export COROSYNC_DEFAULT_CONFIG_IFACE="openaisserviceenable:openaisparser"
+/usr/sbin/corosync -f

Property changes on: services/aisexec
___________________________________________________________________
Name: svn:executable
   + *

Index: services/openaisparser.c
===================================================================
--- services/openaisparser.c	(revision 1633)
+++ services/openaisparser.c	(working copy)
@@ -197,56 +197,6 @@
 
 	fclose(fp);
 
-	/*
-	 * Load clm module
-	 */
-        objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
-		"service", strlen("service"));
-	objdb->object_key_create(object_handle, "name", strlen("name"),
-		"openais_clm", strlen("openais_clm") + 1);
-	objdb->object_key_create(object_handle, "ver", strlen("ver"),
-		"0", 2);
-
-	/*
-	 * Load ckpt module
-	 */
-        objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
-		"service", strlen("service"));
-	objdb->object_key_create(object_handle, "name", strlen("name"),
-		"openais_ckpt", strlen("openais_ckpt") + 1);
-	objdb->object_key_create(object_handle, "ver", strlen("ver"),
-		"0", 2);
-
-	/*
-	 * Load evt module
-	 */
-        objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
-		"service", strlen("service"));
-	objdb->object_key_create(object_handle, "name", strlen("name"),
-		"openais_evt", strlen("openais_evt") + 1);
-	objdb->object_key_create(object_handle, "ver", strlen("ver"),
-		"0", 2);
-
-	/*
-	 * Load msg module
-	 */
-        objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
-		"service", strlen("service"));
-	objdb->object_key_create(object_handle, "name", strlen("name"),
-		"openais_msg", strlen("openais_msg") + 1);
-	objdb->object_key_create(object_handle, "ver", strlen("ver"),
-		"0", 2);
-
-	/*
-	 * Load lck module
-	 */
-        objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
-		"service", strlen("service"));
-	objdb->object_key_create(object_handle, "name", strlen("name"),
-		"openais_lck", strlen("openais_lck") + 1);
-	objdb->object_key_create(object_handle, "ver", strlen("ver"),
-		"0", 2);
-
 	sprintf (error_reason, "Successfully read main configuration file '%s'.\n", filename);
 	*error_string = error_reason;
 
Index: services/openaisserviceenable.c
===================================================================
--- services/openaisserviceenable.c	(revision 0)
+++ services/openaisserviceenable.c	(revision 0)
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2006 Red Hat, Inc.
+ *
+ * All rights reserved.
+ *
+ * Author: Patrick Caulfield ([EMAIL PROTECTED])
+ *
+ * This software licensed under BSD license, the text of which follows:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ *   this list of conditions and the following disclaimer in the documentation
+ *   and/or other materials provided with the distribution.
+ * - Neither the name of the MontaVista Software, Inc. nor the names of its
+ *   contributors may be used to endorse or promote products derived from this
+ *   software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <signal.h>
+#include <string.h>
+
+#include <corosync/engine/config.h>
+#include <corosync/lcr/lcr_comp.h>
+#include <corosync/engine/objdb.h>
+
+static char error_reason[512];
+
+struct service_engine {
+	char *name;
+	char *ver;
+};
+
+static struct service_engine service_engines[] = {
+	{ "openais_clm", "0" },
+	{ "openais_evt", "0" },
+	{ "openais_ckpt", "0" },
+	{ "openais_msg", "0" },
+	{ "openais_lck", "0" }
+};
+
+static int openais_service_enable (
+	struct objdb_iface_ver0 *objdb,
+	char **error_string)
+{
+	unsigned int i;
+	unsigned int object_handle;
+
+	for (i = 0; i < sizeof (service_engines) / sizeof (struct service_engine); i++) {
+printf ("enabling %s\n", service_engines[i].name);
+		objdb->object_create(OBJECT_PARENT_HANDLE, &object_handle,
+			"service", strlen("service"));
+		objdb->object_key_create(object_handle, "name", strlen("name"),
+			service_engines[i].name, strlen(service_engines[i].name)+ 1);
+		objdb->object_key_create(object_handle, "ver", strlen("ver"),
+			service_engines[i].ver, 2);
+	}
+
+	sprintf (error_reason, "Successfully configured openais services to load\n");
+	*error_string = error_reason;
+
+	return (0);
+}
+
+/*
+ * Dynamic Loader definition
+ */
+
+struct config_iface_ver0 serviceenable_iface_ver0 = {
+	.config_readconfig      = openais_service_enable,
+	.config_writeconfig 	= NULL,
+	.config_reloadconfig 	= NULL
+};
+
+struct lcr_iface openais_serviceenable_ver0[1] = {
+	{
+		.name				= "openaisserviceenable",
+		.version			= 0,
+		.versions_replace		= 0,
+		.versions_replace_count		= 0,
+		.dependencies			= 0,
+		.dependency_count		= 0,
+		.constructor			= NULL,
+		.destructor			= NULL,
+		.interfaces			= NULL,
+	}
+};
+
+struct openais_service_handler *serviceenable_get_handler_ver0 (void);
+
+struct lcr_comp serviceenable_comp_ver0 = {
+	.iface_count				= 1,
+	.ifaces					= openais_serviceenable_ver0
+};
+
+
+__attribute__ ((constructor)) static void serviceenable_comp_register (void) {
+        lcr_interfaces_set (&openais_serviceenable_ver0[0], &serviceenable_iface_ver0);
+	lcr_component_register (&serviceenable_comp_ver0);
+}
+
+
Index: services/Makefile
===================================================================
--- services/Makefile	(revision 1633)
+++ services/Makefile	(working copy)
@@ -52,14 +52,14 @@
 AMF_OBJS = amf.o amfutil.o amfnode.o amfcluster.o amfapp.o amfsg.o amfsu.o amfcomp.o amfsi.o
 
 # LCR objects
-LCR_SRC = openaisparser.c clm.c ckpt.c evt.c lck.c msg.c cfg.c openaisparser.c $(AMF_SRC)
-LCR_OBJS = openaisparser.o clm.o ckpt.o evt.o lck.o msg.o cfg.o openaisparser.o $(AMF_OBJS)
+LCR_SRC = openaisparser.c openaisserviceenable.c clm.c ckpt.c evt.c lck.c msg.c cfg.c $(AMF_SRC)
+LCR_OBJS = openaisparser.o openaisserviceenable.o clm.o ckpt.o evt.o lck.o msg.o cfg.o o $(AMF_OBJS)
 
 override CFLAGS += -fPIC
 
-all: openaisparser.lcrso service_clm.lcrso service_ckpt.lcrso \
-	service_evt.lcrso service_lck.lcrso service_msg.lcrso \
-	openais-instantiate
+all: openaisparser.lcrso openaisserviceenable.lcrso service_clm.lcrso \
+	service_ckpt.lcrso service_evt.lcrso service_lck.lcrso \
+	service_msg.lcrso openais-instantiate
 
 ifeq (${OPENAIS_COMPAT}, DARWIN)
 
@@ -90,6 +90,9 @@
 openaisparser.lcrso: openaisparser.o
 	$(CC) $(LDFLAGS) -bundle $(LDFLAGS) -bundle_loader $(COROSYNC_BIN) -bind_at_load openaisparser.o -o $@
 
+openaisserviceenable.lcrso: openaisserviceenable.o
+	$(CC) $(LDFLAGS) -bundle $(LDFLAGS) -bundle_loader $(COROSYNC_BIN) -bind_at_load openaisserviceenable.o -o $@
+
 vsf_ykd.lcrso: vsf_ykd.o
 	$(CC) $(LDFLAGS) -bundle $(LDFLAGS) -bundle_loader $(COROSYNC_BIN) -bind_at_load vsf_ykd.o -o $@
 
@@ -120,6 +123,9 @@
 openaisparser.lcrso: openaisparser.o
 	$(CC) -shared -Wl,-soname,openaisparser.lcrso openaisparser.o -o $@
 
+openaisserviceenable.lcrso: openaisserviceenable.o
+	$(CC) -shared -Wl,-soname,openaisserviceenable.lcrso openaisserviceenable.o -o $@
+
 vsf_ykd.lcrso: vsf_ykd.o
 	$(CC) -shared -Wl,-soname,vsf_ykd.lcrso vsf_ykd.o -o $@
 
@@ -132,7 +138,7 @@
 	$(CC) $(LDFLAGS) openais-instantiate.o -o openais-instantiate
 
 clean:
-	rm -f aisexec $(OBJS) *.o *.lcrso libtotem_pg.so* libtotem_pg.a gmon.out 
+	rm -f $(OBJS) *.o *.lcrso libtotem_pg.so* libtotem_pg.a gmon.out 
 	rm -f keygen keygen.o openais-instantiate *.da *.bb *.bbg liblogsys.so* liblogsys.a
 
 depend:
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to