diff --git a/crm/tengine/Makefile.am b/crm/tengine/Makefile.am index 93edc56bd6..f0d28e1344 100644 --- a/crm/tengine/Makefile.am +++ b/crm/tengine/Makefile.am @@ -1,66 +1,71 @@ # # Copyright (C) 2004 Andrew Beekhof # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # MAINTAINERCLEANFILES = Makefile.in INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \ -I$(top_builddir)/libltdl -I$(top_srcdir)/libltdl \ -I$(top_builddir)/linux-ha -I$(top_srcdir)/linux-ha \ -I$(top_builddir) -I$(top_srcdir) hadir = $(sysconfdir)/ha.d halibdir = $(libdir)/@HB_PKG@ commmoddir = $(halibdir)/modules/comm havarlibdir = $(localstatedir)/lib/@HB_PKG@ PIDFILE = $(localstatedir)/run/crmd.pid XML_FLAGS = `xml2-config --cflags` XML_LIBS = `xml2-config --libs` crmdir = $(havarlibdir)/crm COMMONLIBS = $(CRM_DEBUG_LIBS) \ $(top_builddir)/lib/clplumbing/libplumb.la \ $(top_builddir)/$(CRM_DIR)/common/libcrmcommon.la \ $(top_builddir)/$(CRM_DIR)/cib/libcib.la \ $(top_builddir)/lib/apphb/libapphb.la \ $(top_builddir)/lib/hbclient/libhbclient.la \ $(GLIBLIB) \ $(LIBRT) LIBRT = @LIBRT@ AM_CFLAGS = @CFLAGS@ -DPIDFILE='"$(PIDFILE)"' $(CRM_DEBUG_FLAGS) ## binary progs -halib_PROGRAMS = tengine +halib_PROGRAMS = ttest tengine ## SOURCES -#noinst_HEADERS = config.h control.h crmd.h noinst_HEADERS = tengine.h tengine_SOURCES = tengine.c tenginemain.c tengine_CFLAGS = $(XML_FLAGS) -DHA_VARLIBDIR='"@HA_VARLIBDIR@"' tengine_LDFLAGS = $(XML_LIBS) tengine_LDADD = $(COMMONLIBS) +ttest_SOURCES = tengine.c ttest.c +ttest_CFLAGS = $(XML_FLAGS) -DTESTING=1 -DHA_VARLIBDIR='"@HA_VARLIBDIR@"' +ttest_LDFLAGS = $(XML_LIBS) +ttest_LDADD = $(COMMONLIBS) + + clean-generic: - rm -f *.log *.debug *.xml *~ + rm -f *.log *.debug *~ install-exec-local: uninstall-local: diff --git a/crm/tengine/ttest.c b/crm/tengine/ttest.c new file mode 100644 index 0000000000..2eaaf20c1a --- /dev/null +++ b/crm/tengine/ttest.c @@ -0,0 +1,149 @@ +/* $Id: ttest.c,v 1.1 2004/05/18 09:53:38 andrew Exp $ */ + +/* + * Copyright (C) 2004 Andrew Beekhof + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +#define OPTARGS "V?i:o:D:C:S:HA:U:M:I:EWRFt:m:a:d:w:c:r:p:s:" + +#include +#include +#include + +extern gboolean unpack_graph(xmlNodePtr xml_graph); +extern gboolean initiate_transition(void); +extern gboolean initialize_graph(void); + +int +main(int argc, char **argv) +{ + int argerr = 0; + int flag; + + cl_log_set_entity("ttest"); + cl_log_enable_stderr(TRUE); + cl_log_set_facility(LOG_USER); + + xmlInitParser(); + + while (1) { + int option_index = 0; + static struct option long_options[] = { + // Top-level Options + {"daemon", 0, 0, 0}, + + {0, 0, 0, 0} + }; + + flag = getopt_long(argc, argv, OPTARGS, + long_options, &option_index); + if (flag == -1) + break; + + switch(flag) { + case 0: + printf("option %s", long_options[option_index].name); + if (optarg) + printf(" with arg %s", optarg); + printf("\n"); + + break; + + /* a sample test for multiple instance + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + */ + + case 'V': + printf("option %d", flag); + break; + default: + printf("?? getopt returned character code 0%o ??\n", flag); + ++argerr; + break; + } + } + + if (optind < argc) { + printf("non-option ARGV-elements: "); + while (optind < argc) + printf("%s ", argv[optind++]); + printf("\n"); + } + + if (optind > argc) { + ++argerr; + } + + if (argerr) { + cl_log(LOG_ERR, "%d errors in option parsing", argerr); + } + + cl_log(LOG_INFO, "=#=#=#=#= Getting XML =#=#=#=#="); + + + + + CRM_DEBUG("Initializing graph..."); + initialize_graph(); + + xmlNodePtr graph = file2xml(stdin); + + CRM_DEBUG("Unpacking graph..."); + unpack_graph(graph); + CRM_DEBUG("Initiating transition..."); + + if(initiate_transition() == FALSE) { + // nothing to be done.. means we're done. + cl_log(LOG_INFO, "No actions to be taken..." + " transition compelte."); + } + CRM_DEBUG("Transition complete..."); + + return 0; +}